Community
Participate
Working Groups
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?
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.
(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)
New Gerrit change created: https://git.eclipse.org/r/61009
(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.
(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
New Gerrit change created: https://git.eclipse.org/r/61716
Moving To M5. There is a slight change required.
(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
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
Why there is a image.getBounds() but not image.getSize()? Is there a situation imaginable where x and y in the bounds are != 0?
verified in I20160317-0200
(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
(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. */
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.