Bug 416799 - GC.drawImage does not shift correctly when scaled in GTK
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
index 3d905d4..9107e15 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
@@ -912,9 +912,13 @@
}
Cairo.cairo_rectangle(cairo, destX , destY, destWidth, destHeight);
Cairo.cairo_clip(cairo);
- Cairo.cairo_translate(cairo, destX - srcX, destY - srcY);
if (srcWidth != destWidth || srcHeight != destHeight) {
- Cairo.cairo_scale(cairo, destWidth / (float)srcWidth, destHeight / (float)srcHeight);
+ float scaleX = destWidth / (float)srcWidth;
+ float scaleY = destHeight / (float)srcHeight;
+ Cairo.cairo_translate(cairo, destX - (int)(srcX * scaleX), destY - (int)(srcY * scaleY));
+ Cairo.cairo_scale(cairo, scaleX, scaleY);
+ } else {
+ Cairo.cairo_translate(cairo, destX - srcX, destY - srcY);
}
int filter = Cairo.CAIRO_FILTER_GOOD;
switch (data.interpolation) {