Bug 513844

Summary: Missing ImageDataProvider accessor in Image
Product: [Eclipse Project] Platform Reporter: Diego Fernandez <diego.fernandez>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: loskutov, niraj.modi
Version: 4.6   
Target Milestone: ---   
Hardware: PC   
OS: All   
Whiteboard:

Description Diego Fernandez CLA 2017-03-17 23:04:38 EDT
The field imageDataProvider in Image has a default access.

That makes impossible to "copy" an image using:

new Image(display, imageDataProvider)

Since is not possible to access the source imageDataProvider.

The main reasons to do something like this are:
- new Image(display, sourceImage, SWT.IMAGE_COPY) has bugs with HiDPI images (bug 491870)
- new Image(display, sourceImage.getImageData()) looses the HiDPI image, since getImageData returns the data at zoom 100
- Using getImageDataAtCurrentZoom throws ArrayIndexOutOfBounds (bug 513843)

Right now my workaround to the mentioned issues is to access imageDataProvider by reflection, resolving bug 491870 or bug 513843, makes the workaround unnecessary. However for a matter of completeness, it will be good to have the accessor or to consider bug 496409
Comment 1 Andrey Loskutov CLA 2017-03-28 04:43:39 EDT
Can you provide a patch?
Comment 2 Niraj Modi CLA 2017-04-14 04:49:14 EDT
We recently added below new API via bug 496409:
Image#getImageData(int zoom)

Also Image copy constructors are fixed, and they now copy the Providers via bug 514847.

Hope these fixes address your use-case, without the need for specific accessor for Providers.