[PATCH](updated) wined3d: Implemented converting X1R5G5B5 format to R5G5B5A1 to emulate color-keying

hightower at tregt.net hightower at tregt.net
Mon May 21 20:32:35 CDT 2007


-------------- next part --------------
>From 94eca90bc1e16d4e2e393f29589ef037cb3ed7cd Mon Sep 17 00:00:00 2001
From: Kolbjoern Fredheim <hightower at tregt.net>
Date: Tue, 22 May 2007 03:29:44 +0200
Subject: [PATCH] wined3d: Implemented converting X1R5G5B5 format to R5G5B5A1 to emulate color-keying.

---
 dlls/wined3d/surface.c |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 12681c4..fe2fc08 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -1532,6 +1532,15 @@ static HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BO
             }
             break;
 
+        case WINED3DFMT_X1R5G5B5:
+            if (colorkey_active) {
+                *convert = CONVERT_CK_5551;
+                *format = GL_BGRA;
+                *internal = GL_RGBA;
+                *type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
+            }
+            break;
+
         case WINED3DFMT_R8G8B8:
             if (colorkey_active) {
                 *convert = CONVERT_CK_RGB24;
@@ -1720,6 +1729,32 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
         }
         break;
 
+        case CONVERT_CK_5551:
+        {
+            /* Converting X1R5G5B5 format to R5G5B5A1 to emulate color-keying. */
+            unsigned int x, y;
+            WORD *Source;
+            WORD *Dest;
+            TRACE("Color keyed 5551\n");
+            for (y = 0; y < height; y++) {
+                Source = (WORD *) (src + y * pitch);
+                Dest = (WORD *) (dst + y * outpitch);
+                for (x = 0; x < width; x++ ) {
+                    WORD color = *Source++;
+		    *Dest = color;
+                    if ((color < surf->SrcBltCKey.dwColorSpaceLowValue) ||
+                        (color > surf->SrcBltCKey.dwColorSpaceHighValue)) {
+                        *Dest |= (1 << 15);
+                    }
+                    else {
+                        *Dest &= ~(1 << 15);
+                    }
+                    Dest++;
+                }
+            }
+        }
+        break;
+
         case CONVERT_V8U8:
         {
             unsigned int x, y;
-- 
1.5.0.7


More information about the wine-patches mailing list