1 |
/******************************************************************************* |
= |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2000, 2005 IBM Corporation and others. |
|
2 |
* Copyright (c) 2000, 2005 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
|
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
|
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
|
5 |
* which accompanies this distribution, and is available at |
6 |
* http://www.eclipse.org/legal/epl-v10.html |
|
6 |
* http://www.eclipse.org/legal/epl-v10.html |
7 |
* |
|
7 |
* |
8 |
* Contributors: |
|
8 |
* Contributors: |
9 |
* IBM Corporation - initial API and implementation |
|
9 |
* IBM Corporation - initial API and implementation |
10 |
*******************************************************************************/ |
|
10 |
*******************************************************************************/ |
|
|
<> |
11 |
|
|
|
|
12 |
/******************************************************************************* |
|
|
|
13 |
* Additions/modifications to this source file by Oracle America, Inc. 2011 |
|
|
|
14 |
*******************************************************************************/ |
|
|
|
15 |
|
11 |
package org.eclipse.swt.graphics; |
= |
16 |
package org.eclipse.swt.graphics; |
12 |
|
|
17 |
|
13 |
|
|
18 |
|
14 |
import org.eclipse.swt.*; |
|
19 |
import org.eclipse.swt.*; |
15 |
import org.eclipse.swt.internal.Compatibility; |
|
20 |
import org.eclipse.swt.internal.Compatibility; |
16 |
|
|
21 |
|
17 |
import com.ibm.ugl.eswt.OS; |
|
22 |
import com.ibm.ugl.eswt.OS; |
18 |
|
|
23 |
|
19 |
import java.io.*; |
|
24 |
import java.io.*; |
20 |
|
|
25 |
|
21 |
/** |
|
26 |
/** |
22 |
* Instances of this class are graphics which have been prepared |
|
27 |
* Instances of this class are graphics which have been prepared |
23 |
* for display on a specific device. That is, they are ready |
|
28 |
* for display on a specific device. That is, they are ready |
24 |
* to paint using methods such as <code>GC.drawImage()</code> |
|
29 |
* to paint using methods such as <code>GC.drawImage()</code> |
25 |
* and display on widgets with, for example, <code>Button.setImage()</code>. |
|
30 |
* and display on widgets with, for example, <code>Button.setImage()</code>. |
26 |
* <p> |
|
31 |
* <p> |
27 |
* If loaded from a file format that supports it, an |
|
32 |
* If loaded from a file format that supports it, an |
28 |
* <code>Image</code> may have transparency, meaning that certain |
|
33 |
* <code>Image</code> may have transparency, meaning that certain |
29 |
* pixels are specified as being transparent when drawn. Examples |
|
34 |
* pixels are specified as being transparent when drawn. Examples |
30 |
* of file formats that support transparency are GIF and PNG. |
|
35 |
* of file formats that support transparency are GIF and PNG. |
31 |
* </p><p> |
|
36 |
* </p><p> |
32 |
* There are two primary ways to use <code>Images</code>. |
|
37 |
* There are two primary ways to use <code>Images</code>. |
33 |
* The first is to load a graphic file from disk and create an |
|
38 |
* The first is to load a graphic file from disk and create an |
34 |
* <code>Image</code> from it. This is done using an <code>Image</code> |
|
39 |
* <code>Image</code> from it. This is done using an <code>Image</code> |
35 |
* constructor, for example: |
|
40 |
* constructor, for example: |
36 |
* <pre> |
|
41 |
* <pre> |
37 |
* Image i = new Image(device, "C:\\graphic.png"); |
|
42 |
* Image i = new Image(device, "C:\\graphic.png"); |
38 |
* </pre> |
|
43 |
* </pre> |
39 |
* A graphic file may contain a color table specifying which |
|
44 |
* A graphic file may contain a color table specifying which |
40 |
* colors the image was intended to possess. In the above example, |
|
45 |
* colors the image was intended to possess. In the above example, |
41 |
* these colors will be mapped to the closest available color in |
|
46 |
* these colors will be mapped to the closest available color in |
42 |
* SWT. It is possible to get more control over the mapping of |
|
47 |
* SWT. It is possible to get more control over the mapping of |
43 |
* colors as the image is being created, using code of the form: |
|
48 |
* colors as the image is being created, using code of the form: |
44 |
* <pre> |
|
49 |
* <pre> |
45 |
* ImageData data = new ImageData("C:\\graphic.png"); |
|
50 |
* ImageData data = new ImageData("C:\\graphic.png"); |
46 |
* RGB[] rgbs = data.getRGBs(); |
|
51 |
* RGB[] rgbs = data.getRGBs(); |
47 |
* // At this point, rgbs contains specifications of all |
|
52 |
* // At this point, rgbs contains specifications of all |
48 |
* // the colors contained within this image. You may |
|
53 |
* // the colors contained within this image. You may |
49 |
* // allocate as many of these colors as you wish by |
|
54 |
* // allocate as many of these colors as you wish by |
50 |
* // using the Color constructor Color(RGB), then |
|
55 |
* // using the Color constructor Color(RGB), then |
51 |
* // create the image: |
|
56 |
* // create the image: |
52 |
* Image i = new Image(device, data); |
|
57 |
* Image i = new Image(device, data); |
53 |
* </pre> |
|
58 |
* </pre> |
54 |
* <p> |
|
59 |
* <p> |
55 |
* Application code must explicitely invoke the <code>Image.dispose()</code> |
|
60 |
* Application code must explicitely invoke the <code>Image.dispose()</code> |
56 |
* method to release the operating system resources managed by each instance |
|
61 |
* method to release the operating system resources managed by each instance |
57 |
* when those instances are no longer required. |
|
62 |
* when those instances are no longer required. |
58 |
* </p> |
|
63 |
* </p> |
59 |
* |
|
64 |
* |
60 |
* @see Color |
|
65 |
* @see Color |
61 |
* @see ImageData |
|
66 |
* @see ImageData |
62 |
*/ |
|
67 |
*/ |
63 |
public final class Image implements Drawable { |
|
68 |
public final class Image implements Drawable { |
64 |
/** |
|
69 |
/** |
65 |
* specifies whether the receiver is a bitmap or an icon |
|
70 |
* specifies whether the receiver is a bitmap or an icon |
66 |
* (one of <code>SWT.BITMAP</code>, <code>SWT.ICON</code>) |
|
71 |
* (one of <code>SWT.BITMAP</code>, <code>SWT.ICON</code>) |
67 |
*/ |
|
72 |
*/ |
68 |
public int type; |
|
73 |
public int type; |
69 |
|
|
74 |
|
70 |
/** |
|
75 |
/** |
71 |
* the OS resource of the image |
|
76 |
* the OS resource of the image |
72 |
* (Warning: This field is platform dependent) |
|
77 |
* (Warning: This field is platform dependent) |
73 |
*/ |
|
78 |
*/ |
74 |
public int internal_handle; |
|
79 |
public int internal_handle; |
75 |
|
|
80 |
|
76 |
/** |
|
81 |
/** |
77 |
* The device where this image was created. |
|
82 |
* The device where this image was created. |
78 |
*/ |
|
83 |
*/ |
79 |
Device device; |
|
84 |
Device device; |
80 |
|
|
85 |
|
81 |
/** |
|
86 |
/** |
82 |
* Specifies the default scanline padding. |
|
87 |
* Specifies the default scanline padding. |
83 |
* Warning: This field is platform dependent. |
|
88 |
* Warning: This field is platform dependent. |
84 |
*/ |
|
89 |
*/ |
85 |
static final int DEFAULT_SCANLINE_PAD = 4; |
|
90 |
static final int DEFAULT_SCANLINE_PAD = 4; |
86 |
|
|
91 |
|
87 |
/** |
|
92 |
/** |
88 |
* the GC which is drawing on the image |
|
93 |
* the GC which is drawing on the image |
89 |
*/ |
|
94 |
*/ |
90 |
GC memGC; |
|
95 |
GC memGC; |
91 |
|
|
96 |
|
|
|
<> |
97 |
/** |
|
|
|
98 |
* System icon for error. |
|
|
|
99 |
*/ |
|
|
|
100 |
public static final int ERROR = OS.IMAGE_ERROR; |
|
|
|
101 |
|
|
|
|
102 |
/** |
|
|
|
103 |
* System icon for information. |
|
|
|
104 |
*/ |
|
|
|
105 |
public static final int INFORMATION = OS.IMAGE_INFORMATION; |
|
|
|
106 |
|
|
|
|
107 |
/** |
|
|
|
108 |
* System icon for question. |
|
|
|
109 |
*/ |
|
|
|
110 |
public static final int QUESTION = OS.IMAGE_QUESTION; |
|
|
|
111 |
|
|
|
|
112 |
/** |
|
|
|
113 |
* System icon for warning. |
|
|
|
114 |
*/ |
|
|
|
115 |
public static final int WARNING = OS.IMAGE_WARNING; |
92 |
|
= |
116 |
|
93 |
/** |
|
117 |
/** |
94 |
* Creates an ImageData object from the specified image handle |
|
118 |
* Creates an ImageData object from the specified image handle |
95 |
* <p> |
|
119 |
* <p> |
96 |
* |
|
120 |
* |
97 |
* @param handle the platform specific Image handle |
|
121 |
* @param handle the platform specific Image handle |
98 |
* @return ImageData object for the specified image handle. |
|
122 |
* @return ImageData object for the specified image handle. |
99 |
*/ |
|
123 |
*/ |
100 |
static ImageData createImageDataFromNativeImage(int handle) { |
|
124 |
static ImageData createImageDataFromNativeImage(int handle) { |
101 |
ImageData imageData; |
|
125 |
ImageData imageData; |
102 |
int depth = OS.Image_GetDepth(handle); |
|
126 |
int depth = OS.Image_GetDepth(handle); |
103 |
boolean isDirect = OS.Image_IsDirect(handle); |
|
127 |
boolean isDirect = OS.Image_IsDirect(handle); |
104 |
PaletteData palette = null; |
|
128 |
PaletteData palette = null; |
105 |
int alphaMask = 0; |
|
129 |
int alphaMask = 0; |
106 |
int alphaShift = 0; |
|
130 |
int alphaShift = 0; |
107 |
|
|
131 |
|
108 |
if (isDirect) { |
|
132 |
if (isDirect) { |
109 |
int[] masks = OS.Image_GetDirectPaletteMasks(handle); |
|
133 |
int[] masks = OS.Image_GetDirectPaletteMasks(handle); |
110 |
palette = new PaletteData(masks[OS.PALETTE_MASK_RED], masks[OS.PALETTE_MASK_GREEN], masks[OS.PALETTE_MASK_BLUE]); |
|
134 |
palette = new PaletteData(masks[OS.PALETTE_MASK_RED], masks[OS.PALETTE_MASK_GREEN], masks[OS.PALETTE_MASK_BLUE]); |
111 |
alphaMask = masks[OS.PALETTE_MASK_ALPHA]; |
|
135 |
alphaMask = masks[OS.PALETTE_MASK_ALPHA]; |
112 |
alphaShift = countBits(alphaMask, 0); |
|
136 |
alphaShift = countBits(alphaMask, 0); |
113 |
} else { |
|
137 |
} else { |
114 |
int numColors = Compatibility.pow2(depth); // Avoid using Math.pow() because it is not in CLDC |
|
138 |
int numColors = Compatibility.pow2(depth); // Avoid using Math.pow() because it is not in CLDC |
115 |
byte[] red = new byte[numColors]; |
|
139 |
byte[] red = new byte[numColors]; |
116 |
byte[] green = new byte[numColors]; |
|
140 |
byte[] green = new byte[numColors]; |
117 |
byte[] blue = new byte[numColors]; |
|
141 |
byte[] blue = new byte[numColors]; |
118 |
OS.Image_GetIndexedPalette(handle, red, green, blue); |
|
142 |
OS.Image_GetIndexedPalette(handle, red, green, blue); |
119 |
|
|
143 |
|
120 |
RGB[] rgb = new RGB[numColors]; |
|
144 |
RGB[] rgb = new RGB[numColors]; |
121 |
for (int i = 0; i < numColors; i++) { |
|
145 |
for (int i = 0; i < numColors; i++) { |
122 |
rgb[i] = new RGB(red[i] & 0xFF, green[i] & 0xFF, blue[i] & 0xFF); |
|
146 |
rgb[i] = new RGB(red[i] & 0xFF, green[i] & 0xFF, blue[i] & 0xFF); |
123 |
} |
|
147 |
} |
124 |
palette = new PaletteData(rgb); |
|
148 |
palette = new PaletteData(rgb); |
125 |
} |
|
149 |
} |
126 |
int[] bounds = OS.Image_GetBounds(handle); |
|
150 |
int[] bounds = OS.Image_GetBounds(handle); |
127 |
int width = bounds[OS.INDEX_WIDTH]; |
|
151 |
int width = bounds[OS.INDEX_WIDTH]; |
128 |
int height = bounds[OS.INDEX_HEIGHT]; |
|
152 |
int height = bounds[OS.INDEX_HEIGHT]; |
129 |
|
|
153 |
|
130 |
if (depth > 8) { |
|
154 |
if (depth > 8) { |
131 |
int[] pixels = OS.Image_GetPixelsHighColor(handle); |
|
155 |
int[] pixels = OS.Image_GetPixelsHighColor(handle); |
132 |
int pixelIndex = 0; |
|
156 |
int pixelIndex = 0; |
133 |
|
|
157 |
|
134 |
imageData = new ImageData(width, height, depth, palette); |
|
158 |
imageData = new ImageData(width, height, depth, palette); |
135 |
if (alphaMask != 0) { |
|
159 |
if (alphaMask != 0) { |
136 |
for (int y = 0; y < height; y++) { |
|
160 |
for (int y = 0; y < height; y++) { |
137 |
for (int x = 0; x < width; x++, pixelIndex++) { |
|
161 |
for (int x = 0; x < width; x++, pixelIndex++) { |
138 |
int alpha = getPixelRGBComponent(pixels[pixelIndex], alphaMask, alphaShift); |
|
162 |
int alpha = getPixelRGBComponent(pixels[pixelIndex], alphaMask, alphaShift); |
139 |
imageData.setAlpha(x, y, alpha); |
|
163 |
imageData.setAlpha(x, y, alpha); |
140 |
imageData.setPixel(x, y, pixels[pixelIndex]); |
|
164 |
imageData.setPixel(x, y, pixels[pixelIndex]); |
141 |
} |
|
165 |
} |
142 |
} |
|
166 |
} |
143 |
} else { |
|
167 |
} else { |
144 |
imageData.setPixels(0, 0, pixels.length, pixels, 0); |
|
168 |
imageData.setPixels(0, 0, pixels.length, pixels, 0); |
145 |
} |
|
169 |
} |
146 |
} else { |
|
170 |
} else { |
147 |
byte[] pixels = OS.Image_GetPixelsLowColor(handle); |
|
171 |
byte[] pixels = OS.Image_GetPixelsLowColor(handle); |
148 |
int bytesPerLine = pixels.length / height; |
|
172 |
int bytesPerLine = pixels.length / height; |
149 |
int usedBytesPerLine = Compatibility.ceil(width * depth, 8); |
|
173 |
int usedBytesPerLine = Compatibility.ceil(width * depth, 8); |
150 |
int scanlinePad = bytesPerLine - usedBytesPerLine + 1; |
|
174 |
int scanlinePad = bytesPerLine - usedBytesPerLine + 1; |
151 |
|
|
175 |
|
152 |
while (bytesPerLine % scanlinePad > 0) { |
|
176 |
while (bytesPerLine % scanlinePad > 0) { |
153 |
scanlinePad++; |
|
177 |
scanlinePad++; |
154 |
} |
|
178 |
} |
155 |
imageData = new ImageData(width, height, depth, palette, scanlinePad, pixels); |
|
179 |
imageData = new ImageData(width, height, depth, palette, scanlinePad, pixels); |
156 |
} |
|
180 |
} |
157 |
imageData.transparentPixel = OS.Image_GetTransparentColor(handle); |
|
181 |
imageData.transparentPixel = OS.Image_GetTransparentColor(handle); |
158 |
|
|
182 |
|
159 |
return imageData; |
|
183 |
return imageData; |
160 |
} |
|
184 |
} |
161 |
|
|
185 |
|
162 |
static int getPixelRGBComponent(int pixel, int mask, int shift) { |
|
186 |
static int getPixelRGBComponent(int pixel, int mask, int shift) { |
163 |
return ((pixel & mask) >>> shift); |
|
187 |
return ((pixel & mask) >>> shift); |
164 |
} |
|
188 |
} |
165 |
static int imageFormat(String fileName) { |
|
189 |
static int imageFormat(String fileName) { |
166 |
InputStream stream = null; |
|
190 |
InputStream stream = null; |
167 |
try { |
|
191 |
try { |
168 |
stream = Compatibility.newFileInputStream(fileName); |
|
192 |
stream = Compatibility.newFileInputStream(fileName); |
169 |
byte[] buffer = new byte[32]; |
|
193 |
byte[] buffer = new byte[32]; |
170 |
stream.read(buffer, 0, buffer.length); |
|
194 |
stream.read(buffer, 0, buffer.length); |
171 |
stream.close(); |
|
195 |
stream.close(); |
172 |
return Image.imageFormat(buffer); |
|
196 |
return Image.imageFormat(buffer); |
173 |
} catch (IOException e) { |
|
197 |
} catch (IOException e) { |
174 |
SWT.error(SWT.ERROR_IO, e); |
|
198 |
SWT.error(SWT.ERROR_IO, e); |
175 |
} finally { |
|
199 |
} finally { |
176 |
try { |
|
200 |
try { |
177 |
if (stream != null) stream.close(); |
|
201 |
if (stream != null) stream.close(); |
178 |
} catch (IOException e) { |
|
202 |
} catch (IOException e) { |
179 |
// Ignore error |
|
203 |
// Ignore error |
180 |
} |
|
204 |
} |
181 |
} |
|
205 |
} |
182 |
return SWT.IMAGE_UNDEFINED; |
|
206 |
return SWT.IMAGE_UNDEFINED; |
183 |
} |
|
207 |
} |
184 |
static int imageFormat(byte[] streamBytes) { |
|
208 |
static int imageFormat(byte[] streamBytes) { |
185 |
if (isPNGFormat(streamBytes)) return SWT.IMAGE_PNG; |
|
209 |
if (isPNGFormat(streamBytes)) return SWT.IMAGE_PNG; |
186 |
if (isGIFFormat(streamBytes)) return SWT.IMAGE_GIF; |
|
210 |
if (isGIFFormat(streamBytes)) return SWT.IMAGE_GIF; |
187 |
if (isJPEGFormat(streamBytes)) return SWT.IMAGE_JPEG; |
|
211 |
if (isJPEGFormat(streamBytes)) return SWT.IMAGE_JPEG; |
188 |
return SWT.IMAGE_UNDEFINED; |
|
212 |
return SWT.IMAGE_UNDEFINED; |
189 |
} |
|
213 |
} |
190 |
static boolean isPNGFormat(byte[] streamBytes) { |
|
214 |
static boolean isPNGFormat(byte[] streamBytes) { |
191 |
if (streamBytes.length < 8) return false; |
|
215 |
if (streamBytes.length < 8) return false; |
192 |
if ((streamBytes[0] & 0xFF) != 137) return false; //137 |
|
216 |
if ((streamBytes[0] & 0xFF) != 137) return false; //137 |
193 |
if ((streamBytes[1] & 0xFF) != 80) return false; //P |
|
217 |
if ((streamBytes[1] & 0xFF) != 80) return false; //P |
194 |
if ((streamBytes[2] & 0xFF) != 78) return false; //N |
|
218 |
if ((streamBytes[2] & 0xFF) != 78) return false; //N |
195 |
if ((streamBytes[3] & 0xFF) != 71) return false; //G |
|
219 |
if ((streamBytes[3] & 0xFF) != 71) return false; //G |
196 |
if ((streamBytes[4] & 0xFF) != 13) return false; //<RETURN> |
|
220 |
if ((streamBytes[4] & 0xFF) != 13) return false; //<RETURN> |
197 |
if ((streamBytes[5] & 0xFF) != 10) return false; //<LINEFEED> |
|
221 |
if ((streamBytes[5] & 0xFF) != 10) return false; //<LINEFEED> |
198 |
if ((streamBytes[6] & 0xFF) != 26) return false; //<CTRL/Z> |
|
222 |
if ((streamBytes[6] & 0xFF) != 26) return false; //<CTRL/Z> |
199 |
if ((streamBytes[7] & 0xFF) != 10) return false; //<LINEFEED> |
|
223 |
if ((streamBytes[7] & 0xFF) != 10) return false; //<LINEFEED> |
200 |
return true; |
|
224 |
return true; |
201 |
} |
|
225 |
} |
202 |
static boolean isGIFFormat(byte[] streamBytes) { |
|
226 |
static boolean isGIFFormat(byte[] streamBytes) { |
203 |
if (streamBytes.length < 3) return false; |
|
227 |
if (streamBytes.length < 3) return false; |
204 |
if (streamBytes[0] != 'G') return false; |
|
228 |
if (streamBytes[0] != 'G') return false; |
205 |
if (streamBytes[1] != 'I') return false; |
|
229 |
if (streamBytes[1] != 'I') return false; |
206 |
if (streamBytes[2] != 'F') return false; |
|
230 |
if (streamBytes[2] != 'F') return false; |
207 |
return true; |
|
231 |
return true; |
208 |
} |
|
232 |
} |
209 |
static boolean isJPEGFormat(byte[] streamBytes) { |
|
233 |
static boolean isJPEGFormat(byte[] streamBytes) { |
210 |
if (streamBytes.length < 2) return false; |
|
234 |
if (streamBytes.length < 2) return false; |
211 |
if ((streamBytes[0] & 0xFF) != 0xFF) return false; |
|
235 |
if ((streamBytes[0] & 0xFF) != 0xFF) return false; |
212 |
if ((streamBytes[1] & 0xFF) != 0xD8) return false; |
|
236 |
if ((streamBytes[1] & 0xFF) != 0xD8) return false; |
213 |
return true; |
|
237 |
return true; |
214 |
} |
|
238 |
} |
215 |
/** |
|
239 |
/** |
216 |
* Reads the specified stream and returns the contents as a byte |
|
240 |
* Reads the specified stream and returns the contents as a byte |
217 |
* array. |
|
241 |
* array. |
218 |
* |
|
242 |
* |
219 |
* @param stream the raw image data stream |
|
243 |
* @param stream the raw image data stream |
220 |
* @return image data buffer |
|
244 |
* @return image data buffer |
221 |
*/ |
|
245 |
*/ |
222 |
static byte[] readImageStream(InputStream stream) { |
|
246 |
static byte[] readImageStream(InputStream stream) { |
223 |
byte[] buffer = new byte[512]; |
|
247 |
byte[] buffer = new byte[512]; |
224 |
ByteArrayOutputStream baoStream = new ByteArrayOutputStream(); |
|
248 |
ByteArrayOutputStream baoStream = new ByteArrayOutputStream(); |
225 |
|
|
249 |
|
226 |
try { |
|
250 |
try { |
227 |
boolean done = false; |
|
251 |
boolean done = false; |
228 |
while (!done) { |
|
252 |
while (!done) { |
229 |
int length = stream.read(buffer); |
|
253 |
int length = stream.read(buffer); |
230 |
if (-1 == length) { |
|
254 |
if (-1 == length) { |
231 |
done = true; |
|
255 |
done = true; |
232 |
} |
|
256 |
} |
233 |
else { |
|
257 |
else { |
234 |
baoStream.write(buffer,0,length); |
|
258 |
baoStream.write(buffer,0,length); |
235 |
} |
|
259 |
} |
236 |
} |
|
260 |
} |
237 |
} |
|
261 |
} |
238 |
catch (IOException e) { |
|
262 |
catch (IOException e) { |
239 |
SWT.error(SWT.ERROR_IO, e); |
|
263 |
SWT.error(SWT.ERROR_IO, e); |
240 |
} |
|
264 |
} |
241 |
finally { |
|
265 |
finally { |
242 |
try { |
|
266 |
try { |
243 |
baoStream.close(); |
|
267 |
baoStream.close(); |
244 |
} catch (IOException e) { |
|
268 |
} catch (IOException e) { |
245 |
// ignore for the close |
|
269 |
// ignore for the close |
246 |
} |
|
270 |
} |
247 |
} |
|
271 |
} |
248 |
|
|
272 |
|
249 |
return baoStream.toByteArray(); |
|
273 |
return baoStream.toByteArray(); |
250 |
} |
|
274 |
} |
251 |
static int countBits(int mask, int bit) { |
|
275 |
static int countBits(int mask, int bit) { |
252 |
int count = 0; |
|
276 |
int count = 0; |
253 |
|
|
277 |
|
254 |
if (mask == 0) { |
|
278 |
if (mask == 0) { |
255 |
return 0; |
|
279 |
return 0; |
256 |
} |
|
280 |
} |
257 |
while (((mask >> count) & 0x1) == bit) { |
|
281 |
while (((mask >> count) & 0x1) == bit) { |
258 |
count++; |
|
282 |
count++; |
259 |
} |
|
283 |
} |
260 |
return count; |
|
284 |
return count; |
261 |
} |
|
285 |
} |
262 |
|
|
286 |
|
263 |
Image() { |
|
287 |
Image() { |
264 |
} |
|
288 |
} |
265 |
/** |
|
289 |
/** |
266 |
* Constructs an instance of this class from the given |
|
290 |
* Constructs an instance of this class from the given |
267 |
* <code>ImageData</code>. |
|
291 |
* <code>ImageData</code>. |
268 |
* |
|
292 |
* |
269 |
* @param device the device on which to create the image |
|
293 |
* @param device the device on which to create the image |
270 |
* @param data the image data to create the image from (must not be null) |
|
294 |
* @param data the image data to create the image from (must not be null) |
271 |
* |
|
295 |
* |
272 |
* @exception IllegalArgumentException <ul> |
|
296 |
* @exception IllegalArgumentException <ul> |
273 |
* <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li> |
|
297 |
* <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li> |
274 |
* <li>ERROR_NULL_ARGUMENT - if the image data is null</li> |
|
298 |
* <li>ERROR_NULL_ARGUMENT - if the image data is null</li> |
275 |
* </ul> |
|
299 |
* </ul> |
276 |
* @exception SWTException <ul> |
|
300 |
* @exception SWTException <ul> |
277 |
* <li>ERROR_UNSUPPORTED_DEPTH - if the depth of the ImageData is not supported</li> |
|
301 |
* <li>ERROR_UNSUPPORTED_DEPTH - if the depth of the ImageData is not supported</li> |
278 |
* </ul> |
|
302 |
* </ul> |
279 |
* @exception SWTError <ul> |
|
303 |
* @exception SWTError <ul> |
280 |
* <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li> |
|
304 |
* <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li> |
281 |
* </ul> |
|
305 |
* </ul> |
282 |
*/ |
|
306 |
*/ |
283 |
public Image(Device device, ImageData data) { |
|
307 |
public Image(Device device, ImageData data) { |
284 |
init(device, data); |
|
308 |
init(device, data); |
285 |
} |
|
309 |
} |
286 |
/** |
|
310 |
/** |
287 |
* Constructs an instance of this class by loading its representation |
|
311 |
* Constructs an instance of this class by loading its representation |
288 |
* from the specified input stream. Throws an error if an error |
|
312 |
* from the specified input stream. Throws an error if an error |
289 |
* occurs while loading the image, or if the result is an image |
|
313 |
* occurs while loading the image, or if the result is an image |
290 |
* of an unsupported type. Application code is still responsible |
|
314 |
* of an unsupported type. Application code is still responsible |
291 |
* for closing the input stream. |
|
315 |
* for closing the input stream. |
292 |
* <p> |
|
316 |
* <p> |
293 |
* This constructor may be used to load a resource as follows: |
|
317 |
* This constructor may be used to load a resource as follows: |
294 |
* </p> |
|
318 |
* </p> |
295 |
* <pre> |
|
319 |
* <pre> |
296 |
* new Image(device, clazz.getResourceAsStream("file.png")); |
|
320 |
* new Image(device, clazz.getResourceAsStream("file.png")); |
297 |
* </pre> |
|
321 |
* </pre> |
298 |
* |
|
322 |
* |
299 |
* @param device the device on which to create the image |
|
323 |
* @param device the device on which to create the image |
300 |
* @param stream the input stream to load the image from |
|
324 |
* @param stream the input stream to load the image from |
301 |
* |
|
325 |
* |
302 |
* @exception IllegalArgumentException <ul> |
|
326 |
* @exception IllegalArgumentException <ul> |
303 |
* <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li> |
|
327 |
* <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li> |
304 |
* <li>ERROR_NULL_ARGUMENT - if the stream is null</li> |
|
328 |
* <li>ERROR_NULL_ARGUMENT - if the stream is null</li> |
305 |
* </ul> |
|
329 |
* </ul> |
306 |
* @exception SWTException <ul> |
|
330 |
* @exception SWTException <ul> |
307 |
* <li>ERROR_INVALID_IMAGE - if the image file contains invalid data </li> |
|
331 |
* <li>ERROR_INVALID_IMAGE - if the image file contains invalid data </li> |
308 |
* <li>ERROR_IO - if an IO error occurs while reading data</li> |
|
332 |
* <li>ERROR_IO - if an IO error occurs while reading data</li> |
309 |
* <li>ERROR_UNSUPPORTED_DEPTH - if the InputStream describes an image with an unsupported depth</li> |
|
333 |
* <li>ERROR_UNSUPPORTED_DEPTH - if the InputStream describes an image with an unsupported depth</li> |
310 |
* <li>ERROR_UNSUPPORTED_FORMAT - if the image file contains an unrecognized format</li> |
|
334 |
* <li>ERROR_UNSUPPORTED_FORMAT - if the image file contains an unrecognized format</li> |
311 |
* * </ul> |
|
335 |
* * </ul> |
312 |
* </ul> |
|
336 |
* </ul> |
313 |
* @exception SWTError <ul> |
|
337 |
* @exception SWTError <ul> |
314 |
* <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li> |
|
338 |
* <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li> |
315 |
* </ul> |
|
339 |
* </ul> |
316 |
*/ |
|
340 |
*/ |
317 |
public Image(Device device, InputStream stream) { |
|
341 |
public Image(Device device, InputStream stream) { |
318 |
init(device, stream); |
|
342 |
init(device, stream); |
319 |
// testing purposes only |
|
343 |
// testing purposes only |
320 |
// init(device, new ImageData(stream)); |
|
344 |
// init(device, new ImageData(stream)); |
321 |
} |
|
345 |
} |
322 |
/** |
|
346 |
/** |
323 |
* Constructs an empty instance of this class with the |
|
347 |
* Constructs an empty instance of this class with the |
324 |
* specified width and height. The result may be drawn upon |
|
348 |
* specified width and height. The result may be drawn upon |
325 |
* by creating a GC and using any of its drawing operations, |
|
349 |
* by creating a GC and using any of its drawing operations, |
326 |
* as shown in the following example: |
|
350 |
* as shown in the following example: |
327 |
* <pre> |
|
351 |
* <pre> |
328 |
* Image i = new Image(device, width, height); |
|
352 |
* Image i = new Image(device, width, height); |
329 |
* GC gc = new GC(i); |
|
353 |
* GC gc = new GC(i); |
330 |
* gc.drawRectangle(0, 0, 50, 50); |
|
354 |
* gc.drawRectangle(0, 0, 50, 50); |
331 |
* gc.dispose(); |
|
355 |
* gc.dispose(); |
332 |
* </pre> |
|
356 |
* </pre> |
333 |
* <p> |
|
357 |
* <p> |
334 |
* Note: Some platforms may have a limitation on the size |
|
358 |
* Note: Some platforms may have a limitation on the size |
335 |
* of image that can be created (size depends on width, height, |
|
359 |
* of image that can be created (size depends on width, height, |
336 |
* and depth). For example, Windows 95, 98, and ME do not allow |
|
360 |
* and depth). For example, Windows 95, 98, and ME do not allow |
337 |
* images larger than 16M. |
|
361 |
* images larger than 16M. |
338 |
* </p> |
|
362 |
* </p> |
339 |
* |
|
363 |
* |
340 |
* @param device the device on which to create the image |
|
364 |
* @param device the device on which to create the image |
341 |
* @param width the width of the new image |
|
365 |
* @param width the width of the new image |
342 |
* @param height the height of the new image |
|
366 |
* @param height the height of the new image |
343 |
* |
|
367 |
* |
344 |
* @exception IllegalArgumentException <ul> |
|
368 |
* @exception IllegalArgumentException <ul> |
345 |
* <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li> |
|
369 |
* <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li> |
346 |
* <li>ERROR_INVALID_ARGUMENT - if either the width or height is negative or zero</li> |
|
370 |
* <li>ERROR_INVALID_ARGUMENT - if either the width or height is negative or zero</li> |
347 |
* </ul> |
|
371 |
* </ul> |
348 |
* @exception SWTError <ul> |
|
372 |
* @exception SWTError <ul> |
349 |
* <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li> |
|
373 |
* <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li> |
350 |
* </ul> |
|
374 |
* </ul> |
351 |
*/ |
|
375 |
*/ |
352 |
public Image(Device device, int width, int height) { |
|
376 |
public Image(Device device, int width, int height) { |
353 |
init(device, width, height); |
|
377 |
init(device, width, height); |
354 |
} |
|
378 |
} |
355 |
/** |
|
379 |
/** |
356 |
* Constructs an empty instance of this class with the |
|
380 |
* Constructs an empty instance of this class with the |
357 |
* width and height of the specified rectangle. The result |
|
381 |
* width and height of the specified rectangle. The result |
358 |
* may be drawn upon by creating a GC and using any of its |
|
382 |
* may be drawn upon by creating a GC and using any of its |
359 |
* drawing operations, as shown in the following example: |
|
383 |
* drawing operations, as shown in the following example: |
360 |
* <pre> |
|
384 |
* <pre> |
361 |
* Image i = new Image(device, boundsRectangle); |
|
385 |
* Image i = new Image(device, boundsRectangle); |
362 |
* GC gc = new GC(i); |
|
386 |
* GC gc = new GC(i); |
363 |
* gc.drawRectangle(0, 0, 50, 50); |
|
387 |
* gc.drawRectangle(0, 0, 50, 50); |
364 |
* gc.dispose(); |
|
388 |
* gc.dispose(); |
365 |
* </pre> |
|
389 |
* </pre> |
366 |
* <p> |
|
390 |
* <p> |
367 |
* Note: Some platforms may have a limitation on the size |
|
391 |
* Note: Some platforms may have a limitation on the size |
368 |
* of image that can be created (size depends on width, height, |
|
392 |
* of image that can be created (size depends on width, height, |
369 |
* and depth). For example, Windows 95, 98, and ME do not allow |
|
393 |
* and depth). For example, Windows 95, 98, and ME do not allow |
370 |
* images larger than 16M. |
|
394 |
* images larger than 16M. |
371 |
* </p> |
|
395 |
* </p> |
372 |
* |
|
396 |
* |
373 |
* @param device the device on which to create the image |
|
397 |
* @param device the device on which to create the image |
374 |
* @param bounds a rectangle specifying the image's width and height (must not be null) |
|
398 |
* @param bounds a rectangle specifying the image's width and height (must not be null) |
375 |
* |
|
399 |
* |
376 |
* @exception IllegalArgumentException <ul> |
|
400 |
* @exception IllegalArgumentException <ul> |
377 |
* <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li> |
|
401 |
* <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li> |
378 |
* <li>ERROR_NULL_ARGUMENT - if the bounds rectangle is null</li> |
|
402 |
* <li>ERROR_NULL_ARGUMENT - if the bounds rectangle is null</li> |
379 |
* <li>ERROR_INVALID_ARGUMENT - if either the rectangle's width or height is negative</li> |
|
403 |
* <li>ERROR_INVALID_ARGUMENT - if either the rectangle's width or height is negative</li> |
380 |
* </ul> |
|
404 |
* </ul> |
381 |
* @exception SWTError <ul> |
|
405 |
* @exception SWTError <ul> |
382 |
* <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li> |
|
406 |
* <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li> |
383 |
* </ul> |
|
407 |
* </ul> |
384 |
*/ |
|
408 |
*/ |
385 |
public Image(Device device, Rectangle bounds) { |
|
409 |
public Image(Device device, Rectangle bounds) { |
386 |
if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); |
|
410 |
if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); |
387 |
init(device, bounds.width, bounds.height); |
|
411 |
init(device, bounds.width, bounds.height); |
388 |
} |
|
412 |
} |
389 |
/** |
|
413 |
/** |
390 |
* Constructs an instance of this class by loading its representation |
|
414 |
* Constructs an instance of this class by loading its representation |
391 |
* from the file with the specified name. Throws an error if an error |
|
415 |
* from the file with the specified name. Throws an error if an error |
392 |
* occurs while loading the image, or if the result is an image |
|
416 |
* occurs while loading the image, or if the result is an image |
393 |
* of an unsupported type. Application code is still responsible |
|
417 |
* of an unsupported type. Application code is still responsible |
394 |
* for closing the input stream. |
|
418 |
* for closing the input stream. |
395 |
* <p> |
|
419 |
* <p> |
396 |
* This constructor is provided for convenience when loading |
|
420 |
* This constructor is provided for convenience when loading |
397 |
* a single image only. If the specified file contains |
|
421 |
* a single image only. If the specified file contains |
398 |
* multiple images, only the first one will be used. |
|
422 |
* multiple images, only the first one will be used. |
399 |
* |
|
423 |
* |
400 |
* @param device the device on which to create the image |
|
424 |
* @param device the device on which to create the image |
401 |
* @param filename the name of the file to load the image from |
|
425 |
* @param filename the name of the file to load the image from |
402 |
* |
|
426 |
* |
403 |
* @exception IllegalArgumentException <ul> |
|
427 |
* @exception IllegalArgumentException <ul> |
404 |
* <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li> |
|
428 |
* <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li> |
405 |
* <li>ERROR_NULL_ARGUMENT - if the file name is null</li> |
|
429 |
* <li>ERROR_NULL_ARGUMENT - if the file name is null</li> |
406 |
* </ul> |
|
430 |
* </ul> |
407 |
* @exception SWTException <ul> |
|
431 |
* @exception SWTException <ul> |
408 |
* <li>ERROR_INVALID_IMAGE - if the image file contains invalid data </li> |
|
432 |
* <li>ERROR_INVALID_IMAGE - if the image file contains invalid data </li> |
409 |
* <li>ERROR_IO - if an IO error occurs while reading data</li> |
|
433 |
* <li>ERROR_IO - if an IO error occurs while reading data</li> |
410 |
* <li>ERROR_UNSUPPORTED_DEPTH - if the image file has an unsupported depth</li> |
|
434 |
* <li>ERROR_UNSUPPORTED_DEPTH - if the image file has an unsupported depth</li> |
411 |
* <li>ERROR_UNSUPPORTED_FORMAT - if the image file contains an unrecognized format</li> |
|
435 |
* <li>ERROR_UNSUPPORTED_FORMAT - if the image file contains an unrecognized format</li> |
412 |
* </ul> |
|
436 |
* </ul> |
413 |
* @exception SWTError <ul> |
|
437 |
* @exception SWTError <ul> |
414 |
* <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li> |
|
438 |
* <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li> |
415 |
* </ul> |
|
439 |
* </ul> |
416 |
*/ |
|
440 |
*/ |
417 |
public Image(Device device, String filename) { |
|
441 |
public Image(Device device, String filename) { |
418 |
init(device, filename); |
|
442 |
init(device, filename); |
419 |
// testing purposes only |
|
443 |
// testing purposes only |
420 |
// init(device, new ImageData(filename)); |
|
444 |
// init(device, new ImageData(filename)); |
421 |
} |
|
445 |
} |
422 |
/** |
|
446 |
/** |
|
|
<> |
447 |
* Constructs an instance of this class based on a system resource. |
|
|
|
448 |
* @param device the device on which to create the image |
|
|
|
449 |
* @param type SWT.ICON or SWT.BITMAP |
|
|
|
450 |
* @param identifier the resource identifier |
|
|
|
451 |
*/ |
|
|
|
452 |
public Image(Device device, int identifier) { |
|
|
|
453 |
init(device, identifier); |
|
|
|
454 |
} |
|
|
|
455 |
/** |
423 |
* Disposes of the operating system resources associated with |
= |
456 |
* Disposes of the operating system resources associated with |
424 |
* the image. Applications must dispose of all images which |
|
457 |
* the image. Applications must dispose of all images which |
425 |
* they allocate. |
|
458 |
* they allocate. |
426 |
*/ |
|
459 |
*/ |
427 |
public void dispose() { |
|
460 |
public void dispose() { |
428 |
if (internal_handle == 0) return; |
|
461 |
if (internal_handle == 0) return; |
429 |
|
|
462 |
|
430 |
if (memGC != null) { |
|
463 |
if (memGC != null) { |
431 |
memGC.dispose(); |
|
464 |
memGC.dispose(); |
432 |
memGC = null; |
|
465 |
memGC = null; |
433 |
} |
|
466 |
} |
434 |
OS.Image_Dispose(internal_handle); |
|
467 |
OS.Image_Dispose(internal_handle); |
435 |
internal_handle = 0; |
|
468 |
internal_handle = 0; |
436 |
device = null; |
|
469 |
device = null; |
437 |
} |
|
470 |
} |
438 |
/** |
|
471 |
/** |
439 |
* Compares the argument to the receiver, and returns true |
|
472 |
* Compares the argument to the receiver, and returns true |
440 |
* if they represent the <em>same</em> object using a class |
|
473 |
* if they represent the <em>same</em> object using a class |
441 |
* specific comparison. |
|
474 |
* specific comparison. |
442 |
* |
|
475 |
* |
443 |
* @param object the object to compare with this object |
|
476 |
* @param object the object to compare with this object |
444 |
* @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise |
|
477 |
* @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise |
445 |
* |
|
478 |
* |
446 |
* @see #hashCode |
|
479 |
* @see #hashCode |
447 |
*/ |
|
480 |
*/ |
448 |
public boolean equals(Object object) { |
|
481 |
public boolean equals(Object object) { |
449 |
if (object == this) return true; |
|
482 |
if (object == this) return true; |
450 |
if (!(object instanceof Image)) return false; |
|
483 |
if (!(object instanceof Image)) return false; |
451 |
Image image = (Image) object; |
|
484 |
Image image = (Image) object; |
452 |
return device == image.device && internal_handle == image.internal_handle; |
|
485 |
return device == image.device && internal_handle == image.internal_handle; |
453 |
} |
|
486 |
} |
454 |
/** |
|
487 |
/** |
455 |
* Returns the bounds of the receiver. The rectangle will always |
|
488 |
* Returns the bounds of the receiver. The rectangle will always |
456 |
* have x and y values of 0, and the width and height of the |
|
489 |
* have x and y values of 0, and the width and height of the |
457 |
* image. |
|
490 |
* image. |
458 |
* |
|
491 |
* |
459 |
* @return a rectangle specifying the image's bounds |
|
492 |
* @return a rectangle specifying the image's bounds |
460 |
* |
|
493 |
* |
461 |
* @exception SWTException <ul> |
|
494 |
* @exception SWTException <ul> |
462 |
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
|
495 |
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
463 |
* <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon</li> |
|
496 |
* <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon</li> |
464 |
* </ul> |
|
497 |
* </ul> |
465 |
*/ |
|
498 |
*/ |
466 |
public Rectangle getBounds() { |
|
499 |
public Rectangle getBounds() { |
467 |
if (internal_handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
|
500 |
if (internal_handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
468 |
if (type != SWT.BITMAP) SWT.error(SWT.ERROR_INVALID_IMAGE); |
|
501 |
if (type != SWT.BITMAP) SWT.error(SWT.ERROR_INVALID_IMAGE); |
469 |
int[] rect = OS.Image_GetBounds(internal_handle); |
|
502 |
int[] rect = OS.Image_GetBounds(internal_handle); |
470 |
|
|
503 |
|
471 |
return new Rectangle(rect[OS.INDEX_X], rect[OS.INDEX_Y], rect[OS.INDEX_WIDTH], rect[OS.INDEX_HEIGHT]); |
|
504 |
return new Rectangle(rect[OS.INDEX_X], rect[OS.INDEX_Y], rect[OS.INDEX_WIDTH], rect[OS.INDEX_HEIGHT]); |
472 |
} |
|
505 |
} |
473 |
/** |
|
506 |
/** |
474 |
* Returns an <code>ImageData</code> based on the receiver |
|
507 |
* Returns an <code>ImageData</code> based on the receiver |
475 |
* Modifications made to this <code>ImageData</code> will not |
|
508 |
* Modifications made to this <code>ImageData</code> will not |
476 |
* affect the Image. |
|
509 |
* affect the Image. |
477 |
* |
|
510 |
* |
478 |
* @return an <code>ImageData</code> containing the image's data and attributes |
|
511 |
* @return an <code>ImageData</code> containing the image's data and attributes |
479 |
* |
|
512 |
* |
480 |
* @exception SWTException <ul> |
|
513 |
* @exception SWTException <ul> |
481 |
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
|
514 |
* <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> |
482 |
* <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon</li> |
|
515 |
* <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon</li> |
483 |
* </ul> |
|
516 |
* </ul> |
484 |
* |
|
517 |
* |
485 |
* @see ImageData |
|
518 |
* @see ImageData |
486 |
*/ |
|
519 |
*/ |
487 |
public ImageData getImageData() { |
|
520 |
public ImageData getImageData() { |
488 |
if (internal_handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
|
521 |
if (internal_handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
489 |
if (type != SWT.BITMAP) SWT.error(SWT.ERROR_INVALID_IMAGE); |
|
522 |
if (type != SWT.BITMAP) SWT.error(SWT.ERROR_INVALID_IMAGE); |
490 |
ImageData imageData = createImageDataFromNativeImage(internal_handle); |
|
523 |
ImageData imageData = createImageDataFromNativeImage(internal_handle); |
491 |
return imageData; |
|
524 |
return imageData; |
492 |
} |
|
525 |
} |
493 |
/** |
|
526 |
/** |
494 |
* Returns an integer hash code for the receiver. Any two |
|
527 |
* Returns an integer hash code for the receiver. Any two |
495 |
* objects that return <code>true</code> when passed to |
|
528 |
* objects that return <code>true</code> when passed to |
496 |
* <code>equals</code> must return the same value for this |
|
529 |
* <code>equals</code> must return the same value for this |
497 |
* method. |
|
530 |
* method. |
498 |
* |
|
531 |
* |
499 |
* @return the receiver's hash |
|
532 |
* @return the receiver's hash |
500 |
* |
|
533 |
* |
501 |
* @see #equals |
|
534 |
* @see #equals |
502 |
*/ |
|
535 |
*/ |
503 |
public int hashCode() { |
|
536 |
public int hashCode() { |
504 |
return internal_handle; |
|
537 |
return internal_handle; |
505 |
} |
|
538 |
} |
506 |
void init(Device device, ImageData imageData) { |
|
539 |
void init(Device device, ImageData imageData) { |
507 |
if (device == null) device = Device.getDevice(); |
|
540 |
if (device == null) device = Device.getDevice(); |
508 |
if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); |
|
541 |
if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); |
509 |
if (imageData == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); |
|
542 |
if (imageData == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); |
510 |
int depth = imageData.depth; |
|
543 |
int depth = imageData.depth; |
511 |
this.device = device; |
|
544 |
this.device = device; |
512 |
|
|
545 |
|
513 |
PaletteData palette = imageData.palette; |
|
546 |
PaletteData palette = imageData.palette; |
514 |
if (palette.isDirect) { |
|
547 |
if (palette.isDirect) { |
515 |
byte[] byteData = imageData.data; |
|
548 |
byte[] byteData = imageData.data; |
516 |
int width = imageData.width; |
|
549 |
int width = imageData.width; |
517 |
int height = imageData.height; |
|
550 |
int height = imageData.height; |
518 |
int[] intData = new int[width * height]; |
|
551 |
int[] intData = new int[width * height]; |
519 |
int bytesPerPixel = depth / 8; |
|
552 |
int bytesPerPixel = depth / 8; |
520 |
int redMask = palette.redMask; |
|
553 |
int redMask = palette.redMask; |
521 |
int greenMask = palette.greenMask; |
|
554 |
int greenMask = palette.greenMask; |
522 |
int blueMask = palette.blueMask; |
|
555 |
int blueMask = palette.blueMask; |
523 |
int redShift = countBits(redMask, 0); |
|
556 |
int redShift = countBits(redMask, 0); |
524 |
int greenShift = countBits(greenMask, 0); |
|
557 |
int greenShift = countBits(greenMask, 0); |
525 |
int blueShift = countBits(blueMask, 0); |
|
558 |
int blueShift = countBits(blueMask, 0); |
526 |
int redMax8bit = 0; |
|
559 |
int redMax8bit = 0; |
527 |
int greenMax8bit = 0; |
|
560 |
int greenMax8bit = 0; |
528 |
int blueMax8bit = 0; |
|
561 |
int blueMax8bit = 0; |
529 |
|
|
562 |
|
530 |
if (depth == 8) { |
|
563 |
if (depth == 8) { |
531 |
int redSize = countBits(redMask >> redShift, 1); |
|
564 |
int redSize = countBits(redMask >> redShift, 1); |
532 |
int greenSize = countBits(greenMask >> greenShift, 1); |
|
565 |
int greenSize = countBits(greenMask >> greenShift, 1); |
533 |
int blueSize = countBits(blueMask >> blueShift, 1); |
|
566 |
int blueSize = countBits(blueMask >> blueShift, 1); |
534 |
|
|
567 |
|
535 |
redMax8bit = (1 << redSize) - 1; |
|
568 |
redMax8bit = (1 << redSize) - 1; |
536 |
greenMax8bit = (1 << greenSize) - 1; |
|
569 |
greenMax8bit = (1 << greenSize) - 1; |
537 |
blueMax8bit = (1 << blueSize) - 1; |
|
570 |
blueMax8bit = (1 << blueSize) - 1; |
538 |
} |
|
571 |
} |
539 |
|
|
572 |
|
540 |
for (int y = 0; y < height; y++) { |
|
573 |
for (int y = 0; y < height; y++) { |
541 |
for (int x = 0; x < width; x++) { |
|
574 |
for (int x = 0; x < width; x++) { |
542 |
int byteIndex = y * imageData.bytesPerLine + x * bytesPerPixel; |
|
575 |
int byteIndex = y * imageData.bytesPerLine + x * bytesPerPixel; |
543 |
int pixel; |
|
576 |
int pixel; |
544 |
if (depth == 8) { |
|
577 |
if (depth == 8) { |
545 |
pixel = byteData[byteIndex]; |
|
578 |
pixel = byteData[byteIndex]; |
546 |
} else if (depth == 16) { |
|
579 |
} else if (depth == 16) { |
547 |
// 16bpp image data is in least significant byte order |
|
580 |
// 16bpp image data is in least significant byte order |
548 |
pixel = (byteData[byteIndex+1] & 0xFF) << 8 | (byteData[byteIndex] & 0xFF); |
|
581 |
pixel = (byteData[byteIndex+1] & 0xFF) << 8 | (byteData[byteIndex] & 0xFF); |
549 |
} else if (depth == 24) { |
|
582 |
} else if (depth == 24) { |
550 |
// 24bpp image data is in most significant byte order |
|
583 |
// 24bpp image data is in most significant byte order |
551 |
pixel = (byteData[byteIndex] & 0xFF) << 16 | (byteData[byteIndex+1] & 0xFF) << 8 | (byteData[byteIndex+2] & 0xFF); |
|
584 |
pixel = (byteData[byteIndex] & 0xFF) << 16 | (byteData[byteIndex+1] & 0xFF) << 8 | (byteData[byteIndex+2] & 0xFF); |
552 |
} else { |
|
585 |
} else { |
553 |
// 32bpp image data is in most significant byte order |
|
586 |
// 32bpp image data is in most significant byte order |
554 |
pixel = (byteData[byteIndex] & 0xFF) << 24 | (byteData[byteIndex+1] & 0xFF) << 16 | (byteData[byteIndex+2] & 0xFF) << 8 | (byteData[byteIndex+3] & 0xFF); |
|
587 |
pixel = (byteData[byteIndex] & 0xFF) << 24 | (byteData[byteIndex+1] & 0xFF) << 16 | (byteData[byteIndex+2] & 0xFF) << 8 | (byteData[byteIndex+3] & 0xFF); |
555 |
} |
|
588 |
} |
556 |
int red = getPixelRGBComponent(pixel, redMask, redShift); |
|
589 |
int red = getPixelRGBComponent(pixel, redMask, redShift); |
557 |
int green = getPixelRGBComponent(pixel, greenMask, greenShift); |
|
590 |
int green = getPixelRGBComponent(pixel, greenMask, greenShift); |
558 |
int blue = getPixelRGBComponent(pixel, blueMask, blueShift); |
|
591 |
int blue = getPixelRGBComponent(pixel, blueMask, blueShift); |
559 |
// UGL does not support 8 bit direct color. Convert color values to 16 bit. |
|
592 |
// UGL does not support 8 bit direct color. Convert color values to 16 bit. |
560 |
if (depth == 8) { |
|
593 |
if (depth == 8) { |
561 |
final int RedMax16bit = 31; // 5 bits |
|
594 |
final int RedMax16bit = 31; // 5 bits |
562 |
final int GreenMax16bit = 63; // 6 bits |
|
595 |
final int GreenMax16bit = 63; // 6 bits |
563 |
final int BlueMax16bit = 31; // 5 bits |
|
596 |
final int BlueMax16bit = 31; // 5 bits |
564 |
|
|
597 |
|
565 |
if (redMax8bit != 0) { |
|
598 |
if (redMax8bit != 0) { |
566 |
red = red * RedMax16bit / redMax8bit; |
|
599 |
red = red * RedMax16bit / redMax8bit; |
567 |
} |
|
600 |
} |
568 |
if (greenMax8bit != 0) { |
|
601 |
if (greenMax8bit != 0) { |
569 |
green = green * GreenMax16bit / greenMax8bit; |
|
602 |
green = green * GreenMax16bit / greenMax8bit; |
570 |
} |
|
603 |
} |
571 |
if (blueMax8bit != 0) { |
|
604 |
if (blueMax8bit != 0) { |
572 |
blue = blue * BlueMax16bit / blueMax8bit; |
|
605 |
blue = blue * BlueMax16bit / blueMax8bit; |
573 |
} |
|
606 |
} |
574 |
intData[y * width + x] = red << 11 | green << 5 | blue; |
|
607 |
intData[y * width + x] = red << 11 | green << 5 | blue; |
575 |
} else if (depth == 16) { |
|
608 |
} else if (depth == 16) { |
576 |
intData[y * width + x] = red << 11 | green << 5 | blue; |
|
609 |
intData[y * width + x] = red << 11 | green << 5 | blue; |
577 |
} else if (depth == 24){ |
|
610 |
} else if (depth == 24){ |
578 |
intData[y * width + x] = red << 16 | green << 8 | blue; |
|
611 |
intData[y * width + x] = red << 16 | green << 8 | blue; |
579 |
} else { |
|
612 |
} else { |
580 |
if ((imageData.alpha == -1) && (imageData.alphaData == null) && (imageData.transparentPixel == -1)) { |
|
613 |
if ((imageData.alpha == -1) && (imageData.alphaData == null) && (imageData.transparentPixel == -1)) { |
581 |
intData[y * width + x] = 255 << 24 | red << 16 | green << 8 | blue; |
|
614 |
intData[y * width + x] = 255 << 24 | red << 16 | green << 8 | blue; |
582 |
} else { |
|
615 |
} else { |
583 |
intData[y * width + x] = red << 16 | green << 8 | blue; |
|
616 |
intData[y * width + x] = red << 16 | green << 8 | blue; |
584 |
} |
|
617 |
} |
585 |
} |
|
618 |
} |
586 |
} |
|
619 |
} |
587 |
} |
|
620 |
} |
588 |
// UGL does not directly support 8 bit direct images. |
|
621 |
// UGL does not directly support 8 bit direct images. |
589 |
if (depth == 8) { |
|
622 |
if (depth == 8) { |
590 |
depth = 16; |
|
623 |
depth = 16; |
591 |
} |
|
624 |
} |
592 |
internal_handle = OS.Image_NewFromIntData(device.internal_handle, width, height, intData, depth, imageData.transparentPixel, imageData.alpha, imageData.alphaData); |
|
625 |
internal_handle = OS.Image_NewFromIntData(device.internal_handle, width, height, intData, depth, imageData.transparentPixel, imageData.alpha, imageData.alphaData); |
593 |
} else { |
|
626 |
} else { |
594 |
RGB[] rgbs = imageData.getRGBs(); |
|
627 |
RGB[] rgbs = imageData.getRGBs(); |
595 |
// guard against SWT palette being too long, since PaletteData does |
|
628 |
// guard against SWT palette being too long, since PaletteData does |
596 |
// no consistency check. |
|
629 |
// no consistency check. |
597 |
int paletteSize = Math.min(rgbs.length, 1 << depth); |
|
630 |
int paletteSize = Math.min(rgbs.length, 1 << depth); |
598 |
byte[] indexedReds = new byte[paletteSize]; |
|
631 |
byte[] indexedReds = new byte[paletteSize]; |
599 |
byte[] indexedGreens = new byte[paletteSize]; |
|
632 |
byte[] indexedGreens = new byte[paletteSize]; |
600 |
byte[] indexedBlues = new byte[paletteSize]; |
|
633 |
byte[] indexedBlues = new byte[paletteSize]; |
601 |
|
|
634 |
|
602 |
for (int i = 0; i < paletteSize; i++) { |
|
635 |
for (int i = 0; i < paletteSize; i++) { |
603 |
RGB rgb = rgbs[i]; |
|
636 |
RGB rgb = rgbs[i]; |
604 |
indexedReds[i] = (byte) rgb.red; |
|
637 |
indexedReds[i] = (byte) rgb.red; |
605 |
indexedGreens[i] = (byte) rgb.green; |
|
638 |
indexedGreens[i] = (byte) rgb.green; |
606 |
indexedBlues[i] = (byte) rgb.blue; |
|
639 |
indexedBlues[i] = (byte) rgb.blue; |
607 |
} |
|
640 |
} |
608 |
internal_handle = OS.Image_NewFromByteData(device.internal_handle, imageData.width, imageData.height, imageData.data, imageData.bytesPerLine, depth, indexedReds, indexedGreens, indexedBlues, paletteSize, imageData.transparentPixel); |
|
641 |
internal_handle = OS.Image_NewFromByteData(device.internal_handle, imageData.width, imageData.height, imageData.data, imageData.bytesPerLine, depth, indexedReds, indexedGreens, indexedBlues, paletteSize, imageData.transparentPixel); |
609 |
} |
|
642 |
} |
610 |
} |
|
643 |
} |
611 |
void init(Device device, String fileName) { |
|
644 |
void init(Device device, String fileName) { |
612 |
if (device == null) device = Device.getDevice(); |
|
645 |
if (device == null) device = Device.getDevice(); |
613 |
if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); |
|
646 |
if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); |
614 |
if (fileName == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); |
|
647 |
if (fileName == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); |
615 |
int imageFormat = Image.imageFormat(fileName); |
|
648 |
int imageFormat = Image.imageFormat(fileName); |
616 |
if (imageFormat == SWT.IMAGE_UNDEFINED) SWT.error(SWT.ERROR_UNSUPPORTED_FORMAT); |
|
649 |
if (imageFormat == SWT.IMAGE_UNDEFINED) SWT.error(SWT.ERROR_UNSUPPORTED_FORMAT); |
617 |
|
|
650 |
|
618 |
internal_handle = OS.Image_NewFromFile(device.internal_handle, fileName); |
|
651 |
internal_handle = OS.Image_NewFromFile(device.internal_handle, fileName); |
619 |
this.device = device; |
|
652 |
this.device = device; |
620 |
} |
|
653 |
} |
621 |
void init(Device device, InputStream stream) { |
|
654 |
void init(Device device, InputStream stream) { |
622 |
if (device == null) device = Device.getDevice(); |
|
655 |
if (device == null) device = Device.getDevice(); |
623 |
if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); |
|
656 |
if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); |
624 |
if (stream == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); |
|
657 |
if (stream == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); |
625 |
|
|
658 |
|
626 |
byte[] buffer = readImageStream(stream); |
|
659 |
byte[] buffer = readImageStream(stream); |
627 |
int imageFormat = Image.imageFormat(buffer); |
|
660 |
int imageFormat = Image.imageFormat(buffer); |
628 |
if (imageFormat == SWT.IMAGE_UNDEFINED) SWT.error(SWT.ERROR_UNSUPPORTED_FORMAT); |
|
661 |
if (imageFormat == SWT.IMAGE_UNDEFINED) SWT.error(SWT.ERROR_UNSUPPORTED_FORMAT); |
629 |
|
|
662 |
|
630 |
internal_handle = OS.Image_NewFromFileData(device.internal_handle, buffer, buffer.length); |
|
663 |
internal_handle = OS.Image_NewFromFileData(device.internal_handle, buffer, buffer.length); |
631 |
this.device = device; |
|
664 |
this.device = device; |
632 |
} |
|
665 |
} |
633 |
void init(Device device, int width, int height) { |
|
666 |
void init(Device device, int width, int height) { |
634 |
if (device == null) device = Device.getDevice(); |
|
667 |
if (device == null) device = Device.getDevice(); |
635 |
if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); |
|
668 |
if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); |
636 |
this.device = device; |
|
669 |
this.device = device; |
637 |
if (width <= 0 | height <= 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); |
<> |
670 |
if (width <= 0 || height <= 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); |
638 |
this.type = SWT.BITMAP; |
= |
671 |
this.type = SWT.BITMAP; |
639 |
|
|
672 |
|
640 |
// Fill with opaque black |
|
673 |
// Fill with opaque black |
641 |
internal_handle = OS.Image_NewFromSize(device.internal_handle, width, height, 0xff000000); |
|
674 |
internal_handle = OS.Image_NewFromSize(device.internal_handle, width, height, 0xff000000); |
642 |
if (internal_handle == 0) SWT.error(SWT.ERROR_NO_HANDLES); |
|
675 |
if (internal_handle == 0) SWT.error(SWT.ERROR_NO_HANDLES); |
|
|
-+ |
676 |
} |
|
|
|
677 |
void init(Device device, int identifier) |
|
|
|
678 |
{ |
|
|
|
679 |
if (device == null) device = Device.getDevice(); |
|
|
|
680 |
if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); |
|
|
|
681 |
if ((identifier != ERROR) && (identifier != INFORMATION) && |
|
|
|
682 |
(identifier != QUESTION) && (identifier != WARNING)) { |
|
|
|
683 |
SWT.error(SWT.ERROR_INVALID_ARGUMENT); |
|
|
|
684 |
} |
|
|
|
685 |
this.device = device; |
|
|
|
686 |
this.type = SWT.BITMAP; |
|
|
|
687 |
internal_handle = OS.Image_NewFromSystemResource(device.internal_handle, identifier); |
643 |
} |
= |
688 |
} |
644 |
|
|
689 |
|
645 |
public void internal_copyArea(int destImageHandle, int srcX, int srcY, int srcWidth, int srcHeight) { |
|
690 |
public void internal_copyArea(int destImageHandle, int srcX, int srcY, int srcWidth, int srcHeight) { |
646 |
OS.Image_CopyArea(internal_handle, destImageHandle, srcX, srcY, srcWidth, srcHeight); |
|
691 |
OS.Image_CopyArea(internal_handle, destImageHandle, srcX, srcY, srcWidth, srcHeight); |
647 |
} |
|
692 |
} |
648 |
/** |
|
693 |
/** |
649 |
* Invokes platform specific functionality to dispose a GC handle. |
|
694 |
* Invokes platform specific functionality to dispose a GC handle. |
650 |
* <p> |
|
695 |
* <p> |
651 |
* <b>IMPORTANT:</b> This method is <em>not</em> part of the public |
|
696 |
* <b>IMPORTANT:</b> This method is <em>not</em> part of the public |
652 |
* API for <code>Image</code>. It is marked public only so that it |
|
697 |
* API for <code>Image</code>. It is marked public only so that it |
653 |
* can be shared within the packages provided by SWT. It is not |
|
698 |
* can be shared within the packages provided by SWT. It is not |
654 |
* available on all platforms, and should never be called from |
|
699 |
* available on all platforms, and should never be called from |
655 |
* application code. |
|
700 |
* application code. |
656 |
* </p> |
|
701 |
* </p> |
657 |
* |
|
702 |
* |
658 |
* @param handle the platform specific GC handle |
|
703 |
* @param handle the platform specific GC handle |
659 |
* @param data the platform specific GC data |
|
704 |
* @param data the platform specific GC data |
660 |
* |
|
705 |
* |
661 |
*/ |
|
706 |
*/ |
662 |
public void internal_dispose_GC(int painter, InternalGCData data) { |
|
707 |
public void internal_dispose_GC(int painter, InternalGCData data) { |
663 |
// do nothing. GCs disposed in GC.dispose |
|
708 |
// do nothing. GCs disposed in GC.dispose |
664 |
} |
|
709 |
} |
665 |
public Rectangle internal_getBounds () { |
|
710 |
public Rectangle internal_getBounds () { |
666 |
return getBounds(); |
|
711 |
return getBounds(); |
667 |
} |
|
712 |
} |
668 |
public int internal_getDepth() { |
|
713 |
public int internal_getDepth() { |
669 |
return OS.Image_GetDepth(internal_handle); |
|
714 |
return OS.Image_GetDepth(internal_handle); |
670 |
} |
|
715 |
} |
671 |
/** |
|
716 |
/** |
672 |
* Invokes platform specific functionality to allocate a new GC handle. |
|
717 |
* Invokes platform specific functionality to allocate a new GC handle. |
673 |
* <p> |
|
718 |
* <p> |
674 |
* <b>IMPORTANT:</b> This method is <em>not</em> part of the public |
|
719 |
* <b>IMPORTANT:</b> This method is <em>not</em> part of the public |
675 |
* API for <code>Image</code>. It is marked public only so that it |
|
720 |
* API for <code>Image</code>. It is marked public only so that it |
676 |
* can be shared within the packages provided by SWT. It is not |
|
721 |
* can be shared within the packages provided by SWT. It is not |
677 |
* available on all platforms, and should never be called from |
|
722 |
* available on all platforms, and should never be called from |
678 |
* application code. |
|
723 |
* application code. |
679 |
* </p> |
|
724 |
* </p> |
680 |
* |
|
725 |
* |
681 |
* @param data the platform specific GC data |
|
726 |
* @param data the platform specific GC data |
682 |
* @return the platform specific GC handle |
|
727 |
* @return the platform specific GC handle |
683 |
* |
|
728 |
* |
684 |
* @private |
|
729 |
* @private |
685 |
*/ |
|
730 |
*/ |
686 |
public int internal_new_GC(InternalGCData data) { |
|
731 |
public int internal_new_GC(InternalGCData data) { |
687 |
if (internal_handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
|
732 |
if (internal_handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); |
688 |
/* |
|
733 |
/* |
689 |
* Create a new GC that can draw into the image. |
|
734 |
* Create a new GC that can draw into the image. |
690 |
* Only supported for bitmaps. |
|
735 |
* Only supported for bitmaps. |
691 |
*/ |
|
736 |
*/ |
692 |
if (type != SWT.BITMAP || memGC != null) SWT.error(SWT.ERROR_INVALID_ARGUMENT); |
|
737 |
if (type != SWT.BITMAP || memGC != null) SWT.error(SWT.ERROR_INVALID_ARGUMENT); |
693 |
|
|
738 |
|
694 |
int gcHandle = OS.Image_NewGraphics(internal_handle); |
|
739 |
int gcHandle = OS.Image_NewGraphics(internal_handle); |
695 |
data.device = device; |
|
740 |
data.device = device; |
696 |
data.image = this; |
|
741 |
data.image = this; |
697 |
return gcHandle; |
|
742 |
return gcHandle; |
698 |
} |
|
743 |
} |
699 |
/** |
|
744 |
/** |
700 |
* Returns <code>true</code> if the image has been disposed, |
|
745 |
* Returns <code>true</code> if the image has been disposed, |
701 |
* and <code>false</code> otherwise. |
|
746 |
* and <code>false</code> otherwise. |
702 |
* <p> |
|
747 |
* <p> |
703 |
* This method gets the dispose state for the image. |
|
748 |
* This method gets the dispose state for the image. |
704 |
* When an image has been disposed, it is an error to |
|
749 |
* When an image has been disposed, it is an error to |
705 |
* invoke any other method using the image. |
|
750 |
* invoke any other method using the image. |
706 |
* |
|
751 |
* |
707 |
* @return <code>true</code> when the image is disposed and <code>false</code> otherwise |
|
752 |
* @return <code>true</code> when the image is disposed and <code>false</code> otherwise |
708 |
*/ |
|
753 |
*/ |
709 |
public boolean isDisposed() { |
|
754 |
public boolean isDisposed() { |
710 |
return internal_handle == 0; |
|
755 |
return internal_handle == 0; |
711 |
} |
|
756 |
} |
712 |
/** |
|
757 |
/** |
713 |
* Returns a string containing a concise, human-readable |
|
758 |
* Returns a string containing a concise, human-readable |
714 |
* description of the receiver. |
|
759 |
* description of the receiver. |
715 |
* |
|
760 |
* |
716 |
* @return a string representation of the receiver |
|
761 |
* @return a string representation of the receiver |
717 |
*/ |
|
762 |
*/ |
718 |
public String toString () { |
|
763 |
public String toString () { |
719 |
if (isDisposed()) return "Image {*DISPOSED*}"; |
|
764 |
if (isDisposed()) return "Image {*DISPOSED*}"; |
720 |
return "Image {" + internal_handle + "}"; |
|
765 |
return "Image {" + internal_handle + "}"; |
721 |
} |
|
766 |
} |
722 |
|
|
767 |
|
723 |
public Rectangle internal_getDefaultClipping() { |
|
768 |
public Rectangle internal_getDefaultClipping() { |
724 |
return getBounds(); |
|
769 |
return getBounds(); |
725 |
} |
|
770 |
} |
726 |
|
|
771 |
|
727 |
} |
|
772 |
} |