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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
/* */ package NET.worlds.scape;
/* */
/* */ import java.awt.Image;
/* */ import java.awt.Toolkit;
/* */ import java.awt.image.ColorModel;
/* */ import java.awt.image.DirectColorModel;
/* */ import java.awt.image.ImageConsumer;
/* */ import java.awt.image.ImageProducer;
/* */ import java.awt.image.IndexColorModel;
/* */ import java.io.PrintStream;
/* */ import java.util.Hashtable;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class ImageConverter
/* */ implements ImageConsumer
/* */ {
/* */ private String urlName;
/* */ private String filename;
/* */ private int width;
/* */ private int height;
/* */ private Image image;
/* */ private boolean done;
/* */ private boolean ok;
/* 29 */ private boolean debug = false;
/* */ private ColorModel model;
/* 31 */ private int transparentColor = -1;
/* */ private int hDIB;
/* */ private int pixelPtr;
/* */
/* */ public ImageConverter(String urlName, String filename)
/* */ {
/* 37 */ this.urlName = urlName;
/* 38 */ this.filename = filename;
/* */ }
/* */
/* */
/* */ static
/* */ {
/* 44 */ nativeInit();
/* */ }
/* */
/* */ public synchronized int convert()
/* */ {
/* 49 */ this.image = Toolkit.getDefaultToolkit().getImage(this.filename);
/* 50 */ this.image.getSource().startProduction(this);
/* */
/* 52 */ while (!this.done) {
/* */ try {
/* 54 */ wait();
/* */ }
/* */ catch (InterruptedException localInterruptedException) {}
/* */ }
/* 58 */ int textureID = 0;
/* 59 */ if (this.ok)
/* 60 */ textureID = convertDIBToTexture();
/* 61 */ cleanup();
/* 62 */ return textureID;
/* */ }
/* */
/* */ public void setDimensions(int width, int height)
/* */ {
/* 67 */ if (this.debug)
/* 68 */ System.out.println("Set dimensions: w " + width + " h " + height);
/* 69 */ this.width = width;
/* 70 */ this.height = height;
/* */ }
/* */
/* */ public void setProperties(Hashtable<?, ?> props)
/* */ {
/* 75 */ if (this.debug) {
/* 76 */ System.out.println("Set properties");
/* */ }
/* */ }
/* */
/* */ public void setColorModel(ColorModel model) {
/* 81 */ if (this.debug) {
/* 82 */ System.out.println("Set color model: " + model);
/* */ }
/* 84 */ this.model = model;
/* 85 */ assert ((this.width != 0) && (this.height != 0));
/* 86 */ int[] palette = null;
/* 87 */ int colors = 0;
/* 88 */ if ((model instanceof IndexColorModel)) {
/* 89 */ IndexColorModel im = (IndexColorModel)model;
/* 90 */ colors = im.getMapSize();
/* 91 */ this.transparentColor = im.getTransparentPixel();
/* 92 */ palette = new int[colors * 3];
/* 93 */ for (int i = 0; i < colors; i++)
/* 94 */ palette[i] = im.getRGB(i);
/* */ } else {
/* 96 */ DirectColorModel dm = (DirectColorModel)model;
/* */
/* */
/* */
/* */
/* */
/* 102 */ assert (dm.getBlueMask() == 255);
/* 103 */ assert (dm.getGreenMask() == 65280);
/* 104 */ assert (dm.getRedMask() == 16711680);
/* */ }
/* 106 */ prepareDIB(this.width, this.height, colors, palette);
/* */ }
/* */
/* */ public void setHints(int hintflags)
/* */ {
/* 111 */ if (this.debug) {
/* 112 */ System.out.println("Set hints: " + (
/* 113 */ (hintflags & 0x1) != 0 ? " RANDOM " : "") + (
/* 114 */ (hintflags & 0x2) != 0 ? " TOPDOWNLEFTRIGHT " : "") + (
/* 115 */ (hintflags & 0x4) != 0 ? " COMPLETESCANS " : "") + (
/* 116 */ (hintflags & 0x8) != 0 ? " SINGLEPASS " : "") + (
/* 117 */ (hintflags & 0x10) != 0 ? " SINGLEFRAME " : ""));
/* */ }
/* */ }
/* */
/* */ public void setPixels(int x, int y, int w, int h, ColorModel model, byte[] pixels, int off, int scansize)
/* */ {
/* 123 */ if (this.debug)
/* 124 */ System.out.println("setPixels(byte): x " + x + " y " + y + " w " +
/* 125 */ w + " h " + h + " model " + model + " off " +
/* 126 */ off + " scansize " + scansize);
/* 127 */ assert (model == this.model);
/* 128 */ setDIBPixelBytes(x, y, w, h, pixels, off, scansize);
/* */ }
/* */
/* */
/* */ public void setPixels(int x, int y, int w, int h, ColorModel model, int[] pixels, int off, int scansize)
/* */ {
/* 134 */ if (this.debug)
/* 135 */ System.out.println("setPixels(int): x " + x + " y " + y + " w " +
/* 136 */ w + " h " + h + " model " + model + " off " +
/* 137 */ off + " scansize " + scansize);
/* 138 */ assert (model == this.model);
/* 139 */ setDIBPixelInts(x, y, w, h, pixels, off, scansize);
/* */ }
/* */
/* */ public synchronized void imageComplete(int status)
/* */ {
/* 144 */ if (this.debug) {
/* 145 */ String state = null;
/* 146 */ switch (status) {
/* */ case 1:
/* 148 */ state = "ERROR";
/* 149 */ break;
/* */ case 2:
/* 151 */ state = "SINGLEDONE";
/* 152 */ break;
/* */ case 3:
/* 154 */ state = "STATICDONE";
/* 155 */ break;
/* */ case 4:
/* 157 */ state = "ABORTED";
/* */ }
/* */
/* 160 */ System.out.println("Image complete: " + state);
/* */ }
/* 162 */ this.image.getSource().removeConsumer(this);
/* 163 */ this.image.flush();
/* 164 */ this.ok = ((status != 1) && (status != 4));
/* 165 */ this.done = true;
/* 166 */ notify();
/* */ }
/* */
/* */ public static native void nativeInit();
/* */
/* */ private native void prepareDIB(int paramInt1, int paramInt2, int paramInt3, int[] paramArrayOfInt);
/* */
/* */ private native void setDIBPixelBytes(int paramInt1, int paramInt2, int paramInt3, int paramInt4, byte[] paramArrayOfByte, int paramInt5, int paramInt6);
/* */
/* */ private native void setDIBPixelInts(int paramInt1, int paramInt2, int paramInt3, int paramInt4, int[] paramArrayOfInt, int paramInt5, int paramInt6);
/* */
/* */ private native int convertDIBToTexture();
/* */
/* */ private native void cleanup();
/* */ }
/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\ImageConverter.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/
|