changeset 962:e3425875a03a

Implemented transparent BitBlt on OS/2 using dw_pixmap_set_transparent_color() like on Windows.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 02 May 2011 17:04:58 +0000
parents 25b24bb098fd
children ea356c38f7b6
files os2/dw.c
diffstat 1 files changed, 22 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/os2/dw.c	Mon May 02 14:26:17 2011 +0000
+++ b/os2/dw.c	Mon May 02 17:04:58 2011 +0000
@@ -3574,7 +3574,7 @@
    case WM_BUTTON2DOWN:
    case WM_BUTTON3DOWN:
       if(res == -1)
-         WinSetFocus(HWND_DESKTOP, hwnd);
+		  WinSetFocus(HWND_DESKTOP, hwnd);
       else if(res)
          return (MPARAM)TRUE;
    }
@@ -8434,6 +8434,7 @@
    bmih.cBitCount = (SHORT)depth;
 
    pixmap->width = width; pixmap->height = height;
+   pixmap->transcolor = DW_CLR_DEFAULT;
 
    pixmap->hbm = GpiCreateBitmap(pixmap->hps, (PBITMAPINFOHEADER2)&bmih, 0L, NULL, NULL);
 
@@ -8488,6 +8489,7 @@
 
    /* Success fill in other values */
    pixmap->handle = handle;
+   pixmap->transcolor = DW_CLR_DEFAULT;
 
    return pixmap;
 }
@@ -8545,6 +8547,7 @@
 
    /* Success fill in other values */
    pixmap->handle = handle;
+   pixmap->transcolor = DW_CLR_DEFAULT;
 
    return pixmap;
 }
@@ -8595,6 +8598,7 @@
    GpiSetBitmap(pixmap->hps, pixmap->hbm);
 
    pixmap->width = bmih.cx; pixmap->height = bmih.cy;
+   pixmap->transcolor = DW_CLR_DEFAULT;
 
    WinReleasePS(hps);
 
@@ -8677,7 +8681,23 @@
    ptl[3].x = ptl[2].x + width;
    ptl[3].y = ptl[2].y + height;
 
-   GpiBitBlt(hpsdest, hpssrc, 4, ptl, ROP_SRCCOPY, BBO_IGNORE);
+   /* Handle transparency if requested */
+   if(srcp && srcp->transcolor != DW_CLR_DEFAULT)
+   {
+       IMAGEBUNDLE newIb, oldIb;
+       /* Transparent color is put into the background color */
+	   GpiSetBackColor(hpsdest, srcp->transcolor);
+	   GpiQueryAttrs(hpsdest, PRIM_IMAGE, IBB_BACK_MIX_MODE, (PBUNDLE)&oldIb);
+	   newIb.usBackMixMode = BM_SRCTRANSPARENT;
+	   GpiSetAttrs(hpsdest, PRIM_IMAGE, IBB_BACK_MIX_MODE, 0, (PBUNDLE)&newIb);
+	   GpiBitBlt(hpsdest, hpssrc, 4, ptl, ROP_SRCCOPY, BBO_IGNORE);
+       GpiSetAttrs(hpsdest, PRIM_IMAGE, IBB_BACK_MIX_MODE, 0, (PBUNDLE)&oldIb);
+   }
+   else
+   {
+       /* Otherwise use the regular BitBlt call */
+	   GpiBitBlt(hpsdest, hpssrc, 4, ptl, ROP_SRCCOPY, BBO_IGNORE);
+   }
 
    if(!destp)
       WinReleasePS(hpsdest);