@@ -127,7 +127,7 @@ public final class Image extends Resource implements Drawable {
127
127
*/
128
128
static final int DEFAULT_SCANLINE_PAD = 4 ;
129
129
130
- private HashMap <Integer , ImageHandle > zoomLevelToImageHandle = new HashMap <>();
130
+ private Map <Integer , ImageHandle > zoomLevelToImageHandle = new HashMap <>();
131
131
132
132
/**
133
133
* Prevents uninitialized instances from being created outside the package.
@@ -1303,8 +1303,14 @@ public Rectangle getBounds() {
1303
1303
1304
1304
Rectangle getBounds (int zoom ) {
1305
1305
if (isDisposed ()) SWT .error (SWT .ERROR_GRAPHIC_DISPOSED );
1306
- ImageHandle imageMetadata = getImageMetadata (zoom );
1307
- return new Rectangle (0 , 0 , imageMetadata .width , imageMetadata .height );
1306
+ ImageHandle imageMetadata ;
1307
+ if (zoomLevelToImageHandle .containsKey (zoom )) {
1308
+ imageMetadata = zoomLevelToImageHandle .get (zoom );
1309
+ } else {
1310
+ imageMetadata = zoomLevelToImageHandle .values ().iterator ().next ();
1311
+ }
1312
+ Rectangle rectangle = new Rectangle (0 , 0 , imageMetadata .width , imageMetadata .height );
1313
+ return DPIUtil .scaleBounds (rectangle , zoom , imageMetadata .zoom );
1308
1314
}
1309
1315
1310
1316
/**
@@ -2084,18 +2090,19 @@ public void close() {
2084
2090
2085
2091
private class ImageHandle {
2086
2092
final long handle ;
2093
+ final int zoom ;
2087
2094
int height ;
2088
2095
int width ;
2089
2096
2090
2097
public ImageHandle (long handle , int zoom ) {
2091
2098
Rectangle bounds = getBoundsInPixelsFromNative (handle );
2092
2099
this .handle = handle ;
2100
+ this .zoom = zoom ;
2093
2101
this .height = bounds .height ;
2094
2102
this .width = bounds .width ;
2095
2103
setImageMetadataForHandle (this , zoom );
2096
2104
}
2097
2105
2098
-
2099
2106
private Rectangle getBoundsInPixelsFromNative (long handle ) {
2100
2107
switch (type ) {
2101
2108
case SWT .BITMAP :
0 commit comments