Skip to content

Commit

Permalink
[win32] Support scaling of ImageLists with null images
Browse files Browse the repository at this point in the history
This commit properly creates scaled variants of an ImageList if there a null images contained in the source ImageList

Contributes to eclipse-platform#62 and eclipse-platform#131
  • Loading branch information
akoch-yatta committed Aug 2, 2024
1 parent f68bc9b commit 05313c9
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -335,12 +335,18 @@ public long getHandle(int targetZoom) {
int scaledWidth = DPIUtil.scaleUp(DPIUtil.scaleDown(width, this.zoom), targetZoom);
int scaledHeight = DPIUtil.scaleUp(DPIUtil.scaleDown(height, this.zoom), targetZoom);
long handle = OS.ImageList_Create(scaledWidth, scaledHeight, flags, 16, 16);
int count = OS.ImageList_GetImageCount(handle);
for (int i = 0; i < images.length; i++) {
Image image = images[i];
if (image != null) {
set(i, image, count, handle, targetZoom);
count++;
set(i, image, i, handle, targetZoom);
} else {
long hDC = OS.GetDC (0);
if (hDC == 0) SWT.error(SWT.ERROR_NO_HANDLES);
long placeholderBitmapHandle = OS.CreateCompatibleBitmap(hDC, scaledWidth, scaledHeight);
if (placeholderBitmapHandle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
OS.ImageList_Add(handle, placeholderBitmapHandle, placeholderBitmapHandle);
OS.DeleteObject(placeholderBitmapHandle);
OS.ReleaseDC(0, hDC);
}
}
zoomToHandle.put(targetZoom, handle);
Expand Down

0 comments on commit 05313c9

Please sign in to comment.