1 #undef WIN32_LEAN_AND_MEAN
4 #include <win32k/bitmaps.h>
5 #include <win32k/debug.h>
7 #include <ddk/winddi.h>
8 #include "../eng/objects.h"
11 VOID DIB_24BPP_PutPixel(PSURFOBJ SurfObj, LONG x, LONG y, ULONG c)
13 PBYTE byteaddr = SurfObj->pvScan0 + y * SurfObj->lDelta;
14 PRGBTRIPLE addr = (PRGBTRIPLE)byteaddr + x;
19 ULONG DIB_24BPP_GetPixel(PSURFOBJ SurfObj, LONG x, LONG y)
21 PBYTE byteaddr = SurfObj->pvScan0 + y * SurfObj->lDelta;
22 PRGBTRIPLE addr = (PRGBTRIPLE)byteaddr + x;
24 return *(PULONG)(addr) & 0x00ffffff;
27 VOID DIB_24BPP_HLine(PSURFOBJ SurfObj, LONG x1, LONG x2, LONG y, ULONG c)
29 PBYTE byteaddr = SurfObj->pvScan0 + y * SurfObj->lDelta;
30 PRGBTRIPLE addr = (PRGBTRIPLE)byteaddr + x1;
40 VOID DIB_24BPP_VLine(PSURFOBJ SurfObj, LONG x, LONG y1, LONG y2, ULONG c)
42 PBYTE byteaddr = SurfObj->pvScan0 + y1 * SurfObj->lDelta;
43 PRGBTRIPLE addr = (PRGBTRIPLE)byteaddr + x;
44 LONG lDelta = SurfObj->lDelta;
46 byteaddr = (PBYTE)addr;
51 addr = (PRGBTRIPLE)byteaddr;
55 BOOLEAN DIB_24BPP_BitBlt( SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
56 SURFGDI *DestGDI, SURFGDI *SourceGDI,
57 PRECTL DestRect, POINTL *SourcePoint,
58 XLATEOBJ *ColorTranslation)
60 LONG i, j, sx, sy, xColor, f1;
61 PBYTE SourceBits, DestBits, SourceLine, DestLine;
62 PBYTE SourceBits_4BPP, SourceLine_4BPP;
63 PWORD SourceBits_16BPP, SourceLine_16BPP;
65 DestBits = DestSurf->pvScan0 + (DestRect->top * DestSurf->lDelta) + DestRect->left * 3;
67 switch(SourceGDI->BitsPerPixel)
73 for (j=DestRect->top; j<DestRect->bottom; j++)
76 for (i=DestRect->left; i<DestRect->right; i++)
78 if(DIB_1BPP_GetPixel(SourceSurf, sx, sy) == 0)
80 DIB_24BPP_PutPixel(DestSurf, i, j, XLATEOBJ_iXlate(ColorTranslation, 0));
82 DIB_24BPP_PutPixel(DestSurf, i, j, XLATEOBJ_iXlate(ColorTranslation, 1));
91 SourceBits_4BPP = SourceSurf->pvScan0 + (SourcePoint->y * SourceSurf->lDelta) + (SourcePoint->x >> 1);
93 for (j=DestRect->top; j<DestRect->bottom; j++)
95 SourceLine_4BPP = SourceBits_4BPP;
100 for (i=DestRect->left; i<DestRect->right; i++)
102 xColor = XLATEOBJ_iXlate(ColorTranslation,
103 (*SourceLine_4BPP & altnotmask[sx&1]) >> (4 * (1-(sx & 1))));
104 *DestLine++ = xColor & 0xff;
105 *(PWORD)DestLine = xColor >> 8;
107 if(f1 == 1) { SourceLine_4BPP++; f1 = 0; } else { f1 = 1; }
111 SourceBits_4BPP += SourceSurf->lDelta;
112 DestBits += DestSurf->lDelta;
117 SourceLine = SourceSurf->pvScan0 + (SourcePoint->y * SourceSurf->lDelta) + SourcePoint->x;
120 for (j = DestRect->top; j < DestRect->bottom; j++)
122 SourceBits = SourceLine;
125 for (i = DestRect->left; i < DestRect->right; i++)
127 xColor = XLATEOBJ_iXlate(ColorTranslation, *SourceBits);
128 *DestBits = xColor & 0xff;
129 *(PWORD)(DestBits + 1) = xColor >> 8;
134 SourceLine += SourceSurf->lDelta;
135 DestLine += DestSurf->lDelta;
140 SourceBits_16BPP = SourceSurf->pvScan0 + (SourcePoint->y * SourceSurf->lDelta) + 2 * SourcePoint->x;
142 for (j=DestRect->top; j<DestRect->bottom; j++)
144 SourceLine_16BPP = SourceBits_16BPP;
147 for (i=DestRect->left; i<DestRect->right; i++)
149 xColor = XLATEOBJ_iXlate(ColorTranslation, *SourceLine_16BPP);
150 *DestLine++ = xColor & 0xff;
151 *(PWORD)DestLine = xColor >> 8;
156 SourceBits_16BPP = (PWORD)((PBYTE)SourceBits_16BPP + SourceSurf->lDelta);
157 DestBits += DestSurf->lDelta;
162 if (NULL == ColorTranslation || 0 != (ColorTranslation->flXlate & XO_TRIVIAL))
164 SourceBits = SourceSurf->pvScan0 + (SourcePoint->y * SourceSurf->lDelta) + 3 * SourcePoint->x;
165 for (j = DestRect->top; j < DestRect->bottom; j++)
167 RtlCopyMemory(DestBits, SourceBits, 3 * (DestRect->right - DestRect->left));
168 SourceBits += SourceSurf->lDelta;
169 DestBits += DestSurf->lDelta;
175 DPRINT1("DIB_24BPP_Bitblt: Unhandled ColorTranslation for 16 -> 16 copy");
181 SourceLine = SourceSurf->pvScan0 + (SourcePoint->y * SourceSurf->lDelta) + 4 * SourcePoint->x;
184 for (j = DestRect->top; j < DestRect->bottom; j++)
186 SourceBits = SourceLine;
189 for (i = DestRect->left; i < DestRect->right; i++)
191 xColor = XLATEOBJ_iXlate(ColorTranslation, *((PDWORD) SourceBits));
192 *DestBits = xColor & 0xff;
193 *(PWORD)(DestBits + 1) = xColor >> 8;
198 SourceLine += SourceSurf->lDelta;
199 DestLine += DestSurf->lDelta;
204 DbgPrint("DIB_24BPP_Bitblt: Unhandled Source BPP: %u\n", SourceGDI->BitsPerPixel);