diff options
author | Niraj Modi | 2022-03-11 14:50:02 +0000 |
---|---|---|
committer | Niraj Modi | 2022-03-21 14:36:18 +0000 |
commit | def5c63081058881bcce98004349276f577bd32f (patch) | |
tree | 84fa8f33f03311ee10d167cfa82b41e2335ce769 | |
parent | 22797d3f9f09ca67bfd29c864f2aaf8eb452c75c (diff) | |
download | eclipse.platform.swt-def5c63081058881bcce98004349276f577bd32f.tar.gz eclipse.platform.swt-def5c63081058881bcce98004349276f577bd32f.tar.xz eclipse.platform.swt-def5c63081058881bcce98004349276f577bd32f.zip |
Revert "Revert "Bug 493455 - [win32] always treat empty images as opaque""
This reverts commit ea4b8cc806c63249a242e661cf00aa4b9f2150cc.
Reason for revert: Considering for 4.24 M1
Change-Id: If8571d135a1fb7e2e05d60be2f470885e2e87d2c
Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/190430
Tested-by: Niraj Modi <niraj.modi@in.ibm.com>
Reviewed-by: Niraj Modi <niraj.modi@in.ibm.com>
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java | 4 | ||||
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java | 11 |
2 files changed, 10 insertions, 5 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java index ac2dfafd25..b79fe461f5 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java @@ -1220,7 +1220,9 @@ void drawBitmap(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, data.hNullBitmap = 0; } } - if (bm.bmPlanes * bm.bmBitsPixel == 32) { + boolean isDib = bm.bmBits != 0; + int depth = bm.bmPlanes * bm.bmBitsPixel; + if (isDib && depth == 32) { drawBitmapAlpha(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple); } else if (srcImage.transparentPixel != -1) { drawBitmapTransparent(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, bm, imgWidth, imgHeight); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java index 17cc99356a..1b38c70d27 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java @@ -965,7 +965,9 @@ long [] createGdipImage() { BITMAP bm = new BITMAP(); OS.GetObject(handle, BITMAP.sizeof, bm); int depth = bm.bmPlanes * bm.bmBitsPixel; - if (depth == 32 || transparentPixel != -1) { + boolean isDib = bm.bmBits != 0; + boolean hasAlpha = isDib && depth == 32; + if (hasAlpha || transparentPixel != -1) { int imgWidth = bm.bmWidth; int imgHeight = bm.bmHeight; long hDC = device.internal_new_GC(null); @@ -983,7 +985,7 @@ long [] createGdipImage() { long pixels = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, sizeInBytes); if (pixels == 0) SWT.error(SWT.ERROR_NO_HANDLES); byte red = 0, green = 0, blue = 0; - if (depth == 32) { + if (hasAlpha) { OS.MoveMemory(pixels, bm.bmBits, sizeInBytes); } else { @@ -1040,7 +1042,7 @@ long [] createGdipImage() { OS.DeleteObject(srcHdc); OS.DeleteObject(memHdc); OS.DeleteObject(memDib); - int pixelFormat = depth == 32 ? Gdip.PixelFormat32bppPARGB : Gdip.PixelFormat32bppARGB; + int pixelFormat = hasAlpha ? Gdip.PixelFormat32bppPARGB : Gdip.PixelFormat32bppARGB; return new long []{Gdip.Bitmap_new(imgWidth, imgHeight, dibBM.bmWidthBytes, pixelFormat, pixels), pixels}; } return new long []{Gdip.Bitmap_new(handle, 0), 0}; @@ -1606,7 +1608,7 @@ public ImageData getImageDataAtCurrentZoom() { /* Construct and return the ImageData */ ImageData imageData = new ImageData(width, height, depth, palette, 4, data); imageData.transparentPixel = this.transparentPixel; - if (depth == 32) { + if (isDib && depth == 32) { byte straightData[] = new byte[imageSize]; byte alphaData[] = new byte[width * height]; boolean validAlpha = true; @@ -1679,6 +1681,7 @@ void init(int width, int height) { int planes = OS.GetDeviceCaps(hDC, OS.PLANES); int depth = bits * planes; if (depth < 16) depth = 16; + if (depth > 24) depth = 24; handle = createDIB(width, height, depth); } if (handle != 0) { |