質問編集履歴
4
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -7,7 +7,10 @@
|
|
7
7
|
###発生している問題・エラーメッセージ
|
8
8
|
|
9
9
|
```
|
10
|
+
Exception in thread "main" javax.imageio.IIOException: Can't read input file!
|
10
|
-
|
11
|
+
at javax.imageio.ImageIO.read(ImageIO.java:1301)
|
12
|
+
at Test.main(Test.java:9)
|
13
|
+
|
11
14
|
```
|
12
15
|
|
13
16
|
###該当のソース
|
3
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -7,23 +7,18 @@
|
|
7
7
|
###発生している問題・エラーメッセージ
|
8
8
|
|
9
9
|
```
|
10
|
-
メ
|
10
|
+

|
11
11
|
```
|
12
12
|
|
13
|
-
###該当のソース
|
13
|
+
###該当のソース
|
14
|
-
```Java
|
15
|
-
|
14
|
+
import static img.ImageUtility.*;
|
16
15
|
|
17
16
|
import java.awt.image.BufferedImage;
|
18
|
-
import java.io.
|
17
|
+
import java.io.*;
|
19
|
-
|
20
18
|
import javax.imageio.ImageIO;
|
21
|
-
|
22
|
-
public class
|
19
|
+
public class Test {
|
23
|
-
|
24
|
-
|
20
|
+
public static void main(String[] args) throws IOException {
|
25
|
-
// TODO 自動生成されたメソッド・スタブ
|
26
|
-
|
21
|
+
File f = new File("test.jpg");
|
27
22
|
BufferedImage read=ImageIO.read(f);
|
28
23
|
int w = read.getWidth(),h=read.getHeight();
|
29
24
|
BufferedImage write =
|
@@ -42,31 +37,5 @@
|
|
42
37
|
|
43
38
|
File f2 = new File("ret.jpg");
|
44
39
|
ImageIO.write(write, "jpg", f2);
|
45
|
-
|
46
|
-
}
|
47
|
-
|
48
|
-
}
|
49
|
-
```
|
50
|
-
###該当のソースコード2
|
51
|
-
```Java
|
52
|
-
package OCR;
|
53
|
-
public class ImageUtility {
|
54
|
-
public static int a(int c){
|
55
|
-
return c>>>24;
|
56
40
|
}
|
57
|
-
public static int r(int c){
|
58
|
-
return c>>16&0xff;
|
59
|
-
}
|
60
|
-
public static int g(int c){
|
61
|
-
return c>>8&0xff;
|
62
|
-
}
|
63
|
-
public static int b(int c){
|
64
|
-
return c&0xff;
|
65
|
-
}
|
66
|
-
public static int rgb(int r,int g,int b){
|
67
|
-
return 0xff000000 | r <<16 | g <<8 | b;
|
68
|
-
}
|
69
|
-
public static int argb(int a,int r,int g,int b){
|
70
|
-
return a<<24 | r <<16 | g <<8 | b;
|
71
|
-
}
|
72
41
|
}
|
2
すみません。修正しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -50,4 +50,23 @@
|
|
50
50
|
###該当のソースコード2
|
51
51
|
```Java
|
52
52
|
package OCR;
|
53
|
+
public class ImageUtility {
|
54
|
+
public static int a(int c){
|
55
|
+
return c>>>24;
|
56
|
+
}
|
57
|
+
public static int r(int c){
|
58
|
+
return c>>16&0xff;
|
59
|
+
}
|
60
|
+
public static int g(int c){
|
61
|
+
return c>>8&0xff;
|
62
|
+
}
|
63
|
+
public static int b(int c){
|
64
|
+
return c&0xff;
|
65
|
+
}
|
66
|
+
public static int rgb(int r,int g,int b){
|
67
|
+
return 0xff000000 | r <<16 | g <<8 | b;
|
68
|
+
}
|
69
|
+
public static int argb(int a,int r,int g,int b){
|
53
|
-
|
70
|
+
return a<<24 | r <<16 | g <<8 | b;
|
71
|
+
}
|
72
|
+
}
|
1
ソースコード修正、エラーコード追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
###発生している問題・エラーメッセージ
|
8
8
|
|
9
9
|
```
|
10
|
-
|
10
|
+
メソッド r(int) は型 main で未定義です
|
11
11
|
```
|
12
12
|
|
13
13
|
###該当のソースコード1
|
@@ -50,44 +50,4 @@
|
|
50
50
|
###該当のソースコード2
|
51
51
|
```Java
|
52
52
|
package OCR;
|
53
|
-
|
54
|
-
import java.awt.image.BufferedImage;
|
55
|
-
import java.io.File;
|
56
|
-
|
57
|
-
import javax.imageio.ImageIO;
|
58
|
-
|
59
|
-
public class main {
|
60
|
-
|
61
|
-
public static void main(String[] args) {
|
62
|
-
// TODO 自動生成されたメソッド・スタブ
|
63
|
-
File f = new File("test.jpg");
|
64
|
-
BufferedImage read=ImageIO.read(f);
|
65
|
-
int w = read.getWidth(),h=read.getHeight();
|
66
|
-
BufferedImage write =
|
67
|
-
new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
|
68
|
-
|
69
|
-
for(int y=0;y<h;y++){
|
70
|
-
for(int x=0;x<w;x++){
|
71
|
-
int c = read.getRGB(x, y);
|
72
|
-
int r = 255-r(c);
|
73
|
-
int g = 255-g(c);
|
74
|
-
int b = 255-b(c);
|
75
|
-
int rgb = rgb(r,g,b);
|
76
|
-
write.setRGB(x,y,rgb);
|
77
|
-
}
|
78
|
-
}
|
79
|
-
|
80
|
-
File f2 = new File("ret.jpg");
|
81
|
-
ImageIO.write(write, "jpg", f2);
|
82
|
-
|
83
|
-
}
|
84
|
-
|
85
|
-
}
|
86
|
-
```
|
87
|
-
|
88
|
-
###試したこと
|
89
|
-
ソース1とソース2は同じパッケージに入れています。
|
90
|
-
|
91
|
-
###補足情報(言語/FW/ツール等のバージョンなど)
|
92
|
-
ソースは以下のものを参考にしています。
|
93
|
-
|
53
|
+
i.hatenablog.com/entry/20111012/1318436587
|