diff options
author | Silenio Quarti <silenio> | 2006-08-14 19:22:15 +0000 |
---|---|---|
committer | Silenio Quarti <silenio> | 2006-08-14 19:22:15 +0000 |
commit | 285bcb19a810f0b50adfb9ecd453fd68b45ebe38 (patch) | |
tree | 9a2d8c12eec766643f7a4f0acb562bbe5be111fb | |
parent | c83efdce66683ce71701c76019258bb35c80359f (diff) | |
download | eclipse.platform.swt-285bcb19a810f0b50adfb9ecd453fd68b45ebe38.tar.gz eclipse.platform.swt-285bcb19a810f0b50adfb9ecd453fd68b45ebe38.tar.xz eclipse.platform.swt-285bcb19a810f0b50adfb9ecd453fd68b45ebe38.zip |
153567 - Custom cursor has wrong colors
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Cursor.java | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Cursor.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Cursor.java index 88cc56c88e..fea8cc0e0b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Cursor.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/graphics/Cursor.java @@ -357,21 +357,37 @@ public Cursor(Device device, ImageData source, int hotspotX, int hotspotY) { /* Create a destination image with no data */ ImageData newSource = new ImageData( source.width, source.height, 1, ImageData.bwPalette(), - 1, null, 0, null, null, -1, -1, source.type, - source.x, source.y, source.disposalMethod, source.delayTime); + 1, null, 0, null, null, -1, -1, 0, 0, 0, 0, 0); + + byte[] newReds = new byte[]{0, (byte)255}, newGreens = newReds, newBlues = newReds; /* Convert the source to a black and white image of depth 1 */ PaletteData palette = source.palette; - if (palette.isDirect) ImageData.blit(ImageData.BLIT_SRC, - source.data, source.depth, source.bytesPerLine, source.getByteOrder(), 0, 0, source.width, source.height, 0, 0, 0, - ImageData.ALPHA_OPAQUE, null, 0, 0, 0, - newSource.data, newSource.depth, newSource.bytesPerLine, newSource.getByteOrder(), 0, 0, newSource.width, newSource.height, 0, 0, 0, - false, false); - else ImageData.blit(ImageData.BLIT_SRC, - source.data, source.depth, source.bytesPerLine, source.getByteOrder(), 0, 0, source.width, source.height, null, null, null, - ImageData.ALPHA_OPAQUE, null, 0, 0, 0, - newSource.data, newSource.depth, newSource.bytesPerLine, newSource.getByteOrder(), 0, 0, newSource.width, newSource.height, null, null, null, - false, false); + if (palette.isDirect) { + ImageData.blit(ImageData.BLIT_SRC, + source.data, source.depth, source.bytesPerLine, source.getByteOrder(), 0, 0, source.width, source.height, palette.redMask, palette.greenMask, palette.blueMask, + ImageData.ALPHA_OPAQUE, null, 0, 0, 0, + newSource.data, newSource.depth, newSource.bytesPerLine, newSource.getByteOrder(), 0, 0, newSource.width, newSource.height, newReds, newGreens, newBlues, + false, false); + } else { + RGB[] rgbs = palette.getRGBs(); + int length = rgbs.length; + byte[] srcReds = new byte[length]; + byte[] srcGreens = new byte[length]; + byte[] srcBlues = new byte[length]; + for (int i = 0; i < rgbs.length; i++) { + RGB rgb = rgbs[i]; + if (rgb == null) continue; + srcReds[i] = (byte)rgb.red; + srcGreens[i] = (byte)rgb.green; + srcBlues[i] = (byte)rgb.blue; + } + ImageData.blit(ImageData.BLIT_SRC, + source.data, source.depth, source.bytesPerLine, source.getByteOrder(), 0, 0, source.width, source.height, srcReds, srcGreens, srcBlues, + ImageData.ALPHA_OPAQUE, null, 0, 0, 0, + newSource.data, newSource.depth, newSource.bytesPerLine, newSource.getByteOrder(), 0, 0, newSource.width, newSource.height, newReds, newGreens, newBlues, + false, false); + } source = newSource; } |