Revert "Bug 493455 - [win32] always treat empty images as opaque"

This reverts commit dbdc293578b21c6aa23f33d9a3175f4f457f31d0.

Reason for revert: <https://bugs.eclipse.org/bugs/show_bug.cgi?id=493455#c37>

Change-Id: I2627769324b81c5d5b6b1278556ff0c978b163e6
Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/190414
Tested-by: Niraj Modi <niraj.modi@in.ibm.com>
Reviewed-by: Niraj Modi <niraj.modi@in.ibm.com>
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 b79fe46..ac2dfaf 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,9 +1220,7 @@
 			data.hNullBitmap = 0;
 		}
 	}
-	boolean isDib = bm.bmBits != 0;
-	int depth = bm.bmPlanes * bm.bmBitsPixel;
-	if (isDib && depth == 32) {
+	if (bm.bmPlanes * bm.bmBitsPixel == 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 1b38c70..17cc993 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,9 +965,7 @@
 			BITMAP bm = new BITMAP();
 			OS.GetObject(handle, BITMAP.sizeof, bm);
 			int depth = bm.bmPlanes * bm.bmBitsPixel;
-			boolean isDib = bm.bmBits != 0;
-			boolean hasAlpha = isDib && depth == 32;
-			if (hasAlpha || transparentPixel != -1) {
+			if (depth == 32 || transparentPixel != -1) {
 				int imgWidth = bm.bmWidth;
 				int imgHeight = bm.bmHeight;
 				long hDC = device.internal_new_GC(null);
@@ -985,7 +983,7 @@
 				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 (hasAlpha) {
+				if (depth == 32) {
 					OS.MoveMemory(pixels, bm.bmBits, sizeInBytes);
 				}
 				else {
@@ -1042,7 +1040,7 @@
 				OS.DeleteObject(srcHdc);
 				OS.DeleteObject(memHdc);
 				OS.DeleteObject(memDib);
-				int pixelFormat = hasAlpha ? Gdip.PixelFormat32bppPARGB : Gdip.PixelFormat32bppARGB;
+				int pixelFormat = depth == 32 ? 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};
@@ -1608,7 +1606,7 @@
 			/* Construct and return the ImageData */
 			ImageData imageData = new ImageData(width, height, depth, palette, 4, data);
 			imageData.transparentPixel = this.transparentPixel;
-			if (isDib && depth == 32) {
+			if (depth == 32) {
 				byte straightData[] = new byte[imageSize];
 				byte alphaData[] = new byte[width * height];
 				boolean validAlpha = true;
@@ -1681,7 +1679,6 @@
 		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) {