summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/ImageTransfer.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/ImageTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/ImageTransfer.java
index 2f05bec885..e8786258d2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/ImageTransfer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/ImageTransfer.java
@@ -87,6 +87,23 @@ public Object nativeToJava(TransferData transferData) {
if (data.length() == 0) return null;
NSImage nsImage = (NSImage) new NSImage().alloc();
nsImage.initWithData(data);
+
+ NSSize size = nsImage.size();
+ NSImageRep rep = nsImage.bestRepresentationForDevice(null);
+ if (size.width != rep.pixelsWide() || size.height != rep.pixelsHigh()) {
+ size.width /= (rep.pixelsWide() / size.width);
+ size.height /= (rep.pixelsHigh() / size.height);
+ NSImage newImage = ((NSImage)new NSImage().alloc()).initWithSize(size);
+ newImage.lockFocus();
+ NSRect rect = new NSRect();
+ rect.width = size.width;
+ rect.height = size.height;
+ nsImage.drawInRect(rect, new NSRect(), OS.NSCompositeCopy, 1);
+ newImage.unlockFocus();
+ nsImage.release();
+ nsImage = newImage;
+ }
+
//TODO: Image representation wrong???
Image image = Image.cocoa_new(Display.getCurrent(), SWT.BITMAP, nsImage);
ImageData imageData = image.getImageData();