Alexandre Julliard julliard@winehq.org wrote:
Dmitry Timoshkov dmitry@baikal.ru writes:
+static HBITMAP create_alpha_bitmap( HBITMAP hbitmap ) +{
- HBITMAP alpha = 0;
- BITMAPINFO *info = NULL;
- BITMAP bm;
- HDC src, dst;
- void *bits;
- DWORD i;
- const unsigned char *ptr;
- BOOL has_alpha = FALSE;
- if (!GetObjectW( hbitmap, sizeof(bm), &bm )) return 0;
- if (bm.bmBitsPixel != 32) return 0;
- if (!(src = CreateCompatibleDC( 0 ))) return 0;
- if (!(dst = CreateCompatibleDC( src ))) goto done;
- if (!(info = HeapAlloc( GetProcessHeap(), 0, FIELD_OFFSET( BITMAPINFO, bmiColors[256] )))) goto done;
- info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- info->bmiHeader.biWidth = bm.bmWidth;
- info->bmiHeader.biHeight = -bm.bmHeight;
- info->bmiHeader.biPlanes = 1;
- info->bmiHeader.biBitCount = 32;
- info->bmiHeader.biCompression = BI_RGB;
- info->bmiHeader.biSizeImage = bm.bmWidth * bm.bmHeight * 4;
- info->bmiHeader.biXPelsPerMeter = 0;
- info->bmiHeader.biYPelsPerMeter = 0;
- info->bmiHeader.biClrUsed = 0;
- info->bmiHeader.biClrImportant = 0;
- if (!(alpha = CreateDIBSection( dst, info, DIB_RGB_COLORS, &bits, NULL, 0 ))) goto done;
- SelectObject( src, hbitmap );
- SelectObject( dst, alpha );
- BitBlt(dst, 0, 0, bm.bmWidth, bm.bmHeight, src, 0, 0, SRCCOPY);
BitBlt() is not guaranteed to preserve alpha, it's not the right function to use here.
I've heard that before but didn't see the reasoning, in which cases it's supposed to fail? Are you probably suggesting to use GdiAlphaBlend() or something else?
I'm using BitBlt() in all my test apps that play with alpha and I didn't see a single case where alpha is not preserved.