Bug 508491 - Image#getImageData() on retina is garbled for PNG images
created via ImageDataProvider
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java
index 7c6cbd6..f3903e7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java
@@ -688,7 +688,7 @@
 		init ();
 		ImageData data2x = imageDataProvider.getImageData (200);
 		if (data2x != null) {
-			NSBitmapImageRep rep = createRepresentaion (data2x);
+			NSBitmapImageRep rep = createRepresentation (data2x);
 			handle.addRepresentation(rep);
 			rep.release();
 		}
@@ -856,7 +856,7 @@
 	return bounds;
 }
 
-ImageData _getImageData(NSBitmapImageRep imageRep) {
+ImageData _getImageData (NSBitmapImageRep imageRep) {
 	long /*int*/ width = imageRep.pixelsWide();
 	long /*int*/ height = imageRep.pixelsHigh();
 	long /*int*/ bpr = imageRep.bytesPerRow();
@@ -939,8 +939,12 @@
 	NSAutoreleasePool pool = null;
 	if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
 	try {
-		NSBitmapImageRep imageRep = getActualRepresentation();
-		return _getImageData(imageRep);
+		NSBitmapImageRep imageRep = getRepresentation();
+		ImageData data =  _getImageData(imageRep);
+		if (imageFileNameProvider == null && imageDataProvider == null) {
+			return data;
+		}
+		return DPIUtil.autoScaleImageData(device, data, 100, DPIUtil.getDeviceZoom());
 	} finally {
 		if (pool != null) pool.release();
 	}
@@ -967,11 +971,12 @@
 	NSAutoreleasePool pool = null;
 	if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
 	try {
+		NSBitmapImageRep imageRep = getRepresentation();
+		ImageData data = _getImageData(imageRep);
 		if (imageFileNameProvider != null || imageDataProvider != null) {
-			NSBitmapImageRep imageRep = getRepresentation();
-			return _getImageData(imageRep);
+			return data;
 		}
-		return DPIUtil.autoScaleImageData(device, getImageData(), DPIUtil.getDeviceZoom(), 100);
+		return DPIUtil.autoScaleImageData(device, data, DPIUtil.getDeviceZoom(), 100);
 	} finally {
 		if (pool != null) pool.release();
 	}
@@ -1000,26 +1005,6 @@
 	return image;
 }
 
-// Method to get the Image representation for the actual image without any scaling.
-NSBitmapImageRep getActualRepresentation () {
-	NSArray reps = handle.representations();
-	NSSize size = handle.size();
-	long /*int*/ count = reps.count();
-	for (int i = 0; i < count; i++) {
-		NSBitmapImageRep rep = new NSBitmapImageRep(reps.objectAtIndex(i));
-		if (((int)size.width == rep.pixelsWide() && (int)size.height == rep.pixelsHigh())) {
-			if (rep.isKindOfClass(OS.class_NSBitmapImageRep)) {
-				return rep;
-			}
-		}
-	}
-	NSBitmapImageRep newRep = (NSBitmapImageRep)new NSBitmapImageRep().alloc();
-	newRep = newRep.initWithData(handle.TIFFRepresentation());
-	handle.addRepresentation(newRep);
-	newRep.release();
-	return newRep;
-}
-
 NSBitmapImageRep getRepresentation () {
 	NSBitmapImageRep rep = new NSBitmapImageRep(handle.bestRepresentationForDevice(null));
 	if (rep.isKindOfClass(OS.class_NSBitmapImageRep)) {
@@ -1105,13 +1090,13 @@
 	this.width = image.width;
 	this.height = image.height;
 
-	NSBitmapImageRep rep = createRepresentaion(image);
+	NSBitmapImageRep rep = createRepresentation(image);
 	handle.addRepresentation(rep);
 	rep.release();
 	handle.setCacheMode(OS.NSImageCacheNever);
 }
 
-private NSBitmapImageRep createRepresentaion(ImageData imageData) {
+private NSBitmapImageRep createRepresentation(ImageData imageData) {
 	NSBitmapImageRep rep = (NSBitmapImageRep)new NSBitmapImageRep().alloc();
 
 	PaletteData palette = imageData.palette;