diff options
author | Felipe Heidrich <fheidric> | 2005-06-06 17:31:34 +0000 |
---|---|---|
committer | Felipe Heidrich <fheidric> | 2005-06-06 17:31:34 +0000 |
commit | e93f2486223e63a821959269ba87104931e85961 (patch) | |
tree | 995cd0957f1f09f5a812a5c9f8699e51d6c0bcc9 /bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java | |
parent | 8c25e06efd69e55c651488a1b3273099447dfd37 (diff) | |
download | eclipse.platform.swt-e93f2486223e63a821959269ba87104931e85961.tar.gz eclipse.platform.swt-e93f2486223e63a821959269ba87104931e85961.tar.xz eclipse.platform.swt-e93f2486223e63a821959269ba87104931e85961.zip |
*** empty log message ***
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java')
-rwxr-xr-x | bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java | 93 |
1 files changed, 1 insertions, 92 deletions
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 |