[YAROTOWS] Reintegrate the branch. For a brighter future.
[reactos.git] / reactos / subsystems / win32 / win32k / dib / dib24bpp.c
index 9cd846f..0642862 100644 (file)
@@ -1,24 +1,14 @@
 /*
- *  ReactOS W32 Subsystem
- *  Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * PROJECT:         Win32 subsystem
+ * LICENSE:         See COPYING in the top level directory
+ * FILE:            subsystems/win32/win32k/dib/dib24bpp.c
+ * PURPOSE:         Device Independant Bitmap functions, 24bpp
+ * PROGRAMMERS:     Jason Filby
+ *                  Thomas Bluemel
+ *                  Gregor Anich
  */
-/* $Id$ */
 
-#include <w32k.h>
+#include <win32k.h>
 
 #define NDEBUG
 #include <debug.h>
@@ -47,7 +37,8 @@ DIB_24BPP_VLine(SURFOBJ *SurfObj, LONG x, LONG y1, LONG y2, ULONG c)
   LONG lDelta = SurfObj->lDelta;
 
   c &= 0xFFFFFF;
-  while(y1++ < y2) {
+  while(y1++ < y2)
+  {
     *(PUSHORT)(addr) = c & 0xFFFF;
     *(addr + 2) = c >> 16;
 
@@ -129,7 +120,7 @@ DIB_24BPP_BitBltSrcCopy(PBLTINFO BltInfo)
           *DestBits = xColor & 0xff;
           *(PWORD)(DestBits + 1) = xColor >> 8;
           SourceBits += 1;
-         DestBits += 3;
+          DestBits += 3;
         }
 
         SourceLine += BltInfo->SourceSurface->lDelta;
@@ -162,44 +153,44 @@ DIB_24BPP_BitBltSrcCopy(PBLTINFO BltInfo)
     case BMF_24BPP:
       if (NULL == BltInfo->XlateSourceToDest || 0 != (BltInfo->XlateSourceToDest->flXlate & XO_TRIVIAL))
       {
-       if (BltInfo->DestRect.top < BltInfo->SourcePoint.y)
-         {
-           SourceBits = (PBYTE)BltInfo->SourceSurface->pvScan0 + (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) + 3 * BltInfo->SourcePoint.x;
-           for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
-             {
-               RtlMoveMemory(DestBits, SourceBits, 3 * (BltInfo->DestRect.right - BltInfo->DestRect.left));
-               SourceBits += BltInfo->SourceSurface->lDelta;
-               DestBits += BltInfo->DestSurface->lDelta;
-             }
-         }
-       else
-         {
-           SourceBits = (PBYTE)BltInfo->SourceSurface->pvScan0 + ((BltInfo->SourcePoint.y + BltInfo->DestRect.bottom - BltInfo->DestRect.top - 1) * BltInfo->SourceSurface->lDelta) + 3 * BltInfo->SourcePoint.x;
-           DestBits = (PBYTE)BltInfo->DestSurface->pvScan0 + ((BltInfo->DestRect.bottom - 1) * BltInfo->DestSurface->lDelta) + 3 * BltInfo->DestRect.left;
-           for (j = BltInfo->DestRect.bottom - 1; BltInfo->DestRect.top <= j; j--)
-             {
-               RtlMoveMemory(DestBits, SourceBits, 3 * (BltInfo->DestRect.right - BltInfo->DestRect.left));
-               SourceBits -= BltInfo->SourceSurface->lDelta;
-               DestBits -= BltInfo->DestSurface->lDelta;
-             }
-         }
+        if (BltInfo->DestRect.top < BltInfo->SourcePoint.y)
+        {
+          SourceBits = (PBYTE)BltInfo->SourceSurface->pvScan0 + (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) + 3 * BltInfo->SourcePoint.x;
+          for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
+          {
+            RtlMoveMemory(DestBits, SourceBits, 3 * (BltInfo->DestRect.right - BltInfo->DestRect.left));
+            SourceBits += BltInfo->SourceSurface->lDelta;
+            DestBits += BltInfo->DestSurface->lDelta;
+          }
+        }
+        else
+        {
+          SourceBits = (PBYTE)BltInfo->SourceSurface->pvScan0 + ((BltInfo->SourcePoint.y + BltInfo->DestRect.bottom - BltInfo->DestRect.top - 1) * BltInfo->SourceSurface->lDelta) + 3 * BltInfo->SourcePoint.x;
+          DestBits = (PBYTE)BltInfo->DestSurface->pvScan0 + ((BltInfo->DestRect.bottom - 1) * BltInfo->DestSurface->lDelta) + 3 * BltInfo->DestRect.left;
+          for (j = BltInfo->DestRect.bottom - 1; BltInfo->DestRect.top <= j; j--)
+          {
+            RtlMoveMemory(DestBits, SourceBits, 3 * (BltInfo->DestRect.right - BltInfo->DestRect.left));
+            SourceBits -= BltInfo->SourceSurface->lDelta;
+            DestBits -= BltInfo->DestSurface->lDelta;
+          }
+        }
       }
       else
       {
         sx = BltInfo->SourcePoint.x;
         sy = BltInfo->SourcePoint.y;
 
-      for (j=BltInfo->DestRect.top; j<BltInfo->DestRect.bottom; j++)
-      {
-        sx = BltInfo->SourcePoint.x;
-        for (i=BltInfo->DestRect.left; i<BltInfo->DestRect.right; i++)
+        for (j=BltInfo->DestRect.top; j<BltInfo->DestRect.bottom; j++)
         {
-           DWORD pixel = DIB_24BPP_GetPixel(BltInfo->SourceSurface, sx, sy);
-           DIB_24BPP_PutPixel(BltInfo->DestSurface, i, j, XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, pixel));
-          sx++;
+          sx = BltInfo->SourcePoint.x;
+          for (i=BltInfo->DestRect.left; i<BltInfo->DestRect.right; i++)
+          {
+            DWORD pixel = DIB_24BPP_GetPixel(BltInfo->SourceSurface, sx, sy);
+            DIB_24BPP_PutPixel(BltInfo->DestSurface, i, j, XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, pixel));
+            sx++;
+          }
+          sy++;
         }
-        sy++;
-      }
       }
       break;
 
@@ -218,7 +209,7 @@ DIB_24BPP_BitBltSrcCopy(PBLTINFO BltInfo)
           *DestBits = xColor & 0xff;
           *(PWORD)(DestBits + 1) = xColor >> 8;
           SourceBits += 4;
-         DestBits += 3;
+          DestBits += 3;
         }
 
         SourceLine += BltInfo->SourceSurface->lDelta;
@@ -258,12 +249,13 @@ DIB_24BPP_BitBlt(PBLTINFO BltInfo)
    {
       if (BltInfo->PatternSurface)
       {
-         PatternY = (BltInfo->DestRect.top + BltInfo->BrushOrigin.y) %
+         PatternY = (BltInfo->DestRect.top - BltInfo->BrushOrigin.y) %
                     BltInfo->PatternSurface->sizlBitmap.cy;
       }
       else
       {
-         Pattern = BltInfo->Brush->iSolidColor;
+         if (BltInfo->Brush)
+            Pattern = BltInfo->Brush->iSolidColor;
       }
    }
 
@@ -281,8 +273,8 @@ DIB_24BPP_BitBlt(PBLTINFO BltInfo)
          }
 
          if (BltInfo->PatternSurface)
-        {
-            Pattern = DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest);
+         {
+            Pattern = DIB_GetSourceIndex(BltInfo->PatternSurface, (DestX - BltInfo->BrushOrigin.x) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY);
          }
 
          Dest = DIB_DoRop(BltInfo->Rop4, Dest, Source, Pattern) & 0xFFFFFF;
@@ -332,17 +324,17 @@ DIB_24BPP_ColorFill(SURFOBJ* DestSurface, RECTL* DestRect, ULONG color)
           addr += 1;
         }
     }
-  else
+    else
     {
       /* Align to 4-byte address */
       while (0 != ((ULONG_PTR) addr & 0x3))
-        {
-          *(PUSHORT)(addr) = color;
-          addr += 2;
-          *(addr) = color >> 16;
-          addr += 1;
-          Count--;
-        }
+      {
+        *(PUSHORT)(addr) = color;
+        addr += 2;
+        *(addr) = color >> 16;
+        addr += 1;
+        Count--;
+      }
       /* If the color we need to fill with is 0ABC, then the final mem pattern
        * (note little-endianness) would be:
        *
@@ -383,198 +375,68 @@ DIB_24BPP_ColorFill(SURFOBJ* DestSurface, RECTL* DestRect, ULONG color)
   : "=m"(addr)
   : "m"(color), "m"(Count), "m"(addr)
   : "%eax", "%ebx", "%ecx", "%edx", "%edi");
-   Count = Count & 0x03;
+      Count = Count & 0x03;
       while (0 != Count--)
-        {
-          *(PUSHORT)(addr) = color;
-          addr += 2;
-          *(addr) = color >> 16;
-          addr += 1;
-        }
+      {
+        *(PUSHORT)(addr) = color;
+        addr += 2;
+        *(addr) = color >> 16;
+        addr += 1;
+      }
     }
   }
 #else
 
   for (DestY = DestRect->top; DestY< DestRect->bottom; DestY++)
-    {
-      DIB_24BPP_HLine(DestSurface, DestRect->left, DestRect->right, DestY, color);
-    }
+  {
+    DIB_24BPP_HLine(DestSurface, DestRect->left, DestRect->right, DestY, color);
+  }
 #endif
   return TRUE;
 }
 
-//NOTE: If you change something here, please do the same in other dibXXbpp.c files!
-BOOLEAN DIB_24BPP_StretchBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
-                            RECTL* DestRect, RECTL *SourceRect,
-                            POINTL* MaskOrigin, POINTL BrushOrigin,
-                            CLIPOBJ *ClipRegion, XLATEOBJ *ColorTranslation,
-                            ULONG Mode)
-{
-   LONG SrcSizeY;
-   LONG SrcSizeX;
-   LONG DesSizeY;
-   LONG DesSizeX;
-   LONG sx;
-   LONG sy;
-   LONG DesX;
-   LONG DesY;
-   LONG color;
-
-   SrcSizeY = SourceRect->bottom - SourceRect->top;
-   SrcSizeX = SourceRect->right - SourceRect->left;
-
-   DesSizeY = DestRect->bottom - DestRect->top;
-   DesSizeX = DestRect->right - DestRect->left;
-
-   switch(SourceSurf->iBitmapFormat)
-   {
-      case BMF_1BPP:
-         /* FIXME :  MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
-      /* This is a reference implementation, it hasn't been optimized for speed */
-
-       for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++)
-       {
-           sy = (((DesY - DestRect->top) * SrcSizeY) / DesSizeY) + SourceRect->top;
-
-            for (DesX=DestRect->left; DesX<DestRect->right; DesX++)
-            {
-                  sx = (((DesX - DestRect->left) * SrcSizeX) / DesSizeX) + SourceRect->left;
-
-                  if(DIB_1BPP_GetPixel(SourceSurf, sx, sy) == 0)
-                                 {
-                                       DIB_24BPP_PutPixel(DestSurf, DesX, DesY, XLATEOBJ_iXlate(ColorTranslation, 0));
-                  }
-                                 else
-                                 {
-                    DIB_24BPP_PutPixel(DestSurf, DesX, DesY, XLATEOBJ_iXlate(ColorTranslation, 1));
-                  }
-            }
-       }
-
-         break;
-
-      case BMF_4BPP:
-      /* FIXME :  MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
-      /* This is a reference implementation, it hasn't been optimized for speed */
-
-       for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++)
-       {
-           sy = (((DesY - DestRect->top) * SrcSizeY) / DesSizeY) + SourceRect->top;
-
-            for (DesX=DestRect->left; DesX<DestRect->right; DesX++)
-            {
-                 sx = (((DesX - DestRect->left) * SrcSizeX) / DesSizeX) + SourceRect->left;
-                 color = DIB_4BPP_GetPixel(SourceSurf, sx, sy);
-                 DIB_24BPP_PutPixel(DestSurf, DesX, DesY, XLATEOBJ_iXlate(ColorTranslation, color));
-            }
-       }
-      break;
-
-      case BMF_8BPP:
-      /* FIXME :  MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
-      /* This is a reference implementation, it hasn't been optimized for speed */
-
-       for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++)
-       {
-           sy = (((DesY - DestRect->top) * SrcSizeY) / DesSizeY) + SourceRect->top;
-
-            for (DesX=DestRect->left; DesX<DestRect->right; DesX++)
-            {
-                 sx = (((DesX - DestRect->left) * SrcSizeX) / DesSizeX) + SourceRect->left;
-                 color = DIB_8BPP_GetPixel(SourceSurf, sx, sy);
-                 DIB_24BPP_PutPixel(DestSurf, DesX, DesY, XLATEOBJ_iXlate(ColorTranslation, color));
-            }
-       }
-      break;
-
-      case BMF_16BPP:
-      /* FIXME :  MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
-      /* This is a reference implementation, it hasn't been optimized for speed */
-
-       for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++)
-       {
-           sy = (((DesY - DestRect->top) * SrcSizeY) / DesSizeY) + SourceRect->top;
-
-            for (DesX=DestRect->left; DesX<DestRect->right; DesX++)
-            {
-                 sx = (((DesX - DestRect->left) * SrcSizeX) / DesSizeX) + SourceRect->left;
-                 color = DIB_16BPP_GetPixel(SourceSurf, sx, sy);
-                 DIB_24BPP_PutPixel(DestSurf, DesX, DesY, XLATEOBJ_iXlate(ColorTranslation, color));
-            }
-       }
-      break;
-
-      case BMF_24BPP:
-      /* FIXME :  MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
-      /* This is a reference implementation, it hasn't been optimized for speed */
-
-       for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++)
-       {
-           sy = (((DesY - DestRect->top) * SrcSizeY) / DesSizeY) + SourceRect->top;
-
-            for (DesX=DestRect->left; DesX<DestRect->right; DesX++)
-            {
-                 sx = (((DesX - DestRect->left) * SrcSizeX) / DesSizeX) + SourceRect->left;
-                 color = DIB_24BPP_GetPixel(SourceSurf, sx, sy);
-                 DIB_24BPP_PutPixel(DestSurf, DesX, DesY, XLATEOBJ_iXlate(ColorTranslation, color));
-            }
-       }
-      break;
-
-      case BMF_32BPP:
-      /* FIXME :  MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
-      /* This is a reference implementation, it hasn't been optimized for speed */
-
-       for (DesY=DestRect->top; DesY<DestRect->bottom; DesY++)
-       {
-           sy = (((DesY - DestRect->top) * SrcSizeY) / DesSizeY) + SourceRect->top;
-
-            for (DesX=DestRect->left; DesX<DestRect->right; DesX++)
-            {
-                 sx = (((DesX - DestRect->left) * SrcSizeX) / DesSizeX) + SourceRect->left;
-                 color = DIB_32BPP_GetPixel(SourceSurf, sx, sy);
-                 DIB_24BPP_PutPixel(DestSurf, DesX, DesY, XLATEOBJ_iXlate(ColorTranslation, color));
-            }
-       }
-      break;
-
-      default:
-      //DPRINT1("DIB_24BPP_StretchBlt: Unhandled Source BPP: %u\n", BitsPerFormat(SourceSurf->iBitmapFormat));
-      return FALSE;
-    }
-
-  return TRUE;
-}
-
 BOOLEAN
 DIB_24BPP_TransparentBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
-                         RECTL*  DestRect,  POINTL  *SourcePoint,
+                         RECTL*  DestRect,  RECTL *SourceRect,
                          XLATEOBJ *ColorTranslation, ULONG iTransColor)
 {
-  ULONG X, Y, SourceX, SourceY, Source, wd, Dest;
+  ULONG X, Y, SourceX, SourceY = 0, Source = 0, wd, Dest;
   BYTE *DestBits;
 
-  SourceY = SourcePoint->y;
+  LONG DstHeight;
+  LONG DstWidth;
+  LONG SrcHeight;
+  LONG SrcWidth;
+
+  DstHeight = DestRect->bottom - DestRect->top;
+  DstWidth = DestRect->right - DestRect->left;
+  SrcHeight = SourceRect->bottom - SourceRect->top;
+  SrcWidth = SourceRect->right - SourceRect->left;
+
   DestBits = (BYTE*)((PBYTE)DestSurf->pvScan0 +
-                      (DestRect->left << 2) +
+                      (DestRect->left * 3) +
                       DestRect->top * DestSurf->lDelta);
-  wd = DestSurf->lDelta - ((DestRect->right - DestRect->left) << 2);
+  wd = DestSurf->lDelta - ((DestRect->right - DestRect->left) * 3);
 
   for(Y = DestRect->top; Y < DestRect->bottom; Y++)
   {
-    SourceX = SourcePoint->x;
-    for(X = DestRect->left; X < DestRect->right; X++, DestBits += 3, SourceX++)
+    SourceY = SourceRect->top+(Y - DestRect->top) * SrcHeight / DstHeight;
+    for(X = DestRect->left; X < DestRect->right; X++, DestBits += 3)
     {
-      Source = DIB_GetSourceIndex(SourceSurf, SourceX, SourceY);
-      if(Source != iTransColor)
+      SourceX = SourceRect->left+(X - DestRect->left) * SrcWidth / DstWidth;
+      if (SourceX >= 0 && SourceY >= 0 &&
+          SourceSurf->sizlBitmap.cx > SourceX && SourceSurf->sizlBitmap.cy > SourceY)
       {
-        Dest = XLATEOBJ_iXlate(ColorTranslation, Source) & 0xFFFFFF;
-         *(PUSHORT)(DestBits) = Dest & 0xFFFF;
-         *(DestBits + 2) = Dest >> 16;
+        Source = DIB_GetSourceIndex(SourceSurf, SourceX, SourceY);
+        if(Source != iTransColor)
+        {
+          Dest = XLATEOBJ_iXlate(ColorTranslation, Source) & 0xFFFFFF;
+           *(PUSHORT)(DestBits) = Dest & 0xFFFF;
+           *(DestBits + 2) = Dest >> 16;
+        }
       }
     }
 
-    SourceY++;
     DestBits = (BYTE*)((ULONG_PTR)DestBits + wd);
   }
 
@@ -604,7 +466,6 @@ DIB_24BPP_AlphaBlend(SURFOBJ* Dest, SURFOBJ* Source, RECTL* DestRect,
 {
    INT Rows, Cols, SrcX, SrcY;
    register PUCHAR Dst;
-   ULONG DstDelta;
    BLENDFUNCTION BlendFunc;
    register NICEPIXEL32 DstPixel, SrcPixel;
    UCHAR Alpha, SrcBpp;
@@ -613,9 +474,6 @@ DIB_24BPP_AlphaBlend(SURFOBJ* Dest, SURFOBJ* Source, RECTL* DestRect,
           SourceRect->left, SourceRect->top, SourceRect->right, SourceRect->bottom,
           DestRect->left, DestRect->top, DestRect->right, DestRect->bottom);
 
-   ASSERT(DestRect->bottom - DestRect->top == SourceRect->bottom - SourceRect->top &&
-          DestRect->right - DestRect->left == SourceRect->right - SourceRect->left);
-
    BlendFunc = BlendObj->BlendFunction;
    if (BlendFunc.BlendOp != AC_SRC_OVER)
    {
@@ -641,36 +499,41 @@ DIB_24BPP_AlphaBlend(SURFOBJ* Dest, SURFOBJ* Source, RECTL* DestRect,
 
    Dst = (PUCHAR)((ULONG_PTR)Dest->pvScan0 + (DestRect->top * Dest->lDelta) +
                              (DestRect->left * 3));
-   DstDelta = Dest->lDelta - ((DestRect->right - DestRect->left) * 3);
    SrcBpp = BitsPerFormat(Source->iBitmapFormat);
 
-   Rows = DestRect->bottom - DestRect->top;
+   Rows = 0;
    SrcY = SourceRect->top;
-   while (--Rows >= 0)
-   {
-      Cols = DestRect->right - DestRect->left;
-      SrcX = SourceRect->left;
-      while (--Cols >= 0)
+   while (++Rows <= DestRect->bottom - DestRect->top)
+  {
+    Cols = 0;
+    SrcX = SourceRect->left;
+    while (++Cols <= DestRect->right - DestRect->left)
+    {
+      SrcPixel.ul = DIB_GetSource(Source, SrcX, SrcY, ColorTranslation);
+      SrcPixel.col.red = (SrcPixel.col.red * BlendFunc.SourceConstantAlpha) / 255;
+      SrcPixel.col.green = (SrcPixel.col.green * BlendFunc.SourceConstantAlpha) / 255;
+      SrcPixel.col.blue = (SrcPixel.col.blue * BlendFunc.SourceConstantAlpha) / 255;
+      if (!(BlendFunc.AlphaFormat & AC_SRC_ALPHA))
       {
-         SrcPixel.ul = DIB_GetSource(Source, SrcX++, SrcY, ColorTranslation);
-         SrcPixel.col.red = SrcPixel.col.red * BlendFunc.SourceConstantAlpha / 255;
-         SrcPixel.col.green = SrcPixel.col.green * BlendFunc.SourceConstantAlpha / 255;
-         SrcPixel.col.blue = SrcPixel.col.blue * BlendFunc.SourceConstantAlpha / 255;
-         SrcPixel.col.alpha = (SrcBpp == 32) ? (SrcPixel.col.alpha * BlendFunc.SourceConstantAlpha / 255) : BlendFunc.SourceConstantAlpha;
-
-         Alpha = ((BlendFunc.AlphaFormat & AC_SRC_ALPHA) != 0) ?
-                 SrcPixel.col.alpha : BlendFunc.SourceConstantAlpha;
-
-         DstPixel.ul = *Dst;
-         DstPixel.col.red = Clamp8(DstPixel.col.red * (255 - Alpha) / 255 + SrcPixel.col.red);
-         DstPixel.col.green = Clamp8(DstPixel.col.green * (255 - Alpha) / 255 + SrcPixel.col.green);
-         DstPixel.col.blue = Clamp8(DstPixel.col.blue * (255 - Alpha) / 255 + SrcPixel.col.blue);
-         *Dst = DstPixel.ul;
-         Dst = (PUCHAR)((ULONG_PTR)Dst + 3);
+          Alpha = BlendFunc.SourceConstantAlpha ;
       }
-      Dst = (PUCHAR)((ULONG_PTR)Dst + DstDelta);
-      SrcY++;
-   }
+      else
+      {
+        Alpha = (SrcPixel.col.alpha * BlendFunc.SourceConstantAlpha) / 255;
+      }
+
+      DstPixel.col.red = Clamp8((*Dst * (255 - Alpha)) / 255 + SrcPixel.col.red) ;
+      DstPixel.col.green = Clamp8((*(Dst+1) * (255 - Alpha) / 255 + SrcPixel.col.green)) ;
+      DstPixel.col.blue = Clamp8((*(Dst+2) * (255 - Alpha)) / 255 + SrcPixel.col.blue) ;
+      *Dst++ = DstPixel.col.red;
+      *Dst++ = DstPixel.col.green;
+      *Dst++ = DstPixel.col.blue;
+      SrcX = SourceRect->left + (Cols*(SourceRect->right - SourceRect->left))/(DestRect->right - DestRect->left);
+    }
+    Dst = (PUCHAR)((ULONG_PTR)Dest->pvScan0 + ((DestRect->top + Rows) * Dest->lDelta) +
+                (DestRect->left*3));
+    SrcY = SourceRect->top + (Rows*(SourceRect->bottom - SourceRect->top))/(DestRect->bottom - DestRect->top);
+  }
 
    return TRUE;
 }