Bug 481315 - [Graphics] Implement new HighDPI APIs Image#getImageDataAtCurrentZoom and Image#getBoundsInPixels
Summary: [Graphics] Implement new HighDPI APIs Image#getImageDataAtCurrentZoom and Ima...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.5   Edit
Hardware: PC All
: P3 enhancement (vote)
Target Milestone: 4.6 M6   Edit
Assignee: Niraj Modi CLA
QA Contact:
URL:
Whiteboard:
Keywords: api
Depends on:
Blocks: 479614
  Show dependency tree
 
Reported: 2015-11-03 08:00 EST by Thomas Singer CLA
Modified: 2016-03-18 12:01 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Singer CLA 2015-11-03 08:00:47 EST
Currently, it is unclear what information is returned by image.getBounds() and image.getImageData() for images created with an ImageDataProvider returning different scaled versions of the image.

BTW, why there is a image.getBounds() but not image.getSize()? Is there a situation imaginable where x and y in the bounds are != 0?
Comment 1 Sravan Kumar Lakkimsetti CLA 2015-11-04 00:43:29 EST
both getBounds() and getImageData() returns the information about the current image(hidpi/normal). 

This is going to change for Neon. in neon this will always return for 100% image.
Comment 2 Niraj Modi CLA 2015-11-04 04:27:33 EST
(In reply to Sravan Kumar Lakkimsetti from comment #1)
> both getBounds() and getImageData() returns the information about the
> current image(hidpi/normal). 
> 
> This is going to change for Neon. in neon this will always return for 100%
> image.

Once above behavior is implemented, we will mention same in JavaDocs of these two method for clarity.

Refer https://bugs.eclipse.org/bugs/show_bug.cgi?id=479614#c1, we also plan to add below 2 new HighDPI APIs for all Platforms:
Image#getImageData(zoom) and Image#getBounds(zoom)
Comment 3 Eclipse Genie CLA 2015-11-23 08:32:22 EST
New Gerrit change created: https://git.eclipse.org/r/61009
Comment 4 Niraj Modi CLA 2015-11-23 08:42:55 EST
(In reply to Eclipse Genie from comment #3)
> New Gerrit change created: https://git.eclipse.org/r/61009

Below is the list of changes as part of this patch:
1. Update behavior of Image#getBounds() to always return bounds at 100% zoom.
2. New Image#getBounds(int zoom) method to return bounds at specified zoom level.
3. Also added a new API: Rectangle#scale(float scaleFactor) which comes handy when required to scales the Rectangle instance as per the specified scaleFactor.

Note: Planning to create a separate gerrit for Image#getImageData(zoom) changes.
Comment 5 Niraj Modi CLA 2015-12-01 07:51:23 EST
(In reply to Niraj Modi from comment #4)
> (In reply to Eclipse Genie from comment #3)
> > New Gerrit change created: https://git.eclipse.org/r/61009
> 
> Below is the list of changes as part of this patch:
> 1. Update behavior of Image#getBounds() to always return bounds at 100% zoom.
> 2. New Image#getBounds(int zoom) method to return bounds at specified zoom
> level.
> 3. Also added a new API: Rectangle#scale(float scaleFactor) which comes
> handy when required to scales the Rectangle instance as per the specified
> scaleFactor.
> 
> Note: Planning to create a separate gerrit for Image#getImageData(zoom)
> changes.

Above mentioned changes are pushed via below git patch to 'NeonhiDpiWork' branch:
http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?h=slakkimsetti/NeonhiDpiWork&id=8baf49afc39148cd9c97c190587eb0632fb864ce
Comment 6 Eclipse Genie CLA 2015-12-02 02:43:12 EST
New Gerrit change created: https://git.eclipse.org/r/61716
Comment 7 Sravan Kumar Lakkimsetti CLA 2015-12-03 04:27:55 EST
Moving To M5. There is a slight change required.
Comment 8 Niraj Modi CLA 2016-01-08 02:53:07 EST
(In reply to Eclipse Genie from comment #6)
> New Gerrit change created: https://git.eclipse.org/r/61716

Issue with above gerrit patch, as it fails for JUnits test which no longer exists in latest patch.
Committed the changes via below git patch to 'slakkimsetti/NeonhiDpiWork' branch:
http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?h=slakkimsetti/NeonhiDpiWork&id=aac6290317e08481c583a8d4ffc77b6b20cab551
Comment 9 Niraj Modi CLA 2016-03-15 10:51:52 EDT
Below are the new APIs added to Image Class for HighDPI purpose:
- Image#getImageDataAtCurrentZoom() - Returns ImageData at current Zoom
- Image#getBoundsInPixels() - Returns Bounds in Pixel
Note, existing standard APIs Image#getImageData() and Image#getBounds() to always return information at 100% zoom.

Work on this feature was done on below branch and is merged to master in Neon M6
http://git.eclipse.org/c/platform/eclipse.platform.swt.git/?h=slakkimsetti%2FHighDPIChangesforNeon
Comment 10 Thomas Singer CLA 2016-03-16 08:28:19 EDT
Why there is a image.getBounds() but not image.getSize()? Is there a situation imaginable where x and y in the bounds are != 0?
Comment 11 Sravan Kumar Lakkimsetti CLA 2016-03-18 05:56:28 EDT
verified in I20160317-0200
Comment 12 Sravan Kumar Lakkimsetti CLA 2016-03-18 05:58:08 EDT
(In reply to Thomas Singer from comment #10)
> Why there is a image.getBounds() but not image.getSize()? Is there a
> situation imaginable where x and y in the bounds are != 0?

We have used similar api which is already existing. that is the reason we have getBounds. it returns the size of the image in logical pixels
Comment 13 Lakshmi P Shanmugam CLA 2016-03-18 07:07:33 EDT
(In reply to Thomas Singer from comment #10)
> Why there is a image.getBounds() but not image.getSize()? Is there a
> situation imaginable where x and y in the bounds are != 0?

No, x & y will be 0.
The javadoc of getBounds() & getBoundsInPixels() excplicitly mention this.
/**
 * Returns the bounds of the receiver. The rectangle will always
 * have x and y values of 0, and the width and height of the
 * image.
 */
Comment 14 Thomas Singer CLA 2016-03-18 12:01:02 EDT
Now you are providing a new API, so this is the best point to make the right choice. IMHO, the right choice would be to use getSize():Point instead and keep getBounds() deprecated.