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
|
package Game;
import java.awt.Transparency;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import Tools.ToolBox;
/*
* Copyright 2009 Volker Oth
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Wrapper class for additional images which don't fit anywhere else.
*
* @author Volker Oth
*/
public class MiscGfx {
/** Index of images */
public static enum Index {
/** border for the mini map */
BORDER,
/** Lemmin i logo */
LEMMINI,
/** green background tile */
TILE_GREEN,
/** brows background tile */
TILE_BROWN,
/** replay sign 1 */
REPLAY_1,
/** replay sign 2 */
REPLAY_2,
/** selection marker for replay */
SELECT
}
/** array of images */
private static BufferedImage image[];
/**
* Initialization.
* @throws ResourceException
*/
public static void init() throws ResourceException {
ArrayList<BufferedImage> images = new ArrayList<BufferedImage>();
BufferedImage img;
/* 0: BORDER */
img = ToolBox.ImageToBuffered(Core.loadImage("misc/border.gif"),Transparency.OPAQUE);
images.add(img);
/* 1: LEMMINI */
img = ToolBox.ImageToBuffered(Core.loadImageJar("lemmini.png"), Transparency.TRANSLUCENT);
images.add(img);
/* 2: TILE_GREEN */
img = ToolBox.ImageToBuffered(Core.loadImageJar("background.gif"), Transparency.OPAQUE);
images.add(img);
/* 3: TILE_BROWN */
//patch brown version of tile
BufferedImage brownImg = ToolBox.createImage(img.getWidth(), img.getHeight(),Transparency.BITMASK);
for (int xp=0; xp<img.getWidth(null); xp++)
for (int yp=0; yp<img.getHeight(null); yp++) {
int col = img.getRGB(xp, yp); // A R G B
int a = col & 0xff000000; // transparent part
int r = (col >> 16) & 0xff;
int g = (col >> 8) & 0xff;
int b = col & 0xff;
// patch image to brown version by manipulating red component
r = (r*2)&0xff;
b = b/2;
col = a | (g<<16) | (r<<8) | b;
brownImg.setRGB(xp, yp, col);
}
images.add(brownImg);
/* 4: REPLAY_1 */
BufferedImage anim[] = ToolBox.getAnimation(Core.loadImage("misc/replay.gif"),2,Transparency.BITMASK);
images.add(anim[0]);
/* 5: REPLAY_2 */
images.add(anim[1]);
/* 6: SELECT */
img = ToolBox.ImageToBuffered(Core.loadImage("misc/select.gif"),Transparency.BITMASK);
images.add(img);
image = new BufferedImage[images.size()];
image = images.toArray(image);
}
/**
* Get image.
* @param idx Index
* @return image of the given index
*/
public static BufferedImage getImage(Index idx) {
return image[idx.ordinal()];
}
}
|