-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetImage.java
More file actions
95 lines (69 loc) · 2.42 KB
/
setImage.java
File metadata and controls
95 lines (69 loc) · 2.42 KB
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
/**
* Created by esmasert on 25.01.2018.
*/
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class setImage {
public testAES object;
public static List<String> CRA = new ArrayList<>();
public static List<String> CGA = new ArrayList<>();
public static List<String> CBA = new ArrayList<>();
public static List<Integer> RedInteger = new ArrayList<>();
public static List<Integer> GreenInteger = new ArrayList<>();
public static List<Integer> BlueInteger = new ArrayList<>();
public File a;
public setImage() {
object = new testAES();
CRA = object.getEncryptedWholeRed();
CGA = object.getEncryptedWholeGreen();
CBA = object.getEncryptedWholeBlue();
for (String k :CRA){
RedInteger.add(Integer.valueOf(k,16));
}
System.out.println(RedInteger);
for (String k :CGA){
GreenInteger.add(Integer.valueOf(k,16));
}
System.out.println(GreenInteger);
for (String k :CBA){
BlueInteger.add(Integer.valueOf(k,16));
}
System.out.println(BlueInteger);
//image dimension
int width = 245;
int height = 186;
//create buffered image object img
BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
//file object
File f = null;
//create random image pixel by pixel
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
int a = (int) (Math.random() * 256); //alpha
int r = (int) (RedInteger.get(y*width+x)); //red
int g = (int) (GreenInteger.get(y*width+x)); //green
int b = (int) (BlueInteger.get(y*width+x)); //blue
int p = (a << 24) | (r << 16) | (g << 8) | b; //pixel
img.setRGB(x, y, p);
}
}
//write image
try {
f = new File("/Users/esmasert/Desktop/OutputExample.png");
ImageIO.write(img, "png", f);
a=f;
} catch (IOException e) {
System.out.println("Error: " + e);
}
}
static public void main(String args[]) throws Exception {
setImage obj = new setImage();
}
public File getEncyptedPicture() {
return a;
}
}