Bug 491870 - Can't create copy of image instance
Summary: Can't create copy of image instance
Status: CLOSED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.5.2   Edit
Hardware: PC Windows 10
: P3 major (vote)
Target Milestone: 4.7 M7   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-17 14:37 EDT by Kamil Karkus CLA
Modified: 2017-04-05 06:27 EDT (History)
3 users (show)

See Also:


Attachments
Plain zip file (not a project or jar), src/bugreport contains two examples and images/bugreport the image used in the example (6.31 KB, application/zip)
2017-03-17 21:56 EDT, Diego Fernandez CLA
no flags Details
Output of test Snippets on Win10 and Win7 (46.67 KB, image/png)
2017-04-05 04:30 EDT, Niraj Modi CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kamil Karkus CLA 2016-04-17 14:37:24 EDT
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.
Comment 1 Diego Fernandez CLA 2017-03-17 21:56:14 EDT
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).
Comment 2 Diego Fernandez CLA 2017-03-17 22:00:29 EDT
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
Comment 3 Diego Fernandez CLA 2017-03-17 22:11:04 EDT
This bug is also reproducible in SWT 4.6.2
Comment 4 Lakshmi P Shanmugam CLA 2017-03-28 07:30:22 EDT
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?
Comment 5 Niraj Modi CLA 2017-04-05 04:30:21 EDT
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.
Comment 6 Niraj Modi CLA 2017-04-05 05:56:10 EDT
(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.
Comment 7 Lakshmi P Shanmugam CLA 2017-04-05 06:27:47 EDT
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.