Skip to content

Commit 12e0564

Browse files
ShahzaibIbrahimHeikoKlare
authored andcommitted
Guard smooth scaling for images not having transparency mask
Enabling the smooth scaling for images with a transparency mask produce erroneous results with a loss of transparency. This guards the application of smooth scaling with the given image not having a transparency mask.
1 parent cc07c36 commit 12e0564

File tree

1 file changed

+5
-5
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal

1 file changed

+5
-5
lines changed

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ private static ImageData autoScaleImageData (Device device, final ImageData imag
292292
int height = imageData.height;
293293
int scaledWidth = Math.round (width * scaleFactor);
294294
int scaledHeight = Math.round (height * scaleFactor);
295-
return switch (autoScaleMethod) {
296-
case SMOOTH -> {
295+
boolean useSmoothScaling = autoScaleMethod == AutoScaleMethod.SMOOTH && imageData.getTransparencyType() != SWT.TRANSPARENCY_MASK;
296+
if (useSmoothScaling) {
297297
Image original = new Image (device, (ImageDataProvider) zoom -> imageData);
298298
/* Create a 24 bit image data with alpha channel */
299299
final ImageData resultData = new ImageData (scaledWidth, scaledHeight, 24, new PaletteData (0xFF, 0xFF00, 0xFF0000));
@@ -310,10 +310,10 @@ private static ImageData autoScaleImageData (Device device, final ImageData imag
310310
original.dispose ();
311311
ImageData result = resultImage.getImageData (getDeviceZoom ());
312312
resultImage.dispose ();
313-
yield result;
313+
return result;
314+
} else {
315+
return imageData.scaledTo (scaledWidth, scaledHeight);
314316
}
315-
default -> imageData.scaledTo (scaledWidth, scaledHeight);
316-
};
317317
}
318318

319319
/**

0 commit comments

Comments
 (0)