@@ -292,8 +292,9 @@ private static ImageData autoScaleImageData (Device device, final ImageData imag
292
292
int height = imageData .height ;
293
293
int scaledWidth = Math .round (width * scaleFactor );
294
294
int scaledHeight = Math .round (height * scaleFactor );
295
- return switch (autoScaleMethod ) {
296
- case SMOOTH -> {
295
+ ImageData result ;
296
+ boolean useSmoothScaling = autoScaleMethod == AutoScaleMethod .SMOOTH && imageData .getTransparencyType () != SWT .TRANSPARENCY_MASK ;
297
+ if (useSmoothScaling ) {
297
298
Image original = new Image (device , (ImageDataProvider ) zoom -> imageData );
298
299
/* Create a 24 bit image data with alpha channel */
299
300
final ImageData resultData = new ImageData (scaledWidth , scaledHeight , 24 , new PaletteData (0xFF , 0xFF00 , 0xFF0000 ));
@@ -302,18 +303,21 @@ private static ImageData autoScaleImageData (Device device, final ImageData imag
302
303
GC gc = new GC (resultImage );
303
304
gc .setAntialias (SWT .ON );
304
305
gc .drawImage (original , 0 , 0 , autoScaleDown (width ), autoScaleDown (height ),
305
- /* E.g. destWidth here is effectively DPIUtil.autoScaleDown (scaledWidth), but avoiding rounding errors.
306
- * Nevertheless, we still have some rounding errors due to the point-based API GC#drawImage(..).
306
+ /*
307
+ * E.g. destWidth here is effectively DPIUtil.autoScaleDown (scaledWidth), but
308
+ * avoiding rounding errors. Nevertheless, we still have some rounding errors
309
+ * due to the point-based API GC#drawImage(..).
307
310
*/
308
311
0 , 0 , Math .round (autoScaleDown (width * scaleFactor )), Math .round (autoScaleDown (height * scaleFactor )));
309
312
gc .dispose ();
310
313
original .dispose ();
311
- ImageData result = resultImage .getImageData (getDeviceZoom ());
314
+ result = resultImage .getImageData (getDeviceZoom ());
312
315
resultImage .dispose ();
313
- yield result ;
316
+ } else {
317
+ result = imageData .scaledTo (scaledWidth , scaledHeight );
314
318
}
315
- default -> imageData . scaledTo ( scaledWidth , scaledHeight );
316
- } ;
319
+
320
+ return result ;
317
321
}
318
322
319
323
/**
0 commit comments