-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.java
117 lines (69 loc) · 2.95 KB
/
Main.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
106
107
108
109
110
111
112
113
114
115
116
117
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.io.FileInputStream;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class Main {
BufferedImage image1;
BufferedImage image2;
public static void main(String[] args) {
System.out.println("AADLSLDA");
Main m = new Main();
}
public Main() {
JFrame window = new JFrame();
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
double windowWidth = 1920.0;
double windowHeight = 1200.0;
BufferedImage combinedImage;
try {
image1 = ImageIO.read(new FileInputStream("image1.png"));
double wid1 = image1.getWidth();
double hei1 = image1.getHeight();
image2 = ImageIO.read(new FileInputStream("image2.png"));
double wid2 = image2.getWidth();
double hei2 = image2.getHeight();
AffineTransform at = new AffineTransform();
AffineTransform at1 = new AffineTransform();
at1.scale(0.6, 0.6);
wid1=wid1*0.6; hei1=hei1*0.6;
double scaleIndex = 0.8;
// at.translate((wid1/2)-(wid2/2), 319-(hei2/2));
// at.rotate(Math.toRadians(180));
// at.translate( -((wid1/2)-(wid2/2)), -(319-(hei2/2)));
if (scaleIndex * hei2 >= hei1*0.795) {
System.out.println(
"You might make a scaleIndex lower, because currently your element oversteps the 954px limit!\n");
return;
} else {
System.out.println("Before scale: Wid2 is: " + wid2 + " hei2 is: " + hei2);
at.scale(scaleIndex, scaleIndex);
double wid2Scal = wid2 * scaleIndex;
double hei2Scal = hei2 * scaleIndex;
at.translate( ((wid1 / 2) - (wid2Scal / 2)) / scaleIndex, (hei1*0.795-hei2Scal)/4);
}
// 954, 319
// center of mass trapezoid is ~ 375px, 414px
// at.translate( (wid1/2)- (1.5*wid2/2), 490-(hei2/2));
// at.rotate(Math.toRadians(180));
System.out.println("Wid2 is: " + scaleIndex * wid2 + " hei2 is: " + scaleIndex * hei2);
combinedImage = new BufferedImage(1152, 720, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = combinedImage.createGraphics();
g.drawImage(image1, at1, null);
g.drawImage(image2, at, null);
g.dispose();
JLabel label = new JLabel();
window.add(label);
label.setIcon(new ImageIcon(combinedImage));
} catch (IOException e) {
System.out.println("Error!");
e.printStackTrace();
}
window.pack();
window.setVisible(true);
}
}