📄 dib32bpp.c
字号:
if (! FinalCopy32(Target, ScanLine, ClipSpans, ClipSpansCount, &SpanIndex, DestY, DestRect))
{
/* No more spans, everything else is clipped away, we're done */
ExFreePool(ClipSpans);
ExFreePool(ScanLine);
ExFreePool(ScanLineAhead);
return TRUE;
}
DestY++;
Target = (PIXEL *)((BYTE *)Target + DestSurf->lDelta);
Source += IntPart;
E += FractPart;
if (E >= DestRect->bottom - DestRect->top) {
E -= DestRect->bottom - DestRect->top;
Source = (PIXEL *)((BYTE *)Source + SourceSurf->lDelta);
} /* if */
} /* while */
if (skip > 0 && Source != PrevSource)
ScaleLineAvg32(ScanLine, Source, SourceRect->right - SourceRect->left, DestRect->right - DestRect->left);
while (skip-- > 0) {
if (! FinalCopy32(Target, ScanLine, ClipSpans, ClipSpansCount, &SpanIndex, DestY, DestRect))
{
/* No more spans, everything else is clipped away, we're done */
ExFreePool(ClipSpans);
ExFreePool(ScanLine);
ExFreePool(ScanLineAhead);
return TRUE;
}
DestY++;
Target = (PIXEL *)((BYTE *)Target + DestSurf->lDelta);
} /* while */
ExFreePool(ClipSpans);
ExFreePool(ScanLine);
ExFreePool(ScanLineAhead);
return TRUE;
}
//NOTE: If you change something here, please do the same in other dibXXbpp.c files!
BOOLEAN DIB_32BPP_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 = 0;
LONG sy = 0;
LONG DesX;
LONG DesY;
PULONG DestBits;
LONG DifflDelta;
LONG SrcZoomXHight;
LONG SrcZoomXLow;
LONG SrcZoomYHight;
LONG SrcZoomYLow;
LONG sy_dec = 0;
LONG sy_max;
LONG sx_dec = 0;
LONG sx_max;
DPRINT("DIB_32BPP_StretchBlt: Source BPP: %u, srcRect: (%d,%d)-(%d,%d), dstRect: (%d,%d)-(%d,%d)\n",
BitsPerFormat(SourceSurf->iBitmapFormat), SourceRect->left, SourceRect->top, SourceRect->right,
SourceRect->bottom, DestRect->left, DestRect->top, DestRect->right, DestRect->bottom);
/* Calc the Zoom height of Source */
SrcSizeY = SourceRect->bottom - SourceRect->top;
/* Calc the Zoom Width of Source */
SrcSizeX = SourceRect->right - SourceRect->left;
/* Calc the Zoom height of Destions */
DesSizeY = DestRect->bottom - DestRect->top;
/* Calc the Zoom width of Destions */
DesSizeX = DestRect->right - DestRect->left;
/* Calc the zoom factor of soruce height */
SrcZoomYHight = SrcSizeY / DesSizeY;
SrcZoomYLow = SrcSizeY - (SrcZoomYHight * DesSizeY);
/* Calc the zoom factor of soruce width */
SrcZoomXHight = SrcSizeX / DesSizeX;
SrcZoomXLow = SrcSizeX - (SrcZoomXHight * DesSizeX);
sx_max = DesSizeX;
sy_max = DesSizeY;
sy = SourceRect->top;
DestBits = (PULONG)((PBYTE)DestSurf->pvScan0 + (DestRect->left << 2) +
DestRect->top * DestSurf->lDelta);
DifflDelta = DestSurf->lDelta - (DesSizeX << 2);
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=0; DesY<DesSizeY; DesY++)
{
sx = SourceRect->left;
sx_dec = 0;
for (DesX=0; DesX<DesSizeX; DesX++)
{
*DestBits = XLATEOBJ_iXlate(ColorTranslation,
DIB_1BPP_GetPixel(SourceSurf, sx, sy));
DestBits = (PULONG)((ULONG_PTR)DestBits + 4);
sx += SrcZoomXHight;
sx_dec += SrcZoomXLow;
if (sx_dec >= sx_max)
{
sx++;
sx_dec -= sx_max;
}
}
DestBits = (PULONG)((ULONG_PTR)DestBits + DifflDelta);
sy += SrcZoomYHight;
sy_dec += SrcZoomYLow;
if (sy_dec >= sy_max)
{
sy++;
sy_dec -= sy_max;
}
}
break;
case BMF_4BPP:
/* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
/* This is a reference implementation, it hasn't been optimized for speed */
for (DesY=0; DesY<DesSizeY; DesY++)
{
sx = SourceRect->left;
sx_dec = 0;
for (DesX=0; DesX<DesSizeX; DesX++)
{
*DestBits = XLATEOBJ_iXlate(ColorTranslation,
DIB_4BPP_GetPixel(SourceSurf, sx, sy));
DestBits = (PULONG)((ULONG_PTR)DestBits + 4);
sx += SrcZoomXHight;
sx_dec += SrcZoomXLow;
if (sx_dec >= sx_max)
{
sx++;
sx_dec -= sx_max;
}
}
DestBits = (PULONG)((ULONG_PTR)DestBits + DifflDelta);
sy += SrcZoomYHight;
sy_dec += SrcZoomYLow;
if (sy_dec >= sy_max)
{
sy++;
sy_dec -= sy_max;
}
}
break;
case BMF_8BPP:
/* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
/* This is a reference implementation, it hasn't been optimized for speed */
for (DesY=0; DesY<DesSizeY; DesY++)
{
sx = SourceRect->left;
sx_dec = 0;
for (DesX=0; DesX<DesSizeX; DesX++)
{
*DestBits = XLATEOBJ_iXlate(ColorTranslation,
DIB_8BPP_GetPixel(SourceSurf, sx, sy));
DestBits = (PULONG)((ULONG_PTR)DestBits + 4);
sx += SrcZoomXHight;
sx_dec += SrcZoomXLow;
if (sx_dec >= sx_max)
{
sx++;
sx_dec -= sx_max;
}
}
DestBits = (PULONG)((ULONG_PTR)DestBits + DifflDelta);
sy += SrcZoomYHight;
sy_dec += SrcZoomYLow;
if (sy_dec >= sy_max)
{
sy++;
sy_dec -= sy_max;
}
}
break;
case BMF_16BPP:
/* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
/* This is a reference implementation, it hasn't been optimized for speed */
for (DesY=0; DesY<DesSizeY; DesY++)
{
sx = SourceRect->left;
sx_dec = 0;
for (DesX=0; DesX<DesSizeX; DesX++)
{
*DestBits = XLATEOBJ_iXlate(ColorTranslation,
DIB_16BPP_GetPixel(SourceSurf, sx, sy));
DestBits = (PULONG)((ULONG_PTR)DestBits + 4);
sx += SrcZoomXHight;
sx_dec += SrcZoomXLow;
if (sx_dec >= sx_max)
{
sx++;
sx_dec -= sx_max;
}
}
DestBits = (PULONG)((ULONG_PTR)DestBits + DifflDelta);
sy += SrcZoomYHight;
sy_dec += SrcZoomYLow;
if (sy_dec >= sy_max)
{
sy++;
sy_dec -= sy_max;
}
}
break;
case BMF_24BPP:
/* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
/* This is a reference implementation, it hasn't been optimized for speed */
for (DesY=0; DesY<DesSizeY; DesY++)
{
sx = SourceRect->left;
sx_dec = 0;
for (DesX=0; DesX<DesSizeX; DesX++)
{
*DestBits = XLATEOBJ_iXlate(ColorTranslation,
DIB_24BPP_GetPixel(SourceSurf, sx, sy));
DestBits = (PULONG)((ULONG_PTR)DestBits + 4);
sx += SrcZoomXHight;
sx_dec += SrcZoomXLow;
if (sx_dec >= sx_max)
{
sx++;
sx_dec -= sx_max;
}
}
DestBits = (PULONG)((ULONG_PTR)DestBits + DifflDelta);
sy += SrcZoomYHight;
sy_dec += SrcZoomYLow;
if (sy_dec >= sy_max)
{
sy++;
sy_dec -= sy_max;
}
}
break;
case BMF_32BPP:
return ScaleRectAvg32(DestSurf, SourceSurf, DestRect, SourceRect, MaskOrigin, BrushOrigin,
ClipRegion, ColorTranslation, Mode);
break;
default:
//DPRINT1("DIB_32BPP_StretchBlt: Unhandled Source BPP: %u\n", BitsPerFormat(SourceSurf->iBitmapFormat));
return FALSE;
}
return TRUE;
}
BOOLEAN
DIB_32BPP_TransparentBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
RECTL* DestRect, POINTL *SourcePoint,
XLATEOBJ *ColorTranslation, ULONG iTransColor)
{
ULONG X, Y, SourceX, SourceY, Source, wd;
ULONG *DestBits;
SourceY = SourcePoint->y;
DestBits = (ULONG*)((PBYTE)DestSurf->pvScan0 +
(DestRect->left << 2) +
DestRect->top * DestSurf->lDelta);
wd = DestSurf->lDelta - ((DestRect->right - DestRect->left) << 2);
for(Y = DestRect->top; Y < DestRect->bottom; Y++)
{
SourceX = SourcePoint->x;
for(X = DestRect->left; X < DestRect->right; X++, DestBits++, SourceX++)
{
Source = DIB_GetSourceIndex(SourceSurf, SourceX, SourceY);
if(Source != iTransColor)
{
*DestBits = XLATEOBJ_iXlate(ColorTranslation, Source);
}
}
SourceY++;
DestBits = (ULONG*)((ULONG_PTR)DestBits + wd);
}
return TRUE;
}
typedef union {
ULONG ul;
struct {
UCHAR red;
UCHAR green;
UCHAR blue;
UCHAR alpha;
} col;
} NICEPIXEL32;
static __inline UCHAR
Clamp8(ULONG val)
{
return (val > 255) ? 255 : val;
}
BOOLEAN
DIB_32BPP_AlphaBlend(SURFOBJ* Dest, SURFOBJ* Source, RECTL* DestRect,
RECTL* SourceRect, CLIPOBJ* ClipRegion,
XLATEOBJ* ColorTranslation, BLENDOBJ* BlendObj)
{
INT Rows, Cols, SrcX, SrcY;
register PULONG Dst;
ULONG DstDelta;
BLENDFUNCTION BlendFunc;
register NICEPIXEL32 DstPixel, SrcPixel;
UCHAR Alpha, SrcBpp;
DPRINT("DIB_32BPP_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;
}
Dst = (PULONG)((ULONG_PTR)Dest->pvScan0 + (DestRect->top * Dest->lDelta) +
(DestRect->left << 2));
DstDelta = Dest->lDelta - ((DestRect->right - DestRect->left) << 2);
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)
{
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);
DstPixel.col.alpha = Clamp8(DstPixel.col.alpha * (255 - Alpha) / 255 + SrcPixel.col.alpha);
*Dst++ = DstPixel.ul;
}
Dst = (PULONG)((ULONG_PTR)Dst + DstDelta);
SrcY++;
}
return TRUE;
}
/* EOF */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -