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
|
/**
* splashtool – A simple tool for creating SYSLINUX splashes without fuss
*
* Copyright © 2013, 2014 Mattias Andrée (maandree@member.fsf.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.image.*;
import javax.imageio.*;
/**
* Assemble the splash
*
* @author Mattias Andrée <a href="mailto:maandree@member.fsf.org">maandree@member.fsf.org</a>
*/
public class Assemble
{
public static void main(final String... args) throws IOException
{
Graphics g = splash.createGraphics();
g.drawImage(background, offx, offy, null);
g.drawImage(shadow, offx + 1, offy + 1, null);
g.drawImage(foreground, offx, offy, null);
g.dispose();
if (args[1].toLowerCase().startsWith("-w") || args[1].toLowerCase().startsWith("--w"))
splash = widescreen(splash);
ImageIO.write(splash, "png", new BufferedOutputStream(new FileOutputStream(new File(args[0]))));
}
private static BufferedImage widescreen(BufferedImage img)
{
BufferedImage rc = new BufferedImage(480 * 16 / 9, 480, BufferedImage.TYPE_INT_ARGB);
for (int y = 0; y < 480; y++)
for (int x = 0, e = 0; x < 640; x++)
{
rc.setRGB(x + e, y, img.getRGB(x, y));
if (x % 3 == 2)
if (x == 639)
rc.setRGB(x + ++e, y, img.getRGB(x, y));
else
{
int argb1 = img.getRGB(x, y);
int argb2 = img.getRGB(x + 1, y);
int a = (argb1 >>> 24) + (argb2 >>> 24);
int r = ((argb1 >> 16) & 255) + ((argb2 >> 16) & 255);
int g = ((argb1 >> 8) & 255) + ((argb2 >> 8) & 255);
int b = (argb1 & 255) + (argb2 & 255);
rc.setRGB(x + ++e, y, ((a >> 1) << 24) | ((r >> 1) << 16) | ((g >> 1) << 8) | (b >> 1));
}
}
return rc;
}
}
|