Community
Participate
Working Groups
Hello, I can't create copy of image instance with this code(because I get instance with same size but every pixel is black): Image newImg = new Image(display, oldImg, SWT.IMAGE_COPY); //which works fine on linux However I found out it can be done in other way: Image newImg = new Image(display, oldImg.getImageData()); //this works on both platforms I don't know what I can tell more.
Created attachment 267330 [details] Plain zip file (not a project or jar), src/bugreport contains two examples and images/bugreport the image used in the example I had the same problem in MacOSX (no black image but transparent pixels). The problem with new Image(display, source, SWT.IMAGE_COPY) is reproducible when the image contains HiDPI data. The attached example shows how to reproduce it using JFace ImageDescriptor.createFromURL (see SWTCopyBug.java). Probably it can be reproduced also by creating the source image using a ImageDataProvider. The copy works when a non-HiDPI image is used (see SWTCopyWorking.java).
This bug is probably related with: https://bugs.eclipse.org/bugs/show_bug.cgi?id=480954 https://bugs.eclipse.org/bugs/show_bug.cgi?id=508570
This bug is also reproducible in SWT 4.6.2
The problem on Mac is fixed via Bug 508570. The sample in comment#1 seems to work fine now. Niraj, can you verify if this is a problem on Windows?
Created attachment 267649 [details] Output of test Snippets on Win10 and Win7 It looks like the snippet behavior is expected. Note: SWTCopyBug snippet uses ImageDescriptor(from JFace) which follow the @2x naming convention: https://www.eclipse.org/eclipse/news/4.6/platform_isv.php#high-dpi-icons Whereas SWTCopyWorking uses Image(from SWT) which is supposed to autoScale Up the image to 200% zoom. PFA Output of test Snippets on Win10 and Win7, confirming this.
(In reply to Kamil Karkus from comment #0) > Hello, > I can't create copy of image instance with this code(because I get instance > with same size but every pixel is black): > Image newImg = new Image(display, oldImg, SWT.IMAGE_COPY); //which works > fine on linux > > However I found out it can be done in other way: > > Image newImg = new Image(display, oldImg.getImageData()); //this works on > both platforms > > I don't know what I can tell more. I don't see the above behavior on Windows with latest Eclipse build. Also as per my testing, I didn't find any behavior difference between Win10 and Win7 w.r.t. to the attached snippets. Closing this issue, if you still see any issue around this please reopen with exact details and test-snippets.
The problem with Mac has been fixed via Bug 508570. It's possible that the problem on Windows too may have been fixed by other commits. Let's close this as WORKSFORME.