LONG lDelta = SurfObj->lDelta;
byteaddr = addr;
- while(y1++ < y2)
+ while(y1++ < y2)
{
*addr = c;
if(DIB_1BPP_GetPixel(BltInfo->SourceSurface, sx, sy) == 0)
{
DIB_8BPP_PutPixel(BltInfo->DestSurface, i, j, XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, 0));
- }
- else
+ }
+ else
{
DIB_8BPP_PutPixel(BltInfo->DestSurface, i, j, XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, 1));
}
return TRUE;
}
-typedef union {
- ULONG ul;
- struct {
- UCHAR red;
- UCHAR green;
- UCHAR blue;
- UCHAR alpha;
- } col;
-} NICEPIXEL32;
-
-typedef union {
- USHORT us;
- struct {
- USHORT red:5,
- green:6,
- blue:5;
- } col;
-} NICEPIXEL16;
-
-static __inline UCHAR
-Clamp8(ULONG val)
-{
- return (val > 255) ? 255 : val;
-}
-
-BOOLEAN
-DIB_8BPP_AlphaBlend(SURFOBJ* Dest, SURFOBJ* Source, RECTL* DestRect,
- RECTL* SourceRect, CLIPOBJ* ClipRegion,
- XLATEOBJ* ColorTranslation, BLENDOBJ* BlendObj)
-{
- INT Rows, Cols, SrcX, SrcY;
- register PUCHAR Dst;
- ULONG DstDelta;
- BLENDFUNCTION BlendFunc;
- register NICEPIXEL32 DstPixel32;
- register NICEPIXEL32 SrcPixel32;
- register NICEPIXEL16 SrcPixel16;
- UCHAR Alpha, SrcBpp;
- EXLATEOBJ exloDst2Src;
- EXLATEOBJ* pexlo;
-
- DPRINT("DIB_8BPP_AlphaBlend: srcRect: (%d,%d)-(%d,%d), dstRect: (%d,%d)-(%d,%d)\n",
- 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)
- {
- DPRINT1("BlendOp != AC_SRC_OVER\n");
- return FALSE;
- }
- if (BlendFunc.BlendFlags != 0)
- {
- DPRINT1("BlendFlags != 0\n");
- return FALSE;
- }
- if ((BlendFunc.AlphaFormat & ~AC_SRC_ALPHA) != 0)
- {
- DPRINT1("Unsupported AlphaFormat (0x%x)\n", BlendFunc.AlphaFormat);
- return FALSE;
- }
- if ((BlendFunc.AlphaFormat & AC_SRC_ALPHA) != 0 &&
- BitsPerFormat(Source->iBitmapFormat) != 32)
- {
- DPRINT1("Source bitmap must be 32bpp when AC_SRC_ALPHA is set\n");
- return FALSE;
- }
- if (!ColorTranslation)
- {
- DPRINT1("ColorTranslation must not be NULL!\n");
- return FALSE;
- }
-
- pexlo = CONTAINING_RECORD(ColorTranslation, EXLATEOBJ, xlo);
- EXLATEOBJ_vInitialize(&exloDst2Src, pexlo->ppalDst, pexlo->ppalSrc, 0, 0, 0);
-
- Dst = (PUCHAR)((ULONG_PTR)Dest->pvScan0 + (DestRect->top * Dest->lDelta) +
- DestRect->left);
- DstDelta = Dest->lDelta - (DestRect->right - DestRect->left);
- SrcBpp = BitsPerFormat(Source->iBitmapFormat);
-
- Rows = DestRect->bottom - DestRect->top;
- SrcY = SourceRect->top;
- while (--Rows >= 0)
- {
- Cols = DestRect->right - DestRect->left;
- SrcX = SourceRect->left;
- while (--Cols >= 0)
- {
- if (SrcBpp <= 16)
- {
- SrcPixel16.us = DIB_GetSource(Source, SrcX++, SrcY, ColorTranslation);
- SrcPixel32.col.red = (SrcPixel16.col.red << 3) | (SrcPixel16.col.red >> 2);
- SrcPixel32.col.green = (SrcPixel16.col.green << 2) | (SrcPixel16.col.green >> 4);
- SrcPixel32.col.blue = (SrcPixel16.col.blue << 3) | (SrcPixel16.col.blue >> 2);
- }
- else
- {
- SrcPixel32.ul = DIB_GetSourceIndex(Source, SrcX++, SrcY);
- }
- SrcPixel32.col.red = SrcPixel32.col.red * BlendFunc.SourceConstantAlpha / 255;
- SrcPixel32.col.green = SrcPixel32.col.green * BlendFunc.SourceConstantAlpha / 255;
- SrcPixel32.col.blue = SrcPixel32.col.blue * BlendFunc.SourceConstantAlpha / 255;
- SrcPixel32.col.alpha = (SrcBpp == 32) ? (SrcPixel32.col.alpha * BlendFunc.SourceConstantAlpha / 255) : BlendFunc.SourceConstantAlpha;
-
- Alpha = ((BlendFunc.AlphaFormat & AC_SRC_ALPHA) != 0) ?
- SrcPixel32.col.alpha : BlendFunc.SourceConstantAlpha;
-
- DstPixel32.ul = XLATEOBJ_iXlate(&exloDst2Src.xlo, *Dst);
- SrcPixel32.col.red = Clamp8(DstPixel32.col.red * (255 - Alpha) / 255 + SrcPixel32.col.red);
- SrcPixel32.col.green = Clamp8(DstPixel32.col.green * (255 - Alpha) / 255 + SrcPixel32.col.green);
- SrcPixel32.col.blue = Clamp8(DstPixel32.col.blue * (255 - Alpha) / 255 + SrcPixel32.col.blue);
- *Dst++ = XLATEOBJ_iXlate(ColorTranslation, SrcPixel32.ul);
- }
- Dst = (PUCHAR)((ULONG_PTR)Dst + DstDelta);
- SrcY++;
- }
-
- EXLATEOBJ_vCleanup(&exloDst2Src);
-
- return TRUE;
-}
-
/* EOF */