@@ -521,6 +521,20 @@ void disposeAll() {
521521 image .removeOnDisposeListener (disposeCallback );
522522 super .disposeAll ();
523523 }
524+
525+ protected float calculateTransformationScale () {
526+ Transform current = new Transform (device );
527+ getTransform (current );
528+ float [] m = new float [6 ];
529+ current .getElements (m );
530+ // this calculates the effective length in x and y
531+ // direction without being affected by the rotation
532+ // of the transformation
533+ float scaleWidth = (float ) Math .hypot (m [0 ], m [2 ]);
534+ float scaleHeight = (float ) Math .hypot (m [1 ], m [3 ]);
535+ current .dispose ();
536+ return Math .max (scaleWidth , scaleHeight );
537+ }
524538}
525539
526540private class CopyAreaToImageOperation extends ImageOperation {
@@ -1181,11 +1195,13 @@ void apply() {
11811195 private void draw (Image image , int srcX , int srcY , int srcWidth , int srcHeight , int destX , int destY , int destWidth , int destHeight ) {
11821196 int gcZoom = getZoom ();
11831197 int requestedImageZoom = calculateZoomForImage (gcZoom , source .width , source .height , destination .width , destination .height );
1198+ float transformationScale = calculateTransformationScale ();
1199+ int scaledImageZoomWithTransform = Math .round (transformationScale * requestedImageZoom );
11841200
11851201 Rectangle src = new Rectangle (srcX , srcY , srcWidth , srcHeight );
11861202 Rectangle destPixels = Win32DPIUtils .pointToPixel (drawable , new Rectangle (destX , destY , destWidth , destHeight ), gcZoom );
11871203 Rectangle fullImageBounds = image .getBounds ();
1188- Rectangle requestedFullImageBoundsPixels = Win32DPIUtils .pointToPixel (drawable , fullImageBounds , requestedImageZoom );
1204+ Rectangle requestedFullImageBoundsPixels = Win32DPIUtils .pointToPixel (drawable , fullImageBounds , scaledImageZoomWithTransform );
11891205
11901206 image .executeOnImageHandleAtBestFittingSize ((tempHandle ) -> {
11911207 Rectangle srcPixels = computeSourceRectangle (tempHandle , fullImageBounds , src );
@@ -1252,18 +1268,22 @@ private class DrawScaledImageOperation extends ImageOperation {
12521268
12531269 @ Override
12541270 void apply () {
1255- int gcZoom = getZoom ();
1256- drawImage (getImage (), destination .x , destination .y , destination .width , destination .height , gcZoom );
1271+ draw (getImage (), destination .x , destination .y , destination .width , destination .height );
12571272 }
1258- }
12591273
1260- private void drawImage (Image image , int destX , int destY , int destWidth , int destHeight , int imageZoom ) {
1261- Rectangle destPixels = Win32DPIUtils .pointToPixel (drawable , new Rectangle (destX , destY , destWidth , destHeight ),
1262- imageZoom );
1263- image .executeOnImageHandleAtBestFittingSize (tempHandle -> {
1264- drawImage (image , 0 , 0 , tempHandle .width (), tempHandle .height (), destPixels .x , destPixels .y ,
1265- destPixels .width , destPixels .height , false , tempHandle );
1266- }, destPixels .width , destPixels .height );
1274+ private void draw (Image image , int destX , int destY , int destWidth , int destHeight ) {
1275+ int gcZoom = getZoom ();
1276+ float transformationScale = calculateTransformationScale ();
1277+ int scaledImageZoomWithTransform = Math .round (transformationScale * gcZoom );
1278+ Rectangle destPixels = Win32DPIUtils .pointToPixel (drawable , new Rectangle (destX , destY , destWidth , destHeight ), gcZoom );
1279+ Rectangle destPixelsScaledWithTransform = Win32DPIUtils .pointToPixel (drawable , new Rectangle (destX , destY , destWidth , destHeight ),
1280+ scaledImageZoomWithTransform );
1281+
1282+ image .executeOnImageHandleAtBestFittingSize (tempHandle -> {
1283+ drawImage (image , 0 , 0 , tempHandle .width (), tempHandle .height (), destPixels .x , destPixels .y ,
1284+ destPixels .width , destPixels .height , false , tempHandle );
1285+ }, destPixelsScaledWithTransform .width , destPixelsScaledWithTransform .height );
1286+ }
12671287}
12681288
12691289private class DrawImageToImageOperation extends ImageOperation {
0 commit comments