mirror of
https://github.com/reactos/reactos.git
synced 2024-08-03 01:50:57 +00:00
Remove dead StretchBlt code
svn path=/trunk/; revision=39241
This commit is contained in:
parent
2ab5d20abb
commit
3c8f0a1df6
|
@ -452,377 +452,6 @@ DIB_16BPP_ColorFill(SURFOBJ* DestSurface, RECTL* DestRect, ULONG color)
|
|||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
/*
|
||||
=======================================
|
||||
Stretching functions goes below
|
||||
Some parts of code are based on an
|
||||
article "Bresenhame image scaling"
|
||||
Dr. Dobb Journal, May 2002
|
||||
=======================================
|
||||
*/
|
||||
|
||||
typedef unsigned short PIXEL;
|
||||
|
||||
/* 16-bit HiColor (565 format) */
|
||||
__inline PIXEL average16(PIXEL a, PIXEL b)
|
||||
{
|
||||
// This one should be correct, but it's too long
|
||||
/*
|
||||
unsigned char r1, g1, b1, r2, g2, b2, rr, gr, br;
|
||||
unsigned short res;
|
||||
|
||||
r1 = (a & 0xF800) >> 11;
|
||||
g1 = (a & 0x7E0) >> 5;
|
||||
b1 = (a & 0x1F);
|
||||
|
||||
r2 = (b & 0xF800) >> 11;
|
||||
g2 = (b & 0x7E0) >> 5;
|
||||
b2 = (b & 0x1F);
|
||||
|
||||
rr = (r1+r2) / 2;
|
||||
gr = (g1+g2) / 2;
|
||||
br = (b1+b2) / 2;
|
||||
|
||||
res = (rr << 11) + (gr << 5) + br;
|
||||
|
||||
return res;
|
||||
*/
|
||||
// This one is the short form of the correct one, but does not work for QEMU (expects 555 format)
|
||||
//return (((a ^ b) & 0xf7deU) >> 1) + (a & b);
|
||||
|
||||
//hack until short version works properly
|
||||
return a;
|
||||
}
|
||||
|
||||
//NOTE: If you change something here, please do the same in other dibXXbpp.c files!
|
||||
void ScaleLineAvg16(PIXEL *Target, PIXEL *Source, int SrcWidth, int TgtWidth)
|
||||
{
|
||||
int NumPixels = TgtWidth;
|
||||
int IntPart = SrcWidth / TgtWidth;
|
||||
int FractPart = SrcWidth % TgtWidth;
|
||||
int Mid = TgtWidth >> 1;
|
||||
int E = 0;
|
||||
int skip;
|
||||
PIXEL p;
|
||||
|
||||
skip = (TgtWidth < SrcWidth) ? 0 : (TgtWidth / (2*SrcWidth) + 1);
|
||||
NumPixels -= skip;
|
||||
|
||||
while (NumPixels-- > 0)
|
||||
{
|
||||
p = *Source;
|
||||
if (E >= Mid)
|
||||
{
|
||||
p = average16(p, *(Source+1));
|
||||
}
|
||||
*Target++ = p;
|
||||
Source += IntPart;
|
||||
E += FractPart;
|
||||
if (E >= TgtWidth)
|
||||
{
|
||||
E -= TgtWidth;
|
||||
Source++;
|
||||
}
|
||||
}
|
||||
while (skip-- > 0)
|
||||
{
|
||||
*Target++ = *Source;
|
||||
}
|
||||
}
|
||||
|
||||
static BOOLEAN
|
||||
FinalCopy16(PIXEL *Target, PIXEL *Source, PSPAN ClipSpans, UINT ClipSpansCount, UINT *SpanIndex,
|
||||
UINT DestY, RECTL *DestRect)
|
||||
{
|
||||
LONG Left, Right;
|
||||
|
||||
while ( ClipSpans[*SpanIndex].Y < DestY ||
|
||||
(ClipSpans[*SpanIndex].Y == DestY &&
|
||||
ClipSpans[*SpanIndex].X + ClipSpans[*SpanIndex].Width < DestRect->left))
|
||||
{
|
||||
(*SpanIndex)++;
|
||||
if (ClipSpansCount <= *SpanIndex)
|
||||
{
|
||||
/* No more spans, everything else is clipped away, we're done */
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
while (ClipSpans[*SpanIndex].Y == DestY)
|
||||
{
|
||||
if (ClipSpans[*SpanIndex].X < DestRect->right)
|
||||
{
|
||||
Left = max(ClipSpans[*SpanIndex].X, DestRect->left);
|
||||
|
||||
Right = min(ClipSpans[*SpanIndex].X + ClipSpans[*SpanIndex].Width,
|
||||
DestRect->right);
|
||||
|
||||
memcpy(Target + Left - DestRect->left, Source + Left - DestRect->left,
|
||||
(Right - Left) * sizeof(PIXEL));
|
||||
}
|
||||
|
||||
(*SpanIndex)++;
|
||||
|
||||
if (ClipSpansCount <= *SpanIndex)
|
||||
{
|
||||
/* No more spans, everything else is clipped away, we're done */
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//NOTE: If you change something here, please do the same in other dibXXbpp.c files!
|
||||
BOOLEAN ScaleRectAvg16(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
|
||||
RECTL* DestRect, RECTL *SourceRect,
|
||||
POINTL* MaskOrigin, POINTL BrushOrigin,
|
||||
CLIPOBJ *ClipRegion, XLATEOBJ *ColorTranslation,
|
||||
ULONG Mode)
|
||||
{
|
||||
int NumPixels = DestRect->bottom - DestRect->top;
|
||||
|
||||
int IntPart = (((SourceRect->bottom - SourceRect->top) /
|
||||
(DestRect->bottom - DestRect->top)) * SourceSurf->lDelta) >> 1;
|
||||
|
||||
int FractPart = (SourceRect->bottom - SourceRect->top) %
|
||||
(DestRect->bottom - DestRect->top);
|
||||
|
||||
int Mid = (DestRect->bottom - DestRect->top) >> 1;
|
||||
int E = 0;
|
||||
int skip;
|
||||
PIXEL *ScanLine, *ScanLineAhead;
|
||||
PIXEL *PrevSource = NULL;
|
||||
PIXEL *PrevSourceAhead = NULL;
|
||||
|
||||
PIXEL *Target = (PIXEL *) ((PBYTE)DestSurf->pvScan0 + (DestRect->top *
|
||||
DestSurf->lDelta) + 2 * DestRect->left);
|
||||
|
||||
PIXEL *Source = (PIXEL *) ((PBYTE)SourceSurf->pvScan0 + (SourceRect->top *
|
||||
SourceSurf->lDelta) + 2 * SourceRect->left);
|
||||
|
||||
PSPAN ClipSpans;
|
||||
UINT ClipSpansCount;
|
||||
UINT SpanIndex;
|
||||
LONG DestY;
|
||||
|
||||
if (! ClipobjToSpans(&ClipSpans, &ClipSpansCount, ClipRegion, DestRect))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (0 == ClipSpansCount)
|
||||
{
|
||||
/* No clip spans == empty clipping region, everything clipped away */
|
||||
ASSERT(NULL == ClipSpans);
|
||||
return TRUE;
|
||||
}
|
||||
skip = (DestRect->bottom - DestRect->top < SourceRect->bottom - SourceRect->top)
|
||||
? 0 : ((DestRect->bottom - DestRect->top) /
|
||||
(2 * (SourceRect->bottom - SourceRect->top)) + 1);
|
||||
|
||||
NumPixels -= skip;
|
||||
|
||||
ScanLine = (PIXEL*)ExAllocatePool(PagedPool, (DestRect->right - DestRect->left) *
|
||||
sizeof(PIXEL));
|
||||
|
||||
ScanLineAhead = (PIXEL *)ExAllocatePool(PagedPool, (DestRect->right -
|
||||
DestRect->left) * sizeof(PIXEL));
|
||||
|
||||
if (!ScanLine || !ScanLineAhead)
|
||||
{
|
||||
if (ScanLine) ExFreePool(ScanLine);
|
||||
if (ScanLineAhead) ExFreePool(ScanLineAhead);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DestY = DestRect->top;
|
||||
SpanIndex = 0;
|
||||
while (NumPixels-- > 0)
|
||||
{
|
||||
if (Source != PrevSource)
|
||||
{
|
||||
if (Source == PrevSourceAhead)
|
||||
{
|
||||
/* the next scan line has already been scaled and stored in
|
||||
* ScanLineAhead; swap the buffers that ScanLine and ScanLineAhead
|
||||
* point to
|
||||
*/
|
||||
PIXEL *tmp = ScanLine;
|
||||
ScanLine = ScanLineAhead;
|
||||
ScanLineAhead = tmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
ScaleLineAvg16(ScanLine, Source, SourceRect->right - SourceRect->left,
|
||||
DestRect->right - DestRect->left);
|
||||
}
|
||||
PrevSource = Source;
|
||||
}
|
||||
|
||||
if (E >= Mid && PrevSourceAhead != (PIXEL *)((BYTE *)Source +
|
||||
SourceSurf->lDelta))
|
||||
{
|
||||
int x;
|
||||
|
||||
ScaleLineAvg16(ScanLineAhead, (PIXEL *)((BYTE *)Source +
|
||||
SourceSurf->lDelta), SourceRect->right -
|
||||
SourceRect->left, DestRect->right - DestRect->left);
|
||||
|
||||
for (x = 0; x < DestRect->right - DestRect->left; x++)
|
||||
{
|
||||
ScanLine[x] = average16(ScanLine[x], ScanLineAhead[x]);
|
||||
}
|
||||
|
||||
PrevSourceAhead = (PIXEL *)((BYTE *)Source + SourceSurf->lDelta);
|
||||
}
|
||||
|
||||
if (! FinalCopy16(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);
|
||||
}
|
||||
} /* while */
|
||||
|
||||
if (skip > 0 && Source != PrevSource)
|
||||
{
|
||||
ScaleLineAvg16(ScanLine, Source, SourceRect->right - SourceRect->left,
|
||||
DestRect->right - DestRect->left);
|
||||
}
|
||||
|
||||
while (skip-- > 0)
|
||||
{
|
||||
if (! FinalCopy16(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);
|
||||
}
|
||||
|
||||
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_16BPP_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;
|
||||
|
||||
LONG SrcZoomXHight;
|
||||
LONG SrcZoomXLow;
|
||||
LONG SrcZoomYHight;
|
||||
LONG SrcZoomYLow;
|
||||
|
||||
LONG sy_dec = 0;
|
||||
LONG sy_max;
|
||||
|
||||
LONG sx_dec = 0;
|
||||
LONG sx_max;
|
||||
ULONG color;
|
||||
|
||||
DPRINT("DIB_16BPP_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 Destinations */
|
||||
DesSizeY = DestRect->bottom - DestRect->top;
|
||||
|
||||
/* Calc the Zoom width of Destinations */
|
||||
DesSizeX = DestRect->right - DestRect->left;
|
||||
|
||||
/* Calc the zoom factor of source height */
|
||||
SrcZoomYHight = SrcSizeY / DesSizeY;
|
||||
SrcZoomYLow = SrcSizeY - (SrcZoomYHight * DesSizeY);
|
||||
|
||||
/* Calc the zoom factor of source width */
|
||||
SrcZoomXHight = SrcSizeX / DesSizeX;
|
||||
SrcZoomXLow = SrcSizeX - (SrcZoomXHight * DesSizeX);
|
||||
|
||||
sx_max = DesSizeX;
|
||||
sy_max = DesSizeY;
|
||||
sy = SourceRect->top;
|
||||
|
||||
if (SourceSurf->iBitmapFormat != 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++)
|
||||
{
|
||||
sx = SourceRect->left;
|
||||
sx_dec = 0;
|
||||
|
||||
for (DesX=DestRect->left; DesX<DestRect->right; DesX++)
|
||||
{
|
||||
color = XLATEOBJ_iXlate(ColorTranslation,
|
||||
DibFunctionsForBitmapFormat[SourceSurf->iBitmapFormat].
|
||||
DIB_GetPixel(SourceSurf, sx, sy));
|
||||
|
||||
DIB_16BPP_PutPixel(DestSurf, DesX, DesY, color);
|
||||
|
||||
sx += SrcZoomXHight;
|
||||
sx_dec += SrcZoomXLow;
|
||||
if (sx_dec >= sx_max)
|
||||
{
|
||||
sx++;
|
||||
sx_dec -= sx_max;
|
||||
}
|
||||
}
|
||||
|
||||
sy += SrcZoomYHight;
|
||||
sy_dec += SrcZoomYLow;
|
||||
if (sy_dec >= sy_max)
|
||||
{
|
||||
sy++;
|
||||
sy_dec -= sy_max;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return ScaleRectAvg16(DestSurf, SourceSurf, DestRect, SourceRect, MaskOrigin, BrushOrigin,
|
||||
ClipRegion, ColorTranslation, Mode);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
DIB_16BPP_TransparentBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
|
||||
|
|
|
@ -492,47 +492,6 @@ DIB_1BPP_ColorFill(SURFOBJ* DestSurface, RECTL* DestRect, ULONG color)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
//NOTE: If you change something here, please do the same in other dibXXbpp.c files!
|
||||
|
||||
BOOLEAN DIB_1BPP_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;
|
||||
|
||||
/* 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 = DibFunctionsForBitmapFormat[SourceSurf->iBitmapFormat].
|
||||
DIB_GetPixel(SourceSurf, sx, sy);
|
||||
DIB_1BPP_PutPixel(DestSurf, DesX, DesY, XLATEOBJ_iXlate(ColorTranslation, color));
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
DIB_1BPP_TransparentBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
|
||||
RECTL* DestRect, POINTL *SourcePoint,
|
||||
|
|
|
@ -403,97 +403,6 @@ DIB_24BPP_ColorFill(SURFOBJ* DestSurface, RECTL* DestRect, ULONG color)
|
|||
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 = 0;
|
||||
LONG sy = 0;
|
||||
LONG DesX;
|
||||
LONG DesY;
|
||||
|
||||
LONG SrcZoomXHight;
|
||||
LONG SrcZoomXLow;
|
||||
LONG SrcZoomYHight;
|
||||
LONG SrcZoomYLow;
|
||||
|
||||
LONG sy_dec = 0;
|
||||
LONG sy_max;
|
||||
|
||||
LONG sx_dec = 0;
|
||||
LONG sx_max;
|
||||
ULONG color;
|
||||
|
||||
DPRINT("DIB_24BPP_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 Destinations */
|
||||
DesSizeY = DestRect->bottom - DestRect->top;
|
||||
|
||||
/* Calc the Zoom width of Destinations */
|
||||
DesSizeX = DestRect->right - DestRect->left;
|
||||
|
||||
/* Calc the zoom factor of source height */
|
||||
SrcZoomYHight = SrcSizeY / DesSizeY;
|
||||
SrcZoomYLow = SrcSizeY - (SrcZoomYHight * DesSizeY);
|
||||
|
||||
/* Calc the zoom factor of source width */
|
||||
SrcZoomXHight = SrcSizeX / DesSizeX;
|
||||
SrcZoomXLow = SrcSizeX - (SrcZoomXHight * DesSizeX);
|
||||
|
||||
sx_max = DesSizeX;
|
||||
sy_max = DesSizeY;
|
||||
sy = SourceRect->top;
|
||||
|
||||
/* 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++)
|
||||
{
|
||||
sx = SourceRect->left;
|
||||
sx_dec = 0;
|
||||
|
||||
for (DesX=DestRect->left; DesX<DestRect->right; DesX++)
|
||||
{
|
||||
color = XLATEOBJ_iXlate(ColorTranslation,
|
||||
DibFunctionsForBitmapFormat[SourceSurf->iBitmapFormat].
|
||||
DIB_GetPixel(SourceSurf, sx, sy));
|
||||
|
||||
DIB_24BPP_PutPixel(DestSurf, DesX, DesY, color);
|
||||
|
||||
sx += SrcZoomXHight;
|
||||
sx_dec += SrcZoomXLow;
|
||||
if (sx_dec >= sx_max)
|
||||
{
|
||||
sx++;
|
||||
sx_dec -= sx_max;
|
||||
}
|
||||
}
|
||||
|
||||
sy += SrcZoomYHight;
|
||||
sy_dec += SrcZoomYLow;
|
||||
if (sy_dec >= sy_max)
|
||||
{
|
||||
sy++;
|
||||
sy_dec -= sy_max;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
DIB_24BPP_TransparentBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
|
||||
RECTL* DestRect, POINTL *SourcePoint,
|
||||
|
|
|
@ -277,312 +277,6 @@ DIB_32BPP_BitBltSrcCopy(PBLTINFO BltInfo)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=======================================
|
||||
Stretching functions goes below
|
||||
Some parts of code are based on an
|
||||
article "Bresenhame image scaling"
|
||||
Dr. Dobb Journal, May 2002
|
||||
=======================================
|
||||
*/
|
||||
|
||||
typedef unsigned long PIXEL;
|
||||
|
||||
//NOTE: If you change something here, please do the same in other dibXXbpp.c files!
|
||||
|
||||
/* 32-bit Color (___ format) */
|
||||
__inline PIXEL average32(PIXEL a, PIXEL b)
|
||||
{
|
||||
return a; // FIXME: Temp hack to remove "PCB-effect" from the image
|
||||
}
|
||||
|
||||
void ScaleLineAvg32(PIXEL *Target, PIXEL *Source, int SrcWidth, int TgtWidth)
|
||||
{
|
||||
int NumPixels = TgtWidth;
|
||||
int IntPart = SrcWidth / TgtWidth;
|
||||
int FractPart = SrcWidth % TgtWidth;
|
||||
int Mid = TgtWidth >> 1;
|
||||
int E = 0;
|
||||
int skip;
|
||||
PIXEL p;
|
||||
|
||||
skip = (TgtWidth < SrcWidth) ? 0 : (TgtWidth / (2*SrcWidth) + 1);
|
||||
NumPixels -= skip;
|
||||
|
||||
while (NumPixels-- > 0) {
|
||||
p = *Source;
|
||||
if (E >= Mid)
|
||||
p = average32(p, *(Source+1));
|
||||
*Target++ = p;
|
||||
Source += IntPart;
|
||||
E += FractPart;
|
||||
if (E >= TgtWidth) {
|
||||
E -= TgtWidth;
|
||||
Source++;
|
||||
} /* if */
|
||||
} /* while */
|
||||
while (skip-- > 0)
|
||||
*Target++ = *Source;
|
||||
}
|
||||
|
||||
static BOOLEAN
|
||||
FinalCopy32(PIXEL *Target, PIXEL *Source, PSPAN ClipSpans, UINT ClipSpansCount, UINT *SpanIndex,
|
||||
UINT DestY, RECTL *DestRect)
|
||||
{
|
||||
LONG Left, Right;
|
||||
|
||||
while (ClipSpans[*SpanIndex].Y < DestY
|
||||
|| (ClipSpans[*SpanIndex].Y == DestY
|
||||
&& ClipSpans[*SpanIndex].X + ClipSpans[*SpanIndex].Width < DestRect->left))
|
||||
{
|
||||
(*SpanIndex)++;
|
||||
if (ClipSpansCount <= *SpanIndex)
|
||||
{
|
||||
/* No more spans, everything else is clipped away, we're done */
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
while (ClipSpans[*SpanIndex].Y == DestY)
|
||||
{
|
||||
if (ClipSpans[*SpanIndex].X < DestRect->right)
|
||||
{
|
||||
Left = max(ClipSpans[*SpanIndex].X, DestRect->left);
|
||||
Right = min(ClipSpans[*SpanIndex].X + ClipSpans[*SpanIndex].Width, DestRect->right);
|
||||
memcpy(Target + Left - DestRect->left, Source + Left - DestRect->left,
|
||||
(Right - Left) * sizeof(PIXEL));
|
||||
}
|
||||
(*SpanIndex)++;
|
||||
if (ClipSpansCount <= *SpanIndex)
|
||||
{
|
||||
/* No more spans, everything else is clipped away, we're done */
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//NOTE: If you change something here, please do the same in other dibXXbpp.c files!
|
||||
BOOLEAN ScaleRectAvg32(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
|
||||
RECTL* DestRect, RECTL *SourceRect,
|
||||
POINTL* MaskOrigin, POINTL BrushOrigin,
|
||||
CLIPOBJ *ClipRegion, XLATEOBJ *ColorTranslation,
|
||||
ULONG Mode)
|
||||
{
|
||||
int NumPixels = DestRect->bottom - DestRect->top;
|
||||
int IntPart = (((SourceRect->bottom - SourceRect->top) / (DestRect->bottom - DestRect->top)) * SourceSurf->lDelta) / 4;
|
||||
int FractPart = (SourceRect->bottom - SourceRect->top) % (DestRect->bottom - DestRect->top);
|
||||
int Mid = (DestRect->bottom - DestRect->top) >> 1;
|
||||
int E = 0;
|
||||
int skip;
|
||||
PIXEL *ScanLine, *ScanLineAhead;
|
||||
PIXEL *PrevSource = NULL;
|
||||
PIXEL *PrevSourceAhead = NULL;
|
||||
PIXEL *Target = (PIXEL *) ((PBYTE)DestSurf->pvScan0 + (DestRect->top * DestSurf->lDelta) + 4 * DestRect->left);
|
||||
PIXEL *Source = (PIXEL *) ((PBYTE)SourceSurf->pvScan0 + (SourceRect->top * SourceSurf->lDelta) + 4 * SourceRect->left);
|
||||
PSPAN ClipSpans;
|
||||
UINT ClipSpansCount;
|
||||
UINT SpanIndex;
|
||||
LONG DestY;
|
||||
|
||||
if (! ClipobjToSpans(&ClipSpans, &ClipSpansCount, ClipRegion, DestRect))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (0 == ClipSpansCount)
|
||||
{
|
||||
/* No clip spans == empty clipping region, everything clipped away */
|
||||
ASSERT(NULL == ClipSpans);
|
||||
return TRUE;
|
||||
}
|
||||
skip = (DestRect->bottom - DestRect->top < SourceRect->bottom - SourceRect->top) ? 0 : ((DestRect->bottom - DestRect->top) / (2 * (SourceRect->bottom - SourceRect->top)) + 1);
|
||||
NumPixels -= skip;
|
||||
|
||||
ScanLine = (PIXEL*)ExAllocatePool(PagedPool, (DestRect->right - DestRect->left) * sizeof(PIXEL));
|
||||
ScanLineAhead = (PIXEL *)ExAllocatePool(PagedPool, (DestRect->right - DestRect->left) * sizeof(PIXEL));
|
||||
|
||||
if (!ScanLine || !ScanLineAhead)
|
||||
{
|
||||
if (ScanLine) ExFreePool(ScanLine);
|
||||
if (ScanLineAhead) ExFreePool(ScanLineAhead);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DestY = DestRect->top;
|
||||
SpanIndex = 0;
|
||||
while (NumPixels-- > 0) {
|
||||
if (Source != PrevSource) {
|
||||
if (Source == PrevSourceAhead) {
|
||||
/* the next scan line has already been scaled and stored in
|
||||
* ScanLineAhead; swap the buffers that ScanLine and ScanLineAhead
|
||||
* point to
|
||||
*/
|
||||
PIXEL *tmp = ScanLine;
|
||||
ScanLine = ScanLineAhead;
|
||||
ScanLineAhead = tmp;
|
||||
} else {
|
||||
ScaleLineAvg32(ScanLine, Source, SourceRect->right - SourceRect->left, DestRect->right - DestRect->left);
|
||||
} /* if */
|
||||
PrevSource = Source;
|
||||
} /* if */
|
||||
|
||||
if (E >= Mid && PrevSourceAhead != (PIXEL *)((BYTE *)Source + SourceSurf->lDelta)) {
|
||||
int x;
|
||||
ScaleLineAvg32(ScanLineAhead, (PIXEL *)((BYTE *)Source + SourceSurf->lDelta), SourceRect->right - SourceRect->left, DestRect->right - DestRect->left);
|
||||
for (x = 0; x < DestRect->right - DestRect->left; x++)
|
||||
ScanLine[x] = average32(ScanLine[x], ScanLineAhead[x]);
|
||||
PrevSourceAhead = (PIXEL *)((BYTE *)Source + SourceSurf->lDelta);
|
||||
} /* if */
|
||||
|
||||
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 Destinations */
|
||||
DesSizeY = DestRect->bottom - DestRect->top;
|
||||
|
||||
/* Calc the Zoom width of Destinations */
|
||||
DesSizeX = DestRect->right - DestRect->left;
|
||||
|
||||
/* Calc the zoom factor of source height */
|
||||
SrcZoomYHight = SrcSizeY / DesSizeY;
|
||||
SrcZoomYLow = SrcSizeY - (SrcZoomYHight * DesSizeY);
|
||||
|
||||
/* Calc the zoom factor of source 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);
|
||||
|
||||
if (SourceSurf->iBitmapFormat != BMF_32BPP)
|
||||
{
|
||||
/* 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,
|
||||
DibFunctionsForBitmapFormat[SourceSurf->iBitmapFormat].
|
||||
DIB_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;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return ScaleRectAvg32(DestSurf, SourceSurf, DestRect, SourceRect, MaskOrigin, BrushOrigin,
|
||||
ClipRegion, ColorTranslation, Mode);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
DIB_32BPP_TransparentBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
|
||||
RECTL* DestRect, POINTL *SourcePoint,
|
||||
|
|
|
@ -374,46 +374,6 @@ DIB_4BPP_ColorFill(SURFOBJ* DestSurface, RECTL* DestRect, ULONG color)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
//NOTE: If you change something here, please do the same in other dibXXbpp.c files!
|
||||
BOOLEAN DIB_4BPP_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;
|
||||
|
||||
/* 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 = DibFunctionsForBitmapFormat[SourceSurf->iBitmapFormat].
|
||||
DIB_GetPixel(SourceSurf, sx, sy);
|
||||
DIB_4BPP_PutPixel(DestSurf, DesX, DesY, XLATEOBJ_iXlate(ColorTranslation, color));
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
DIB_4BPP_TransparentBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
|
||||
RECTL* DestRect, POINTL *SourcePoint,
|
||||
|
|
|
@ -264,300 +264,7 @@ DIB_8BPP_ColorFill(SURFOBJ* DestSurface, RECTL* DestRect, ULONG color)
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
/*
|
||||
=======================================
|
||||
Stretching functions goes below
|
||||
Some parts of code are based on an
|
||||
article "Bresenhame image scaling"
|
||||
Dr. Dobb Journal, May 2002
|
||||
=======================================
|
||||
*/
|
||||
|
||||
typedef unsigned char PIXEL;
|
||||
|
||||
/* 16-bit HiColor (565 format) */
|
||||
__inline PIXEL average8(PIXEL a, PIXEL b)
|
||||
{
|
||||
return a; // FIXME: Depend on SetStretchMode
|
||||
}
|
||||
|
||||
//NOTE: If you change something here, please do the same in other dibXXbpp.c files!
|
||||
void ScaleLineAvg8(PIXEL *Target, PIXEL *Source, int SrcWidth, int TgtWidth)
|
||||
{
|
||||
int NumPixels = TgtWidth;
|
||||
int IntPart = SrcWidth / TgtWidth;
|
||||
int FractPart = SrcWidth % TgtWidth;
|
||||
int Mid = TgtWidth >> 1;
|
||||
int E = 0;
|
||||
int skip;
|
||||
PIXEL p;
|
||||
|
||||
skip = (TgtWidth < SrcWidth) ? 0 : (TgtWidth / (2*SrcWidth) + 1);
|
||||
NumPixels -= skip;
|
||||
|
||||
while (NumPixels-- > 0) {
|
||||
p = *Source;
|
||||
if (E >= Mid)
|
||||
p = average8(p, *(Source+1));
|
||||
*Target++ = p;
|
||||
Source += IntPart;
|
||||
E += FractPart;
|
||||
if (E >= TgtWidth) {
|
||||
E -= TgtWidth;
|
||||
Source++;
|
||||
} /* if */
|
||||
} /* while */
|
||||
while (skip-- > 0)
|
||||
*Target++ = *Source;
|
||||
}
|
||||
|
||||
static BOOLEAN
|
||||
FinalCopy8(PIXEL *Target, PIXEL *Source, PSPAN ClipSpans, UINT ClipSpansCount, UINT *SpanIndex,
|
||||
UINT DestY, RECTL *DestRect)
|
||||
{
|
||||
LONG Left, Right;
|
||||
|
||||
while (ClipSpans[*SpanIndex].Y < DestY
|
||||
|| (ClipSpans[*SpanIndex].Y == DestY
|
||||
&& ClipSpans[*SpanIndex].X + ClipSpans[*SpanIndex].Width < DestRect->left))
|
||||
{
|
||||
(*SpanIndex)++;
|
||||
if (ClipSpansCount <= *SpanIndex)
|
||||
{
|
||||
/* No more spans, everything else is clipped away, we're done */
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
while (ClipSpans[*SpanIndex].Y == DestY)
|
||||
{
|
||||
if (ClipSpans[*SpanIndex].X < DestRect->right)
|
||||
{
|
||||
Left = max(ClipSpans[*SpanIndex].X, DestRect->left);
|
||||
Right = min(ClipSpans[*SpanIndex].X + ClipSpans[*SpanIndex].Width, DestRect->right);
|
||||
memcpy(Target + Left - DestRect->left, Source + Left - DestRect->left,
|
||||
(Right - Left) * sizeof(PIXEL));
|
||||
}
|
||||
(*SpanIndex)++;
|
||||
if (ClipSpansCount <= *SpanIndex)
|
||||
{
|
||||
/* No more spans, everything else is clipped away, we're done */
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//NOTE: If you change something here, please do the same in other dibXXbpp.c files!
|
||||
BOOLEAN ScaleRectAvg8(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
|
||||
RECTL* DestRect, RECTL *SourceRect,
|
||||
POINTL* MaskOrigin, POINTL BrushOrigin,
|
||||
CLIPOBJ *ClipRegion, XLATEOBJ *ColorTranslation,
|
||||
ULONG Mode)
|
||||
{
|
||||
int NumPixels = DestRect->bottom - DestRect->top;
|
||||
int IntPart = (((SourceRect->bottom - SourceRect->top) / (DestRect->bottom - DestRect->top)) * SourceSurf->lDelta); //((SourceRect->bottom - SourceRect->top) / (DestRect->bottom - DestRect->top)) * (SourceRect->right - SourceRect->left);
|
||||
int FractPart = (SourceRect->bottom - SourceRect->top) % (DestRect->bottom - DestRect->top);
|
||||
int Mid = (DestRect->bottom - DestRect->top) >> 1;
|
||||
int E = 0;
|
||||
int skip;
|
||||
PIXEL *ScanLine, *ScanLineAhead;
|
||||
PIXEL *PrevSource = NULL;
|
||||
PIXEL *PrevSourceAhead = NULL;
|
||||
PIXEL *Target = (PIXEL *) ((PBYTE)DestSurf->pvScan0 + (DestRect->top * DestSurf->lDelta) + DestRect->left);
|
||||
PIXEL *Source = (PIXEL *) ((PBYTE)SourceSurf->pvScan0 + (SourceRect->top * SourceSurf->lDelta) + SourceRect->left);
|
||||
PSPAN ClipSpans;
|
||||
UINT ClipSpansCount;
|
||||
UINT SpanIndex;
|
||||
LONG DestY;
|
||||
|
||||
if (! ClipobjToSpans(&ClipSpans, &ClipSpansCount, ClipRegion, DestRect))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (0 == ClipSpansCount)
|
||||
{
|
||||
/* No clip spans == empty clipping region, everything clipped away */
|
||||
ASSERT(NULL == ClipSpans);
|
||||
return TRUE;
|
||||
}
|
||||
skip = (DestRect->bottom - DestRect->top < SourceRect->bottom - SourceRect->top) ? 0 : ((DestRect->bottom - DestRect->top) / (2 * (SourceRect->bottom - SourceRect->top)) + 1);
|
||||
NumPixels -= skip;
|
||||
|
||||
ScanLine = (PIXEL*)ExAllocatePool(PagedPool, (DestRect->right - DestRect->left) * sizeof(PIXEL));
|
||||
ScanLineAhead = (PIXEL *)ExAllocatePool(PagedPool, (DestRect->right - DestRect->left) * sizeof(PIXEL));
|
||||
|
||||
if (!ScanLine || !ScanLineAhead)
|
||||
{
|
||||
if (ScanLine) ExFreePool(ScanLine);
|
||||
if (ScanLineAhead) ExFreePool(ScanLineAhead);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DestY = DestRect->top;
|
||||
SpanIndex = 0;
|
||||
while (NumPixels-- > 0) {
|
||||
if (Source != PrevSource) {
|
||||
if (Source == PrevSourceAhead) {
|
||||
/* the next scan line has already been scaled and stored in
|
||||
* ScanLineAhead; swap the buffers that ScanLine and ScanLineAhead
|
||||
* point to
|
||||
*/
|
||||
PIXEL *tmp = ScanLine;
|
||||
ScanLine = ScanLineAhead;
|
||||
ScanLineAhead = tmp;
|
||||
} else {
|
||||
ScaleLineAvg8(ScanLine, Source, SourceRect->right - SourceRect->left, DestRect->right - DestRect->left);
|
||||
} /* if */
|
||||
PrevSource = Source;
|
||||
} /* if */
|
||||
|
||||
if (E >= Mid && PrevSourceAhead != (PIXEL *)((BYTE *)Source + SourceSurf->lDelta)) {
|
||||
int x;
|
||||
ScaleLineAvg8(ScanLineAhead, (PIXEL *)((BYTE *)Source + SourceSurf->lDelta), SourceRect->right - SourceRect->left, DestRect->right - DestRect->left);
|
||||
for (x = 0; x < DestRect->right - DestRect->left; x++)
|
||||
ScanLine[x] = average8(ScanLine[x], ScanLineAhead[x]);
|
||||
PrevSourceAhead = (PIXEL *)((BYTE *)Source + SourceSurf->lDelta);
|
||||
} /* if */
|
||||
|
||||
if (! FinalCopy8(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)
|
||||
ScaleLineAvg8(ScanLine, Source, SourceRect->right - SourceRect->left, DestRect->right - DestRect->left);
|
||||
while (skip-- > 0) {
|
||||
if (! FinalCopy8(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_8BPP_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;
|
||||
|
||||
LONG SrcZoomXHight;
|
||||
LONG SrcZoomXLow;
|
||||
LONG SrcZoomYHight;
|
||||
LONG SrcZoomYLow;
|
||||
|
||||
LONG sy_dec = 0;
|
||||
LONG sy_max;
|
||||
|
||||
LONG sx_dec = 0;
|
||||
LONG sx_max;
|
||||
|
||||
ULONG color;
|
||||
|
||||
DPRINT("DIB_8BPP_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 Destinations */
|
||||
DesSizeY = DestRect->bottom - DestRect->top;
|
||||
|
||||
/* Calc the Zoom width of Destinations */
|
||||
DesSizeX = DestRect->right - DestRect->left;
|
||||
|
||||
/* Calc the zoom factor of source height */
|
||||
SrcZoomYHight = SrcSizeY / DesSizeY;
|
||||
SrcZoomYLow = SrcSizeY - (SrcZoomYHight * DesSizeY);
|
||||
|
||||
/* Calc the zoom factor of source width */
|
||||
SrcZoomXHight = SrcSizeX / DesSizeX;
|
||||
SrcZoomXLow = SrcSizeX - (SrcZoomXHight * DesSizeX);
|
||||
|
||||
sx_max = DesSizeX;
|
||||
sy_max = DesSizeY;
|
||||
sy = SourceRect->top;
|
||||
|
||||
if (SourceSurf->iBitmapFormat != 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++)
|
||||
{
|
||||
sx = SourceRect->left;
|
||||
sx_dec = 0;
|
||||
for (DesX=DestRect->left; DesX<DestRect->right; DesX++)
|
||||
{
|
||||
color = XLATEOBJ_iXlate(ColorTranslation,
|
||||
DibFunctionsForBitmapFormat[SourceSurf->iBitmapFormat].
|
||||
DIB_GetPixel(SourceSurf, sx, sy));
|
||||
|
||||
DIB_8BPP_PutPixel(DestSurf, DesX, DesY, color);
|
||||
|
||||
sx += SrcZoomXHight;
|
||||
sx_dec += SrcZoomXLow;
|
||||
if (sx_dec >= sx_max)
|
||||
{
|
||||
sx++;
|
||||
sx_dec -= sx_max;
|
||||
}
|
||||
}
|
||||
|
||||
sy += SrcZoomYHight;
|
||||
sy_dec += SrcZoomYLow;
|
||||
if (sy_dec >= sy_max)
|
||||
{
|
||||
sy++;
|
||||
sy_dec -= sy_max;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return ScaleRectAvg8(DestSurf, SourceSurf, DestRect, SourceRect, MaskOrigin, BrushOrigin,
|
||||
ClipRegion, ColorTranslation, Mode);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
DIB_8BPP_TransparentBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
|
||||
|
|
Loading…
Reference in a new issue