summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java
diff options
context:
space:
mode:
authorSilenio Quarti <silenio>2004-08-13 15:43:54 +0000
committerSilenio Quarti <silenio>2004-08-13 15:43:54 +0000
commita9c82b91103bcd1315d5f013a883736f4e2bcbdc (patch)
treea88503e94abfeeb362bb3577016e8882d5f7c5f8 /bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java
parentb643808e4f52dd43d80a1e9e94b5c7e1e25a3b06 (diff)
downloadeclipse.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/Image.java')
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java43
1 files changed, 4 insertions, 39 deletions
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);
}