diff options
author | Sravan Kumar Lakkimsetti | 2018-11-26 12:04:30 +0000 |
---|---|---|
committer | Sravan Kumar Lakkimsetti | 2019-02-11 12:42:51 +0000 |
commit | 1fdceeecf03490cf104f153703ea774962a5e0a2 (patch) | |
tree | 79533e5ab63791b852658c06057d76b6d2613770 | |
parent | 786077d79023514fe6461507704d63fb05e7f62e (diff) | |
download | eclipse.platform.swt-1fdceeecf03490cf104f153703ea774962a5e0a2.tar.gz eclipse.platform.swt-1fdceeecf03490cf104f153703ea774962a5e0a2.tar.xz eclipse.platform.swt-1fdceeecf03490cf104f153703ea774962a5e0a2.zip |
Bug 538487 - [HiDPI] GC.copyArea() and Image.getImageData() behave
differently (and buggy) MacOS 10.13.6.
Change-Id: I3e4ef6b3672dc44ec401a9e139ba3081170a23c1
Signed-off-by: Sravan Kumar Lakkimsetti <sravankumarl@in.ibm.com>
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java | 57 |
1 files changed, 47 insertions, 10 deletions
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 d0ccede5ed..f292c7aecb 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 @@ -1324,24 +1324,61 @@ public ImageData getImageData(int zoom) { boolean hasImageProvider = imageFileNameProvider != null || imageDataProvider != null; if (zoom == 100) { NSBitmapImageRep imageRep; - imageRep = hasImageProvider ? getRepresentation_100() : getRepresentation(); - return _getImageData(imageRep, alphaInfo_100); - } - if (zoom == 200) { if (hasImageProvider) { - NSBitmapImageRep imageRep200 = getRepresentation_200(); - if (imageRep200 != null) { - if (alphaInfo_100.alphaData != null && alphaInfo_200 != null) { - if (alphaInfo_200.alphaData == null) initAlpha_200(imageRep200); + imageRep = getRepresentation_100(); + return _getImageData(imageRep, alphaInfo_100); + } else { + imageRep = getRepresentation(); + if (imageRep.pixelsHigh() == this.height) { + return _getImageData(imageRep, alphaInfo_100); + } else { + if (alphaInfo_200 == null) { + initAlpha_200(imageRep); + } + + NSArray reps = handle.representations(); + long /*int*/ count = reps.count(); + for (int i = 0; i < count; i++) { + handle.removeRepresentation(new NSImageRep(handle.representations().objectAtIndex(0))); } - return _getImageData(imageRep200, alphaInfo_200); + handle.addRepresentation(imageRep); + + NSSize size = handle.size(); + imageRep = (NSBitmapImageRep)new NSBitmapImageRep().alloc(); + imageRep = imageRep.initWithBitmapDataPlanes(0, (int) size.width, (int) size.height, 8, 3, false, false, OS.NSDeviceRGBColorSpace, OS.NSAlphaFirstBitmapFormat | OS.NSAlphaNonpremultipliedBitmapFormat, (int) size.width * 4, 32); + C.memset(imageRep.bitmapData(), 0xFF, (int) size.width * (int)size.height * 4); + NSGraphicsContext context = NSGraphicsContext.graphicsContextWithBitmapImageRep(imageRep); + NSGraphicsContext.static_saveGraphicsState(); + context.setImageInterpolation(OS.NSImageInterpolationDefault); + NSGraphicsContext.setCurrentContext(context); + NSRect target = new NSRect(); + target.width = size.width; + target.height = size.height; + NSRect sourceRect = new NSRect(); + sourceRect.width = 0; + sourceRect.height = 0; + handle.drawInRect(target, sourceRect, OS.NSCompositeCopy, 1); + NSGraphicsContext.static_restoreGraphicsState(); + return _getImageData(imageRep, alphaInfo_100); + } + } + } + if (zoom == 200) { + NSBitmapImageRep imageRep200 = getRepresentation_200(); + if (imageRep200 != null) { + if (alphaInfo_100.alphaData != null && alphaInfo_200 != null) { + if (alphaInfo_200.alphaData == null) initAlpha_200(imageRep200); + } + if (alphaInfo_200 == null) { + initAlpha_200(imageRep200); } + return _getImageData(imageRep200, alphaInfo_200); } } } finally { if (pool != null) pool.release(); } - return DPIUtil.autoScaleImageData (device, getImageData(), zoom, 100); + return DPIUtil.autoScaleImageData (device, getImageData(100), zoom, 100); } /** Returns the best available representation. May be 100% or 200% iff there is an image provider. */ |