Mercurial > dwindows
diff win/dw.c @ 960:841b66d2d1b9
Added initial support for transparent pixmap/bitmaps on Windows...
without using dw_pixmap_set_transparent_color() using AlphaBlend().
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 02 May 2011 14:18:47 +0000 |
parents | 4519a1d2525e |
children | 25b24bb098fd |
line wrap: on
line diff
--- a/win/dw.c Mon May 02 05:39:37 2011 +0000 +++ b/win/dw.c Mon May 02 14:18:47 2011 +0000 @@ -8871,6 +8871,7 @@ pixmap->hdc = CreateCompatibleDC( hdc ); GetObject( pixmap->hbm, sizeof(bm), &bm ); pixmap->width = bm.bmWidth; pixmap->height = bm.bmHeight; + pixmap->depth = bm.bmBitsPixel; SelectObject( pixmap->hdc, pixmap->hbm ); ReleaseDC( handle, hdc ); free( file ); @@ -8943,6 +8944,7 @@ GetObject( pixmap->hbm, sizeof(bm), &bm ); pixmap->width = bm.bmWidth; pixmap->height = bm.bmHeight; + pixmap->depth = bm.bmBitsPixel; SelectObject( pixmap->hdc, pixmap->hbm ); @@ -8988,17 +8990,18 @@ hdc = GetDC(handle); - pixmap->hbm = LoadBitmap(DWInstance, MAKEINTRESOURCE(id)); pixmap->hdc = CreateCompatibleDC(hdc); GetObject(pixmap->hbm, sizeof(BITMAP), (void *)&bm); pixmap->width = bm.bmWidth; pixmap->height = bm.bmHeight; + pixmap->depth = bm.bmBitsPixel; SelectObject(pixmap->hdc, pixmap->hbm); ReleaseDC(handle, hdc); + pixmap->transcolor = DW_RGB_TRANSPARENT; return pixmap; } @@ -9038,6 +9041,7 @@ HDC hdcdest; HDC hdcsrc; HDC hdcMem; + static BLENDFUNCTION bf = { AC_SRC_OVER, 0, 0xFF, AC_SRC_ALPHA }; if ( dest ) hdcdest = GetDC( dest ); @@ -9052,12 +9056,20 @@ hdcsrc = srcp->hdc; else return; - if ( srcp && srcp->transcolor != DW_RGB_TRANSPARENT ) + + /* If it is a 32bpp bitmap (with alpha) use AlphaBlend unless it fails */ + if ( srcp && srcp->depth == 32 && AlphaBlend( hdcdest, xdest, ydest, width, height, hdcsrc, xsrc, ysrc, width, height, bf ) ) + { + /* Don't do anything */ + } + /* Otherwise perform special bitblt with manual transparency */ + else if ( srcp && srcp->transcolor != DW_RGB_TRANSPARENT ) { DrawTransparentBitmap( hdcdest, srcp->hdc, srcp->hbm, xdest, ydest, RGB( DW_RED_VALUE(srcp->transcolor), DW_GREEN_VALUE(srcp->transcolor), DW_BLUE_VALUE(srcp->transcolor)) ); } else { + /* Finally fall back to the classic BitBlt */ BitBlt( hdcdest, xdest, ydest, width, height, hdcsrc, xsrc, ysrc, SRCCOPY ); } if ( !destp )