diff options
author | Silenio Quarti <silenio> | 2004-08-13 15:43:54 +0000 |
---|---|---|
committer | Silenio Quarti <silenio> | 2004-08-13 15:43:54 +0000 |
commit | a9c82b91103bcd1315d5f013a883736f4e2bcbdc (patch) | |
tree | a88503e94abfeeb362bb3577016e8882d5f7c5f8 /bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics | |
parent | b643808e4f52dd43d80a1e9e94b5c7e1e25a3b06 (diff) | |
download | eclipse.platform.swt-a9c82b91103bcd1315d5f013a883736f4e2bcbdc.tar.gz eclipse.platform.swt-a9c82b91103bcd1315d5f013a883736f4e2bcbdc.tar.xz eclipse.platform.swt-a9c82b91103bcd1315d5f013a883736f4e2bcbdc.zip |
64266
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics')
-rwxr-xr-x | bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Cursor.java | 9 | ||||
-rwxr-xr-x | bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java | 43 |
2 files changed, 8 insertions, 44 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Cursor.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Cursor.java index 83845b5424..b2b1f552a6 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Cursor.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Cursor.java @@ -254,8 +254,7 @@ public Cursor(Device device, int style) { * <li>ERROR_NULL_ARGUMENT - if the source is null</li> * <li>ERROR_NULL_ARGUMENT - if the mask is null and the source does not have a mask</li> * <li>ERROR_INVALID_ARGUMENT - if the source and the mask are not the same - * size, or either is not of depth one, or if the hotspot is outside - * the bounds of the image</li> + * size, or if the hotspot is outside the bounds of the image</li> * </ul> * @exception SWTError <ul> * <li>ERROR_NO_HANDLES - if a handle could not be obtained for cursor creation</li> @@ -276,14 +275,14 @@ public Cursor(Device device, ImageData source, ImageData mask, int hotspotX, int if (mask.width != source.width || mask.height != source.height) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } - /* Check color depths */ - if (mask.depth != 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - if (source.depth != 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT); /* Check the hotspots */ if (hotspotX >= source.width || hotspotX < 0 || hotspotY >= source.height || hotspotY < 0) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } + /* Convert depth to 1 */ + mask = ImageData.convertMask(mask); + source = ImageData.convertMask(source); /* Make sure source and mask scanline pad is 2 */ byte[] sourceData = ImageData.convertPad(source.data, source.width, source.height, source.depth, source.scanlinePad, 2); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java index 70d3a74bd4..9031e6b2dd 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java @@ -559,10 +559,8 @@ public Image(Device device, ImageData data) { /** * Constructs an instance of this class, whose type is * <code>SWT.ICON</code>, from the two given <code>ImageData</code> - * objects. The two images must be the same size, and the mask image - * must have a color depth of 1. Pixel transparency in either image - * will be ignored. If either image is an icon to begin with, an - * exception is thrown. + * objects. The two images must be the same size. Pixel transparency + * in either image will be ignored. * <p> * The mask image should contain white wherever the icon is to be visible, * and black wherever the icon is to be transparent. In addition, @@ -577,9 +575,7 @@ public Image(Device device, ImageData data) { * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li> * <li>ERROR_NULL_ARGUMENT - if either the source or mask is null </li> - * <li>ERROR_INVALID_ARGUMENT - if source and mask are different sizes or - * if the mask is not monochrome, or if either the source or mask - * is already an icon</li> + * <li>ERROR_INVALID_ARGUMENT - if source and mask are different sizes</li> * </ul> * @exception SWTError <ul> * <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li> @@ -593,38 +589,7 @@ public Image(Device device, ImageData source, ImageData mask) { if (source.width != mask.width || source.height != mask.height) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } - if (mask.depth != 1) { - /* - * Feature in Windows. 1-bit DIB sections are buggy on Win98, so we - * create 4-bit DIBs when given a 1-bit ImageData. In order to allow - * users to draw on the masks, we must also support 4-bit masks in - * icon creation by converting them into 1-bit masks. - */ - if (mask.depth != 4) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - PaletteData palette = new PaletteData(new RGB[] {new RGB(0, 0, 0), new RGB(255,255,255)}); - ImageData tempMask = new ImageData(mask.width, mask.height, 1, palette); - /* Find index of black in mask palette */ - RGB[] rgbs = mask.getRGBs(); - int blackIndex = 0; - while (blackIndex < rgbs.length) { - if (rgbs[blackIndex].equals(palette.colors[0])) break; - blackIndex++; - } - if (blackIndex == rgbs.length) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - int[] pixels = new int[mask.width]; - for (int y = 0; y < mask.height; y++) { - mask.getPixels(0, y, mask.width, pixels, 0); - for (int i = 0; i < pixels.length; i++) { - if (pixels[i] == blackIndex) { - pixels[i] = 0; - } else { - pixels[i] = 1; - } - } - tempMask.setPixels(0, y, mask.width, pixels, 0); - } - mask = tempMask; - } + mask = ImageData.convertMask(mask); init(device, this, source, mask); if (device.tracking) device.new_Object(this); } |