Project: SWT
Bug 125812 new Image(device, image, SWT.IMAGE_COPY) does not work as expected on windows.
Reported: 2006-01-31 06:45:37 | Status: resolved fixed

I'm using Eclipse-3.1M4/JDK1.5 Creating an image using new Image(device, image, SWT.IMAGE_COPY) does not work as expected. I have the following code to highlight a part of the image. When the imageData is set into the imageCanvas the image appears to be mirrored diagonally (i.e. mirrored vertically then horizontally) The behaviour of the snippet is different on Windows 2000 and Windows XP. On windows XP the image is mirrored diagonally, and the highlighted box appears on the image, at the correct position. On windows 2000 the image is mirrored diagonally, but the image is NOT highlighted. Setting the alpha to 255(or not setting alpha at all) will draw an opaque highlighted box. The snippet works OK on Linux (Ubuntu Linux ver 5.10) --- begin code --- protected void highlightImage(ImageMapDescriptor descriptor) { Image image = Activator.getImage("resources/images/page1.png"); Image imageCopy = new Image(image.getDevice(), image, SWT.IMAGE_COPY); // draw a highlighted rectangle GC gc = new GC(imageCopy); gc.setAlpha(64); gc.setBackground(new Color(gc.getDevice(), 255, 255, 0)); gc.fillRectangle(descriptor.getBounds()); // get the image data. ImageData imageData = imageCopy.getImageData(); // dispose imageCopy.dispose(); gc.dispose(); this.imageCanvas.setImageData(imageData); } --- end code ---

Files changed in fix:
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java