summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSilenio Quarti <silenio_quarti@ca.ibm.com>2013-07-10 09:54:47 -0400
committerSilenio Quarti <silenio_quarti@ca.ibm.com>2013-07-10 09:55:49 -0400
commit80afedd97a0b6a72bd18c947fb1f1ef3bdcf7751 (patch)
treeca5a18272cb86f3a59a72b204f1283f6de64754a
parentca5e588017b8795b03417457562b8f46567bc04f (diff)
downloadeclipse.platform.swt-80afedd97a0b6a72bd18c947fb1f1ef3bdcf7751.tar.gz
eclipse.platform.swt-80afedd97a0b6a72bd18c947fb1f1ef3bdcf7751.tar.xz
eclipse.platform.swt-80afedd97a0b6a72bd18c947fb1f1ef3bdcf7751.zip
Bug 411203 - [Retina] screen capture via cmd shift control 4 is not
working as expected
-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();