[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wine-devel
Subject:    TransparentBlt
From:       Kevin Koltzau <kevin () plop ! org>
Date:       2004-01-31 5:48:08
Message-ID: 200401310048.08827.kevin () plop ! org
[Download RAW message or body]

Implementation of TransparentBlt

This brings up an interesting thing however..it works perfectly under windows (tested \
on XP), but produces strange results under wine. MaskBlt seems to be broken, but I'm \
not quite sure what the cause is yet I figured I'd send this out incase the problem \
is obvious to anyone


["transparentblt.diff" (text/x-diff)]

Index: dlls/msimg32/Makefile.in
===================================================================
RCS file: /home/wine/wine/dlls/msimg32/Makefile.in,v
retrieving revision 1.7
diff -u -r1.7 Makefile.in
--- dlls/msimg32/Makefile.in	11 Oct 2003 01:09:18 -0000	1.7
+++ dlls/msimg32/Makefile.in	31 Jan 2004 05:37:08 -0000
@@ -3,7 +3,7 @@
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = msimg32.dll
-IMPORTS   = kernel32
+IMPORTS   = gdi32 kernel32

 C_SRCS = msimg32_main.c

Index: dlls/msimg32/msimg32_main.c
===================================================================
RCS file: /home/wine/wine/dlls/msimg32/msimg32_main.c,v
retrieving revision 1.7
diff -u -r1.7 msimg32_main.c
--- dlls/msimg32/msimg32_main.c	5 Sep 2003 23:08:35 -0000	1.7
+++ dlls/msimg32/msimg32_main.c	31 Jan 2004 05:37:08 -0000
@@ -1,5 +1,6 @@
 /*
  * Copyright 2002 Uwe Bonnes
+ * Copyright (C) 2004 Kevin Koltzau
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -42,13 +43,65 @@
 /******************************************************************************
  *           TransparentBlt   (MSIMG32.@)
  */
-BOOL WINAPI TransparentBlt( HDC hdcDest, int xDest, int yDest, int widthDest, int \
heightDst, +BOOL WINAPI TransparentBlt( HDC hdcDest, int xDest, int yDest, int \
                widthDest, int heightDest,
                             HDC hdcSrc, int xSrc, int ySrc, int widthSrc, int \
heightSrc,  UINT crTransparent )
 {
-    FIXME("stub: TransparentBlt from %p to %p\n", hdcSrc, hdcDest );
-    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-    return FALSE;
+    BOOL ret = FALSE;
+    HDC hdcWork;
+    HBITMAP bmpWork;
+    HGDIOBJ oldWork;
+    HDC hdcMask = NULL;
+    HBITMAP bmpMask = NULL;
+    HGDIOBJ oldMask = NULL;
+    int oldStretchMode;
+
+    if(widthDest < 0 || heightDest < 0 || widthSrc < 0 || heightSrc < 0) {
+        TRACE("Can not mirror\n");
+        return FALSE;
+    }
+
+    /* Stretch bitmap */
+    oldStretchMode = GetStretchBltMode(hdcSrc);
+    if(oldStretchMode == BLACKONWHITE || oldStretchMode == WHITEONBLACK)
+        SetStretchBltMode(hdcSrc, COLORONCOLOR);
+    hdcWork = CreateCompatibleDC(hdcDest);
+    bmpWork = CreateCompatibleBitmap(hdcDest, widthDest, heightDest);
+    oldWork = SelectObject(hdcWork, bmpWork);
+    if(!StretchBlt(hdcWork, 0, 0, widthDest, heightDest, hdcSrc, xSrc, ySrc, \
widthSrc, heightSrc, SRCCOPY)) { +        TRACE("Failed to stretch\n");
+        goto error;
+    }
+    SetBkColor(hdcWork, crTransparent);
+
+    /* Create mask */
+    hdcMask = CreateCompatibleDC(hdcDest);
+    bmpMask = CreateCompatibleBitmap(hdcMask, widthDest, heightDest);
+    oldMask = (HBITMAP)SelectObject(hdcMask, bmpMask);
+    if(!BitBlt(hdcMask, 0, 0, widthDest, heightDest, hdcWork, 0, 0, NOTSRCCOPY)) {
+        TRACE("Failed to create mask\n");
+        goto error;
+    }
+
+    if(!MaskBlt(hdcDest, xDest, yDest, widthDest, heightDest, hdcWork, 0, 0, \
bmpMask, 0, 0, MAKEROP4(SRCCOPY,0x00AA0029))) { +        TRACE("Failed to blt\n");
+        goto error;
+    }
+
+    ret = TRUE;
+error:
+    SetStretchBltMode(hdcSrc, oldStretchMode);
+    if(hdcWork) {
+        SelectObject(hdcWork, oldWork);
+        DeleteDC(hdcWork);
+    }
+    if(bmpWork) DeleteObject(bmpWork);
+    if(hdcMask) {
+        SelectObject(hdcMask, oldMask);
+        DeleteDC(hdcMask);
+    }
+    if(bmpMask) DeleteObject(bmpMask);
+    return ret;
 }


Index: include/wingdi.h
===================================================================
RCS file: /home/wine/wine/include/wingdi.h,v
retrieving revision 1.100
diff -u -r1.100 wingdi.h
--- include/wingdi.h	13 Jan 2004 05:20:17 -0000	1.100
+++ include/wingdi.h	31 Jan 2004 05:37:11 -0000
@@ -386,6 +386,8 @@
 #define R2_MERGEPEN     15
 #define R2_WHITE        16

+#define MAKEROP4(fore,back) (DWORD)((((back)<< 8)&0xFF000000)|(fore))
+
 #define SRCCOPY         0xcc0020
 #define SRCPAINT        0xee0086
 #define SRCAND          0x8800c6



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic