Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public final class Image extends Resource implements Drawable {
*/
static final int DEFAULT_SCANLINE_PAD = 4;

private HashMap<Integer, ImageHandle> zoomLevelToImageHandle = new HashMap<>();
private Map<Integer, ImageHandle> zoomLevelToImageHandle = new HashMap<>();

/**
* Prevents uninitialized instances from being created outside the package.
Expand Down Expand Up @@ -1303,8 +1303,14 @@ public Rectangle getBounds() {

Rectangle getBounds(int zoom) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
ImageHandle imageMetadata = getImageMetadata(zoom);
return new Rectangle(0, 0, imageMetadata.width, imageMetadata.height);
ImageHandle imageMetadata;
if (zoomLevelToImageHandle.containsKey(zoom)) {
imageMetadata = zoomLevelToImageHandle.get(zoom);
} else {
imageMetadata = zoomLevelToImageHandle.values().iterator().next();
}
Rectangle rectangle = new Rectangle(0, 0, imageMetadata.width, imageMetadata.height);
return DPIUtil.scaleBounds(rectangle, zoom, imageMetadata.zoom);
}

/**
Expand Down Expand Up @@ -2084,18 +2090,19 @@ public void close() {

private class ImageHandle {
final long handle;
final int zoom;
int height;
int width;

public ImageHandle(long handle, int zoom) {
Rectangle bounds = getBoundsInPixelsFromNative(handle);
this.handle = handle;
this.zoom = zoom;
this.height = bounds.height;
this.width = bounds.width;
setImageMetadataForHandle(this, zoom);
}


private Rectangle getBoundsInPixelsFromNative(long handle) {
switch (type) {
case SWT.BITMAP:
Expand Down
Loading