From 72e8cb6129ce13be39bbb8bdd184621530b3da02 Mon Sep 17 00:00:00 2001 From: "shahzaib.ibrahim" Date: Fri, 2 Aug 2024 17:25:07 +0200 Subject: [PATCH] Replacing the usage of getBoundsInPixels with getBounds initial native image must be the one that will be used by a widget, thats why using getBounds with initialNativeZoom --- .../Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java | 2 +- .../Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java | 2 +- .../Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java index 43eabea38f2..b903f0b9156 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java @@ -466,7 +466,7 @@ void copyAreaInPixels(Image image, int x, int y) { if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (image.type != SWT.BITMAP || image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); /* Copy the bitmap area */ - Rectangle rect = image.getBoundsInPixels(); + Rectangle rect = image.getBounds(data.nativeZoom); long memHdc = OS.CreateCompatibleDC(handle); long hOldBitmap = OS.SelectObject(memHdc, Image.win32_getHandle(image, getZoom())); OS.BitBlt(memHdc, 0, 0, rect.width, rect.height, handle, x, y, OS.SRCCOPY); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java index afed0488e7e..4d2a0bd1502 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java @@ -252,13 +252,13 @@ public Image(Device device, Image srcImage, int flag) { device = this.device; if (srcImage == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (srcImage.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - Rectangle rect = srcImage.getBoundsInPixels(); this.type = srcImage.type; this.imageDataProvider = srcImage.imageDataProvider; this.imageFileNameProvider = srcImage.imageFileNameProvider; this.styleFlag = srcImage.styleFlag | flag; initialNativeZoom = srcImage.initialNativeZoom; this.dataAtBaseZoom = srcImage.dataAtBaseZoom; + Rectangle rect = srcImage.getBounds(initialNativeZoom); switch (flag) { case SWT.IMAGE_COPY: { switch (type) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java index 1e0baa9c18b..b70c6e75087 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java @@ -7293,7 +7293,7 @@ LRESULT wmNotifyToolTip (NMTTCUSTOMDRAW nmcd, long lParam) { if (pinfo.iSubItem != 0) x -= gridWidth; Image image = item.getImage (pinfo.iSubItem); if (image != null) { - Rectangle rect = image.getBoundsInPixels (); + Rectangle rect = image.getBoundsInPixels(); RECT imageRect = item.getBounds (pinfo.iItem, pinfo.iSubItem, false, true, false, false, hDC); Point size = imageList == null ? new Point (rect.width, rect.height) : imageList.getImageSize (); int y = imageRect.top + Math.max (0, (imageRect.bottom - imageRect.top - size.y) / 2);