Skip to content

Commit 29753aa

Browse files
[Win32] Replace autoScaleUp of ImageData with proper scaleImageData
In some image constructors, image data are currently auto-scaled. This works by accident, as the device zoom used for auto scaling conforms to the zoom of the image to be initialized. However, to make this explicit, with this change the proper zoom is passed to scale method. It also makes the autoScaleUp method in DPIUtil obsolete and removes it. Co-authored-by: Hannes Wellmann <[email protected]>
1 parent 5a22598 commit 29753aa

File tree

2 files changed

+9
-10
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT

2 files changed

+9
-10
lines changed

bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/DPIUtil.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,6 @@ public static ImageData autoScaleUp (Device device, final ImageData imageData) {
346346
return autoScaleImageData(device, imageData, 100);
347347
}
348348

349-
public static ImageData autoScaleUp (Device device, final ElementAtZoom<ImageData> elementAtZoom) {
350-
return autoScaleImageData(device, elementAtZoom.element(), elementAtZoom.zoom());
351-
}
352-
353349
public static int[] autoScaleUp(int[] pointArray) {
354350
return scaleUp(pointArray, deviceZoom);
355351
}

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,9 @@ public Image(Device device, ImageData data) {
363363
super(device);
364364
if (data == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
365365
initialNativeZoom = DPIUtil.getNativeDeviceZoom();
366-
data = DPIUtil.autoScaleUp(device, new ElementAtZoom<>(data, 100));
367-
init(data, getZoom());
366+
int deviceZoom = getZoom();
367+
data = DPIUtil.scaleImageData(device, new ElementAtZoom<>(data, 100), deviceZoom);
368+
init(data, deviceZoom);
368369
init();
369370
this.device.registerResourceWithZoomSupport(this);
370371
}
@@ -471,8 +472,9 @@ public Image(Device device, ImageData source, ImageData mask) {
471472
public Image (Device device, InputStream stream) {
472473
super(device);
473474
initialNativeZoom = DPIUtil.getNativeDeviceZoom();
474-
ImageData data = DPIUtil.autoScaleUp(device, new ElementAtZoom<>(new ImageData (stream), 100));
475-
init(data, getZoom());
475+
int deviceZoom = getZoom();
476+
ImageData data = DPIUtil.scaleImageData(device, new ElementAtZoom<>(new ImageData (stream), 100), deviceZoom);
477+
init(data, deviceZoom);
476478
init();
477479
this.device.registerResourceWithZoomSupport(this);
478480
}
@@ -513,8 +515,9 @@ public Image (Device device, String filename) {
513515
super(device);
514516
if (filename == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
515517
initialNativeZoom = DPIUtil.getNativeDeviceZoom();
516-
ImageData data = DPIUtil.autoScaleUp(device, new ElementAtZoom<>(new ImageData (filename), 100));
517-
init(data, getZoom());
518+
int deviceZoom = getZoom();
519+
ImageData data = DPIUtil.scaleImageData(device, new ElementAtZoom<>(new ImageData (filename), 100), deviceZoom);
520+
init(data, deviceZoom);
518521
init();
519522
this.device.registerResourceWithZoomSupport(this);
520523
}

0 commit comments

Comments
 (0)