Skip to content

I20260427-1800

@HeikoKlare HeikoKlare tagged this 27 Apr 14:19
With e97143c7b058d66315d22d67f778188530af32ab, support was added on
Windows to take the Transform scaling into consideration when calling
drawImage(image, x, y). Especially when used in combination with an
SVG-based image, this leads to better results as the best-fitting image
representation is used for painting, rather than relying on
interpolation.

This change follows the same logic for Cocoa/macOS, equivalent to what
has already been done for Windows and Linux.

When a Transform is active on the GC, the call to drawImage(image, x, y)
is delegated to drawImage(image, x, y, w, h), using the image's natural
bounds as the destination size. Within that method, the destination
dimensions are multiplied by the effective transformation scale before
being passed to executeOnImageAtSizeBestFittingSize(), so that the
higher-resolution image representation is selected and rendered at its
full quality rather than being upscaled from a lower-resolution variant.

The effective scale is derived from the active NSAffineTransform via
Math.hypot() on the matrix columns, which correctly handles transforms
that combine scaling with rotation.

The existing test test_drawImageLorg_eclipse_swt_graphics_ImageIIII_withTransform,
which was previously restricted to Windows and Linux, is now enabled on all
platforms (the @DisabledOnOs(OS.MACOS) guard and its now-unused imports
are removed).

Contributes to
https://github.com/eclipse-platform/eclipse.platform.swt/issues/2919
Assets 2
Loading