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 @@ -1772,16 +1772,16 @@ else if (i.alphaData != null) {
if (hIcon == 0) SWT.error(SWT.ERROR_NO_HANDLES);
OS.DeleteObject(hBitmap);
OS.DeleteObject(hMask);
image.new ImageHandle(hIcon, zoom);
image.type = SWT.ICON;
image.new ImageHandle(hIcon, zoom);
}
} else {
if (image == null) {
result = new long []{hDib};
} else {
image.new ImageHandle(hDib, zoom);
image.type = SWT.BITMAP;
image.transparentPixel = i.transparentPixel;
image.new ImageHandle(hDib, zoom);
}
}
return result;
Expand Down Expand Up @@ -2089,26 +2089,26 @@ public void close() {
}

private class ImageHandle {
final long handle;
final int zoom;
int height;
int width;
private final long handle;
private final int zoom;
private int height;
private 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;
updateBoundsInPixelsFromNative();
setImageMetadataForHandle(this, zoom);
}

private Rectangle getBoundsInPixelsFromNative(long handle) {
private void updateBoundsInPixelsFromNative() {
switch (type) {
case SWT.BITMAP:
BITMAP bm = new BITMAP();
OS.GetObject(handle, BITMAP.sizeof, bm);
return new Rectangle(0, 0, width = bm.bmWidth, height = bm.bmHeight);
width = bm.bmWidth;
height = bm.bmHeight;
return;
case SWT.ICON:
ICONINFO info = new ICONINFO();
OS.GetIconInfo(handle, info);
Expand All @@ -2119,10 +2119,11 @@ private Rectangle getBoundsInPixelsFromNative(long handle) {
if (hBitmap == info.hbmMask) bm.bmHeight /= 2;
if (info.hbmColor != 0) OS.DeleteObject(info.hbmColor);
if (info.hbmMask != 0) OS.DeleteObject(info.hbmMask);
return new Rectangle(0, 0, width = bm.bmWidth, height = bm.bmHeight);
width = bm.bmWidth;
height = bm.bmHeight;
return;
default:
SWT.error(SWT.ERROR_INVALID_IMAGE);
return null;
}
}

Expand Down
Loading