#include "../eng/objects.h"
#include "dib.h"
-PFN_DIB_PutPixel DIB_24BPP_PutPixel(PSURFOBJ SurfObj, LONG x, LONG y, ULONG c)
+VOID DIB_24BPP_PutPixel(PSURFOBJ SurfObj, LONG x, LONG y, ULONG c)
{
- PBYTE byteaddr = SurfObj->pvBits + y * SurfObj->lDelta;
+ PBYTE byteaddr = SurfObj->pvScan0 + y * SurfObj->lDelta;
PRGBTRIPLE addr = (PRGBTRIPLE)byteaddr + x;
*(PULONG)(addr) = c;
}
-PFN_DIB_GetPixel DIB_24BPP_GetPixel(PSURFOBJ SurfObj, LONG x, LONG y)
+ULONG DIB_24BPP_GetPixel(PSURFOBJ SurfObj, LONG x, LONG y)
{
- PBYTE byteaddr = SurfObj->pvBits + y * SurfObj->lDelta;
+ PBYTE byteaddr = SurfObj->pvScan0 + y * SurfObj->lDelta;
PRGBTRIPLE addr = (PRGBTRIPLE)byteaddr + x;
- return (PFN_DIB_GetPixel)(*(PULONG)(addr));
+ return *(PULONG)(addr) & 0x00ffffff;
}
-PFN_DIB_HLine DIB_24BPP_HLine(PSURFOBJ SurfObj, LONG x1, LONG x2, LONG y, ULONG c)
+VOID DIB_24BPP_HLine(PSURFOBJ SurfObj, LONG x1, LONG x2, LONG y, ULONG c)
{
- PBYTE byteaddr = SurfObj->pvBits + y * SurfObj->lDelta;
+ PBYTE byteaddr = SurfObj->pvScan0 + y * SurfObj->lDelta;
PRGBTRIPLE addr = (PRGBTRIPLE)byteaddr + x1;
LONG cx = x1;
- while(cx <= x2) {
+ while(cx < x2) {
*(PULONG)(addr) = c;
++addr;
++cx;
}
}
-PFN_DIB_VLine DIB_24BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c)
+VOID DIB_24BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c)
{
- PBYTE byteaddr = SurfObj->pvBits + y1 * SurfObj->lDelta;
+ PBYTE byteaddr = SurfObj->pvScan0 + y1 * SurfObj->lDelta;
PRGBTRIPLE addr = (PRGBTRIPLE)byteaddr + x;
LONG lDelta = SurfObj->lDelta;
byteaddr = (PBYTE)addr;
- while(y1++ <= y2) {
+ while(y1++ < y2) {
*(PULONG)(addr) = c;
byteaddr += lDelta;
}
}
-VOID DIB_24BPP_BltTo_24BPP(PSURFOBJ dstpsd, LONG dstx, LONG dsty, LONG w, LONG h,
- PSURFOBJ srcpsd, LONG srcx, LONG srcy)
-{
- PRGBTRIPLE dst;
- PRGBTRIPLE src;
- PBYTE bytedst;
- PBYTE bytesrc;
- int i;
- int dlDelta = dstpsd->lDelta;
- int slDelta = srcpsd->lDelta;
-
- bytedst = (char *)dstpsd->pvBits + dsty * dlDelta;
- bytesrc = (char *)srcpsd->pvBits + srcy * slDelta;
- dst = (PRGBTRIPLE)bytedst + dstx;
- src = (PRGBTRIPLE)bytesrc + srcx;
-
- while(--h >= 0) {
- PRGBTRIPLE d = dst;
- PRGBTRIPLE s = src;
- LONG dx = dstx;
- LONG sx = srcx;
- for(i=0; i<w; ++i) {
- *d = *s;
- ++d;
- ++s;
- }
- dst += dlDelta;
- src += slDelta;
- }
-}
-
-BOOLEAN DIB_To_24BPP_Bitblt( SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
+BOOLEAN DIB_24BPP_BitBlt( SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
SURFGDI *DestGDI, SURFGDI *SourceGDI,
PRECTL DestRect, POINTL *SourcePoint,
- LONG Delta, XLATEOBJ *ColorTranslation)
+ XLATEOBJ *ColorTranslation)
{
LONG i, j, sx, sy, xColor, f1;
- PBYTE DestBits, SourceBits_24BPP, DestLine, SourceLine_24BPP;
- PRGBTRIPLE SPDestBits, SPSourceBits_24BPP, SPDestLine, SPSourceLine_24BPP; // specially for 24-to-24 blit
- PBYTE SourceBits_4BPP, SourceBits_8BPP, SourceLine_4BPP, SourceLine_8BPP;
+ PBYTE SourceBits, DestBits, SourceLine, DestLine;
+ PBYTE SourceBits_4BPP, SourceLine_4BPP;
PWORD SourceBits_16BPP, SourceLine_16BPP;
- PDWORD SourceBits_32BPP, SourceLine_32BPP;
- DestBits = DestSurf->pvBits + (DestRect->top * DestSurf->lDelta) + DestRect->left * 3;
+ DestBits = DestSurf->pvScan0 + (DestRect->top * DestSurf->lDelta) + DestRect->left * 3;
switch(SourceGDI->BitsPerPixel)
{
break;
case 4:
- SourceBits_4BPP = SourceSurf->pvBits + (SourcePoint->y * SourceSurf->lDelta) + SourcePoint->x;
+ SourceBits_4BPP = SourceSurf->pvScan0 + (SourcePoint->y * SourceSurf->lDelta) + (SourcePoint->x >> 1);
for (j=DestRect->top; j<DestRect->bottom; j++)
{
}
break;
+ case 8:
+ SourceLine = SourceSurf->pvScan0 + (SourcePoint->y * SourceSurf->lDelta) + SourcePoint->x;
+ DestLine = DestBits;
+
+ for (j = DestRect->top; j < DestRect->bottom; j++)
+ {
+ SourceBits = SourceLine;
+ DestBits = DestLine;
+
+ for (i = DestRect->left; i < DestRect->right; i++)
+ {
+ xColor = XLATEOBJ_iXlate(ColorTranslation, *SourceBits);
+ *DestBits = xColor & 0xff;
+ *(PWORD)(DestBits + 1) = xColor >> 8;
+ SourceBits += 1;
+ DestBits += 3;
+ }
+
+ SourceLine += SourceSurf->lDelta;
+ DestLine += DestSurf->lDelta;
+ }
+ break;
+
+ case 16:
+ SourceBits_16BPP = SourceSurf->pvScan0 + (SourcePoint->y * SourceSurf->lDelta) + 2 * SourcePoint->x;
+
+ for (j=DestRect->top; j<DestRect->bottom; j++)
+ {
+ SourceLine_16BPP = SourceBits_16BPP;
+ DestLine = DestBits;
+
+ for (i=DestRect->left; i<DestRect->right; i++)
+ {
+ xColor = XLATEOBJ_iXlate(ColorTranslation, *SourceLine_16BPP);
+ *DestLine++ = xColor & 0xff;
+ *(PWORD)DestLine = xColor >> 8;
+ DestLine += 2;
+ SourceLine_16BPP++;
+ }
+
+ SourceBits_16BPP = (PWORD)((PBYTE)SourceBits_16BPP + SourceSurf->lDelta);
+ DestBits += DestSurf->lDelta;
+ }
+ break;
+
+ case 24:
+ if (NULL == ColorTranslation || 0 != (ColorTranslation->flXlate & XO_TRIVIAL))
+ {
+ SourceBits = SourceSurf->pvScan0 + (SourcePoint->y * SourceSurf->lDelta) + 3 * SourcePoint->x;
+ for (j = DestRect->top; j < DestRect->bottom; j++)
+ {
+ RtlCopyMemory(DestBits, SourceBits, 3 * (DestRect->right - DestRect->left));
+ SourceBits += SourceSurf->lDelta;
+ DestBits += DestSurf->lDelta;
+ }
+ }
+ else
+ {
+ /* FIXME */
+ DPRINT1("DIB_24BPP_Bitblt: Unhandled ColorTranslation for 16 -> 16 copy");
+ return FALSE;
+ }
+ break;
+
+ case 32:
+ SourceLine = SourceSurf->pvScan0 + (SourcePoint->y * SourceSurf->lDelta) + 4 * SourcePoint->x;
+ DestLine = DestBits;
+
+ for (j = DestRect->top; j < DestRect->bottom; j++)
+ {
+ SourceBits = SourceLine;
+ DestBits = DestLine;
+
+ for (i = DestRect->left; i < DestRect->right; i++)
+ {
+ xColor = XLATEOBJ_iXlate(ColorTranslation, *((PDWORD) SourceBits));
+ *DestBits = xColor & 0xff;
+ *(PWORD)(DestBits + 1) = xColor >> 8;
+ SourceBits += 4;
+ DestBits += 3;
+ }
+
+ SourceLine += SourceSurf->lDelta;
+ DestLine += DestSurf->lDelta;
+ }
+ break;
+
default:
DbgPrint("DIB_24BPP_Bitblt: Unhandled Source BPP: %u\n", SourceGDI->BitsPerPixel);
return FALSE;