-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathImage.java
105 lines (94 loc) · 2.7 KB
/
Image.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import java.io.File;
import java.io.*;
import java.io.IOException;
import java.util.Scanner;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
public class Image{
public static void main(String args[])throws IOException{
int width = 640;
int height = 320;
BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
File f = null;
//ImagetoBinary il = new ImagetoBinary();
String bin1 = "11000011110011101001011000011101110111001111011111101101110010111001101100101";
char[] bin = bin1.toCharArray();
FileInputStream fstream = new FileInputStream("Files\\test\\a.txt");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String data;
String[] tmp=null;
while ((data = br.readLine()) != null) {
tmp = data.split(" ");
}
int[] a=new int[tmp.length];
for(int i=0;i<tmp.length;i++)
{
String n = tmp[i];
int z = Integer.parseInt(n);
a[i]=z;
}
fstream = new FileInputStream("Files\\test\\b.txt");
in = new DataInputStream(fstream);
br = new BufferedReader(new InputStreamReader(in));
tmp=null;
while ((data = br.readLine()) != null) {
tmp = data.split(" ");
}
int[] b=new int[tmp.length];
for(int i=0;i<tmp.length;i++)
{
String n = tmp[i];
int z = Integer.parseInt(n);
b[i]=z;
}
fstream = new FileInputStream("Files\\test\\g.txt");
in = new DataInputStream(fstream);
br = new BufferedReader(new InputStreamReader(in));
tmp=null;
while ((data = br.readLine()) != null) {
tmp = data.split(" ");
}
int[] g=new int[tmp.length];
for(int i=0;i<tmp.length;i++)
{
String n = tmp[i];
int z = Integer.parseInt(n);
g[i]=z;
}
int count=0;
int i=0;
int m=0,n=0,l=0;
for(int y = 0; y < height; y++){
for(int x = 0; x < width; x++){
int c = (int)a[m];
m++;
int r;
if(count>=bin.length)
{
//r = (int)((Math.random()<0.5)?0:1);
r=0;
}
else
{
r = bin[i];
count++;
i=i+1;
}
int d = (int)b[n];
n++;
int e = (int)g[l];
l++;
int p = (c<<24) | (r<<16) | (d<<8) | e;
img.setRGB(x, y, p);
}
}
try{
f = new File("Files\\Output\\Output.png");
ImageIO.write(img, "png", f);
System.out.println("Sucessfully Created");
}catch(IOException e){
System.out.println("Error: " + e);
}
}
}