# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1305090754 0 # Node ID 3e1c70896c13313a771bf130c038dc646dbc8a59 # Parent 751522e9f3ac1ae134da2176182b3d83b6457650 Switched to using TransparentBlt() on Windows, and allow transparent bitblt for any depths below 32bpp. Also upped the Dynamic Windows version to 2.0. diff -r 751522e9f3ac -r 3e1c70896c13 dw.h --- a/dw.h Mon May 09 14:05:52 2011 +0000 +++ b/dw.h Wed May 11 05:12:34 2011 +0000 @@ -4,8 +4,8 @@ #define _H_DW /* Dynamic Windows version numbers */ -#define DW_MAJOR_VERSION 1 -#define DW_MINOR_VERSION 1 +#define DW_MAJOR_VERSION 2 +#define DW_MINOR_VERSION 0 #define DW_SUB_VERSION 0 #if !defined(__PHOTON__) diff -r 751522e9f3ac -r 3e1c70896c13 win/dw.c --- a/win/dw.c Mon May 09 14:05:52 2011 +0000 +++ b/win/dw.c Wed May 11 05:12:34 2011 +0000 @@ -246,107 +246,6 @@ } #endif -void DrawTransparentBitmap(HDC hdc, HDC hdcSrc, HBITMAP hBitmap, int xStart, int yStart, COLORREF cTransparentColor) -{ - BITMAP bm; - COLORREF cColor; - HBITMAP bmAndBack, bmAndObject, bmAndMem, bmSave; - HBITMAP bmBackOld, bmObjectOld, bmMemOld, bmSaveOld; - HDC hdcMem, hdcBack, hdcObject, hdcTemp, hdcSave; - POINT ptSize; - -#if 0 - hdcTemp = CreateCompatibleDC(hdc); - SelectObject(hdcTemp, hBitmap); // Select the bitmap -#else - hdcTemp = hdcSrc; -#endif - - GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&bm); - ptSize.x = bm.bmWidth; // Get width of bitmap - ptSize.y = bm.bmHeight; // Get height of bitmap - DPtoLP(hdcTemp, &ptSize, 1); // Convert from device - - // to logical points - - // Create some DCs to hold temporary data. - hdcBack = CreateCompatibleDC(hdc); - hdcObject = CreateCompatibleDC(hdc); - hdcMem = CreateCompatibleDC(hdc); - hdcSave = CreateCompatibleDC(hdc); - - // Create a bitmap for each DC. DCs are required for a number of - // GDI functions. - - // Monochrome DC - bmAndBack = CreateBitmap(ptSize.x, ptSize.y, 1, 1, NULL); - - // Monochrome DC - bmAndObject = CreateBitmap(ptSize.x, ptSize.y, 1, 1, NULL); - - bmAndMem = CreateCompatibleBitmap(hdc, ptSize.x, ptSize.y); - bmSave = CreateCompatibleBitmap(hdc, ptSize.x, ptSize.y); - - // Each DC must select a bitmap object to store pixel data. - bmBackOld = (HBITMAP)SelectObject(hdcBack, bmAndBack); - bmObjectOld = (HBITMAP)SelectObject(hdcObject, bmAndObject); - bmMemOld = (HBITMAP)SelectObject(hdcMem, bmAndMem); - bmSaveOld = (HBITMAP)SelectObject(hdcSave, bmSave); - - // Set proper mapping mode. - SetMapMode(hdcTemp, GetMapMode(hdc)); - - // Save the bitmap sent here, because it will be overwritten. - BitBlt(hdcSave, 0, 0, ptSize.x, ptSize.y, hdcTemp, 0, 0, SRCCOPY); - - // Set the background color of the source DC to the color. - // contained in the parts of the bitmap that should be transparent - cColor = SetBkColor(hdcTemp, cTransparentColor); - - // Create the object mask for the bitmap by performing a BitBlt - // from the source bitmap to a monochrome bitmap. - BitBlt(hdcObject, 0, 0, ptSize.x, ptSize.y, hdcTemp, 0, 0, SRCCOPY); - - // Set the background color of the source DC back to the original - // color. - SetBkColor(hdcTemp, cColor); - - // Create the inverse of the object mask. - BitBlt(hdcBack, 0, 0, ptSize.x, ptSize.y, hdcObject, 0, 0, NOTSRCCOPY); - - // Copy the background of the main DC to the destination. - BitBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, hdc, xStart, yStart, SRCCOPY); - - // Mask out the places where the bitmap will be placed. - BitBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, hdcObject, 0, 0, SRCAND); - - // Mask out the transparent colored pixels on the bitmap. - BitBlt(hdcTemp, 0, 0, ptSize.x, ptSize.y, hdcBack, 0, 0, SRCAND); - - // XOR the bitmap with the background on the destination DC. - BitBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, hdcTemp, 0, 0, SRCPAINT); - - // Copy the destination to the screen. - BitBlt(hdc, xStart, yStart, ptSize.x, ptSize.y, hdcMem, 0, 0, - SRCCOPY); - - // Place the original bitmap back into the bitmap sent here. - BitBlt(hdcTemp, 0, 0, ptSize.x, ptSize.y, hdcSave, 0, 0, SRCCOPY); - - // Delete the memory bitmaps. - DeleteObject(SelectObject(hdcBack, bmBackOld)); - DeleteObject(SelectObject(hdcObject, bmObjectOld)); - DeleteObject(SelectObject(hdcMem, bmMemOld)); - DeleteObject(SelectObject(hdcSave, bmSaveOld)); - - // Delete the memory DCs. - DeleteDC(hdcMem); - DeleteDC(hdcBack); - DeleteDC(hdcObject); - DeleteDC(hdcSave); - DeleteDC(hdcTemp); -} - DWORD GetDllVersion(LPCTSTR lpszDllName) { @@ -8921,7 +8820,7 @@ */ void API dw_pixmap_set_transparent_color( HPIXMAP pixmap, ULONG color ) { - if ( pixmap && pixmap->depth == 8) + if ( pixmap && pixmap->depth < 32) { pixmap->transcolor = _internal_color(color); } @@ -8996,7 +8895,6 @@ { HDC hdcdest; HDC hdcsrc; - HDC hdcMem; static BLENDFUNCTION bf = { AC_SRC_OVER, 0, 0xFF, AC_SRC_ALPHA }; if ( dest ) @@ -9021,7 +8919,7 @@ /* 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)) ); + TransparentBlt( hdcdest, xdest, ydest, width, height, hdcsrc, xsrc, ysrc, width, height, RGB( DW_RED_VALUE(srcp->transcolor), DW_GREEN_VALUE(srcp->transcolor), DW_BLUE_VALUE(srcp->transcolor)) ); } else {