summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelipe Heidrich <fheidric>2005-06-06 17:31:34 +0000
committerFelipe Heidrich <fheidric>2005-06-06 17:31:34 +0000
commite93f2486223e63a821959269ba87104931e85961 (patch)
tree995cd0957f1f09f5a812a5c9f8699e51d6c0bcc9
parent8c25e06efd69e55c651488a1b3273099447dfd37 (diff)
downloadeclipse.platform.swt-e93f2486223e63a821959269ba87104931e85961.tar.gz
eclipse.platform.swt-e93f2486223e63a821959269ba87104931e85961.tar.xz
eclipse.platform.swt-e93f2486223e63a821959269ba87104931e85961.zip
*** empty log message ***
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java91
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java93
2 files changed, 92 insertions, 92 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
index 75c92d7e82..207abc40c0 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
@@ -688,6 +688,97 @@ protected void create (DeviceData data) {
void createDisplay (DeviceData data) {
}
+static int create32bitDIB (int hBitmap, int alpha, byte [] alphaData, int transparentPixel) {
+ BITMAP bm = new BITMAP ();
+ OS.GetObject (hBitmap, BITMAP.sizeof, bm);
+ int imgWidth = bm.bmWidth;
+ int imgHeight = bm.bmHeight;
+ int hDC = OS.GetDC (0);
+ int srcHdc = OS.CreateCompatibleDC (hDC);
+ int oldSrcBitmap = OS.SelectObject (srcHdc, hBitmap);
+ int memHdc = OS.CreateCompatibleDC (hDC);
+ BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER ();
+ bmiHeader.biSize = BITMAPINFOHEADER.sizeof;
+ bmiHeader.biWidth = imgWidth;
+ bmiHeader.biHeight = -imgHeight;
+ bmiHeader.biPlanes = 1;
+ bmiHeader.biBitCount = (short)32;
+ bmiHeader.biCompression = OS.BI_RGB;
+ byte [] bmi = new byte [BITMAPINFOHEADER.sizeof];
+ OS.MoveMemory (bmi, bmiHeader, BITMAPINFOHEADER.sizeof);
+ int [] pBits = new int [1];
+ int memDib = OS.CreateDIBSection (0, bmi, OS.DIB_RGB_COLORS, pBits, 0, 0);
+ if (memDib == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+ int oldMemBitmap = OS.SelectObject (memHdc, memDib);
+ BITMAP dibBM = new BITMAP ();
+ OS.GetObject (memDib, BITMAP.sizeof, dibBM);
+ int sizeInBytes = dibBM.bmWidthBytes * dibBM.bmHeight;
+ OS.BitBlt (memHdc, 0, 0, imgWidth, imgHeight, srcHdc, 0, 0, OS.SRCCOPY);
+ byte red = 0, green = 0, blue = 0;
+ if (transparentPixel != -1) {
+ if (bm.bmBitsPixel <= 8) {
+ byte [] color = new byte [4];
+ OS.GetDIBColorTable (srcHdc, transparentPixel, 1, color);
+ blue = color [0];
+ green = color [1];
+ red = color [2];
+ } else {
+ switch (bm.bmBitsPixel) {
+ case 16:
+ blue = (byte)((transparentPixel & 0x1F) << 3);
+ green = (byte)((transparentPixel & 0x3E0) >> 2);
+ red = (byte)((transparentPixel & 0x7C00) >> 7);
+ break;
+ case 24:
+ blue = (byte)((transparentPixel & 0xFF0000) >> 16);
+ green = (byte)((transparentPixel & 0xFF00) >> 8);
+ red = (byte)(transparentPixel & 0xFF);
+ break;
+ case 32:
+ blue = (byte)((transparentPixel & 0xFF000000) >>> 24);
+ green = (byte)((transparentPixel & 0xFF0000) >> 16);
+ red = (byte)((transparentPixel & 0xFF00) >> 8);
+ break;
+ }
+ }
+ }
+ OS.SelectObject (srcHdc, oldSrcBitmap);
+ OS.SelectObject (memHdc, oldMemBitmap);
+ OS.DeleteObject (srcHdc);
+ OS.DeleteObject (memHdc);
+ OS.ReleaseDC (0, hDC);
+ byte [] srcData = new byte [sizeInBytes];
+ OS.MoveMemory (srcData, pBits [0], sizeInBytes);
+ if (alpha != -1) {
+ for (int y = 0, dp = 0; y < imgHeight; ++y) {
+ for (int x = 0; x < imgWidth; ++x) {
+ srcData [dp + 3] = (byte)alpha;
+ dp += 4;
+ }
+ }
+ } else if (alphaData != null) {
+ for (int y = 0, dp = 0, ap = 0; y < imgHeight; ++y) {
+ for (int x = 0; x < imgWidth; ++x) {
+ srcData [dp + 3] = alphaData [ap++];
+ dp += 4;
+ }
+ }
+ } else if (transparentPixel != -1) {
+ for (int y = 0, dp = 0; y < imgHeight; ++y) {
+ for (int x = 0; x < imgWidth; ++x) {
+ if (srcData [dp] == blue && srcData [dp + 1] == green && srcData [dp + 2] == red) {
+ srcData [dp + 3] = (byte)0;
+ } else {
+ srcData [dp + 3] = (byte)0xFF;
+ }
+ dp += 4;
+ }
+ }
+ }
+ OS.MoveMemory (pBits [0], srcData, sizeInBytes);
+ return memDib;
+}
+
static synchronized void deregister (Display display) {
for (int i=0; i<Displays.length; i++) {
if (display == Displays [i]) Displays [i] = null;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
index 146e488312..32b3d79aa1 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
@@ -132,7 +132,7 @@ void _setImage (Image image) {
} else {
if (data.alpha != -1 || data.alphaData != null || data.transparentPixel != -1) {
hasAlpha = true;
- hImage = createAlphaFromMask (image.handle, data.alpha, data.alphaData, data.transparentPixel);
+ hImage = Display.create32bitDIB (image.handle, data.alpha, data.alphaData, data.transparentPixel);
} else {
hImage = image.handle;
}
@@ -264,97 +264,6 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
return new Point (width, height);
}
-int createAlphaFromMask (int hBitmap, int alpha, byte [] alphaData, int transparentPixel) {
- BITMAP bm = new BITMAP ();
- OS.GetObject (hBitmap, BITMAP.sizeof, bm);
- int imgWidth = bm.bmWidth;
- int imgHeight = bm.bmHeight;
- int hDC = OS.GetDC (0);
- int srcHdc = OS.CreateCompatibleDC (hDC);
- int oldSrcBitmap = OS.SelectObject (srcHdc, hBitmap);
- int memHdc = OS.CreateCompatibleDC (hDC);
- BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER ();
- bmiHeader.biSize = BITMAPINFOHEADER.sizeof;
- bmiHeader.biWidth = imgWidth;
- bmiHeader.biHeight = -imgHeight;
- bmiHeader.biPlanes = 1;
- bmiHeader.biBitCount = (short)32;
- bmiHeader.biCompression = OS.BI_RGB;
- byte [] bmi = new byte [BITMAPINFOHEADER.sizeof];
- OS.MoveMemory (bmi, bmiHeader, BITMAPINFOHEADER.sizeof);
- int [] pBits = new int [1];
- int memDib = OS.CreateDIBSection (0, bmi, OS.DIB_RGB_COLORS, pBits, 0, 0);
- if (memDib == 0) SWT.error (SWT.ERROR_NO_HANDLES);
- int oldMemBitmap = OS.SelectObject (memHdc, memDib);
- BITMAP dibBM = new BITMAP ();
- OS.GetObject (memDib, BITMAP.sizeof, dibBM);
- int sizeInBytes = dibBM.bmWidthBytes * dibBM.bmHeight;
- OS.BitBlt (memHdc, 0, 0, imgWidth, imgHeight, srcHdc, 0, 0, OS.SRCCOPY);
- byte red = 0, green = 0, blue = 0;
- if (transparentPixel != -1) {
- if (bm.bmBitsPixel <= 8) {
- byte [] color = new byte [4];
- OS.GetDIBColorTable (srcHdc, transparentPixel, 1, color);
- blue = color [0];
- green = color [1];
- red = color [2];
- } else {
- switch (bm.bmBitsPixel) {
- case 16:
- blue = (byte)((transparentPixel & 0x1F) << 3);
- green = (byte)((transparentPixel & 0x3E0) >> 2);
- red = (byte)((transparentPixel & 0x7C00) >> 7);
- break;
- case 24:
- blue = (byte)((transparentPixel & 0xFF0000) >> 16);
- green = (byte)((transparentPixel & 0xFF00) >> 8);
- red = (byte)(transparentPixel & 0xFF);
- break;
- case 32:
- blue = (byte)((transparentPixel & 0xFF000000) >>> 24);
- green = (byte)((transparentPixel & 0xFF0000) >> 16);
- red = (byte)((transparentPixel & 0xFF00) >> 8);
- break;
- }
- }
- }
- OS.SelectObject (srcHdc, oldSrcBitmap);
- OS.SelectObject (memHdc, oldMemBitmap);
- OS.DeleteObject (srcHdc);
- OS.DeleteObject (memHdc);
- OS.ReleaseDC (0, hDC);
- byte [] srcData = new byte [sizeInBytes];
- OS.MoveMemory (srcData, pBits [0], sizeInBytes);
- if (alpha != -1) {
- for (int y = 0, dp = 0; y < imgHeight; ++y) {
- for (int x = 0; x < imgWidth; ++x) {
- srcData [dp + 3] = (byte)alpha;
- dp += 4;
- }
- }
- } else if (alphaData != null) {
- for (int y = 0, dp = 0, ap = 0; y < imgHeight; ++y) {
- for (int x = 0; x < imgWidth; ++x) {
- srcData [dp + 3] = alphaData [ap++];
- dp += 4;
- }
- }
- } else if (transparentPixel != -1) {
- for (int y = 0, dp = 0; y < imgHeight; ++y) {
- for (int x = 0; x < imgWidth; ++x) {
- if (srcData [dp] == blue && srcData [dp + 1] == green && srcData [dp + 2] == red) {
- srcData [dp + 3] = (byte)0;
- } else {
- srcData [dp + 3] = (byte)0xFF;
- }
- dp += 4;
- }
- }
- }
- OS.MoveMemory (pBits [0], srcData, sizeInBytes);
- return memDib;
-}
-
/**
* Returns a value which describes the position of the
* text or image in the receiver. The value will be one of