2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 DIB_8BPP_PutPixel(SURFOBJ
*SurfObj
, LONG x
, LONG y
, ULONG c
)
25 PBYTE byteaddr
= SurfObj
->pvScan0
+ y
* SurfObj
->lDelta
+ x
;
31 DIB_8BPP_GetPixel(SURFOBJ
*SurfObj
, LONG x
, LONG y
)
33 PBYTE byteaddr
= SurfObj
->pvScan0
+ y
* SurfObj
->lDelta
+ x
;
35 return (ULONG
)(*byteaddr
);
39 DIB_8BPP_HLine(SURFOBJ
*SurfObj
, LONG x1
, LONG x2
, LONG y
, ULONG c
)
41 memset(SurfObj
->pvScan0
+ y
* SurfObj
->lDelta
+ x1
, (BYTE
) c
, x2
- x1
);
45 DIB_8BPP_VLine(SURFOBJ
*SurfObj
, LONG x
, LONG y1
, LONG y2
, ULONG c
)
47 PBYTE byteaddr
= SurfObj
->pvScan0
+ y1
* SurfObj
->lDelta
;
48 PBYTE addr
= byteaddr
+ x
;
49 LONG lDelta
= SurfObj
->lDelta
;
60 DIB_8BPP_BitBltSrcCopy(PBLTINFO BltInfo
)
62 LONG i
, j
, sx
, sy
, xColor
, f1
;
63 PBYTE SourceBits
, DestBits
, SourceLine
, DestLine
;
64 PBYTE SourceBits_4BPP
, SourceLine_4BPP
;
66 DestBits
= BltInfo
->DestSurface
->pvScan0
+ (BltInfo
->DestRect
.top
* BltInfo
->DestSurface
->lDelta
) + BltInfo
->DestRect
.left
;
68 switch(BltInfo
->SourceSurface
->iBitmapFormat
)
71 sx
= BltInfo
->SourcePoint
.x
;
72 sy
= BltInfo
->SourcePoint
.y
;
74 for (j
=BltInfo
->DestRect
.top
; j
<BltInfo
->DestRect
.bottom
; j
++)
76 sx
= BltInfo
->SourcePoint
.x
;
77 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
79 if(DIB_1BPP_GetPixel(BltInfo
->SourceSurface
, sx
, sy
) == 0)
81 DIB_8BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, 0));
83 DIB_8BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, 1));
92 SourceBits_4BPP
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + (BltInfo
->SourcePoint
.x
>> 1);
94 for (j
=BltInfo
->DestRect
.top
; j
<BltInfo
->DestRect
.bottom
; j
++)
96 SourceLine_4BPP
= SourceBits_4BPP
;
97 sx
= BltInfo
->SourcePoint
.x
;
100 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
102 xColor
= XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
,
103 (*SourceLine_4BPP
& altnotmask
[f1
]) >> (4 * (1 - f1
)));
104 DIB_8BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, xColor
);
105 if(f1
== 1) { SourceLine_4BPP
++; f1
= 0; } else { f1
= 1; }
109 SourceBits_4BPP
+= BltInfo
->SourceSurface
->lDelta
;
114 if (NULL
== BltInfo
->XlateSourceToDest
|| 0 != (BltInfo
->XlateSourceToDest
->flXlate
& XO_TRIVIAL
))
116 if (BltInfo
->DestRect
.top
< BltInfo
->SourcePoint
.y
)
118 SourceBits
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + BltInfo
->SourcePoint
.x
;
119 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
121 RtlMoveMemory(DestBits
, SourceBits
, BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
);
122 SourceBits
+= BltInfo
->SourceSurface
->lDelta
;
123 DestBits
+= BltInfo
->DestSurface
->lDelta
;
128 SourceBits
= BltInfo
->SourceSurface
->pvScan0
+ ((BltInfo
->SourcePoint
.y
+ BltInfo
->DestRect
.bottom
- BltInfo
->DestRect
.top
- 1) * BltInfo
->SourceSurface
->lDelta
) + BltInfo
->SourcePoint
.x
;
129 DestBits
= BltInfo
->DestSurface
->pvScan0
+ ((BltInfo
->DestRect
.bottom
- 1) * BltInfo
->DestSurface
->lDelta
) + BltInfo
->DestRect
.left
;
130 for (j
= BltInfo
->DestRect
.bottom
- 1; BltInfo
->DestRect
.top
<= j
; j
--)
132 RtlMoveMemory(DestBits
, SourceBits
, BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
);
133 SourceBits
-= BltInfo
->SourceSurface
->lDelta
;
134 DestBits
-= BltInfo
->DestSurface
->lDelta
;
140 if (BltInfo
->DestRect
.top
< BltInfo
->SourcePoint
.y
)
142 SourceLine
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + BltInfo
->SourcePoint
.x
;
144 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
146 SourceBits
= SourceLine
;
148 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
150 *DestBits
++ = XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, *SourceBits
++);
152 SourceLine
+= BltInfo
->SourceSurface
->lDelta
;
153 DestLine
+= BltInfo
->DestSurface
->lDelta
;
158 SourceLine
= BltInfo
->SourceSurface
->pvScan0
+ ((BltInfo
->SourcePoint
.y
+ BltInfo
->DestRect
.bottom
- BltInfo
->DestRect
.top
- 1) * BltInfo
->SourceSurface
->lDelta
) + BltInfo
->SourcePoint
.x
;
159 DestLine
= BltInfo
->DestSurface
->pvScan0
+ ((BltInfo
->DestRect
.bottom
- 1) * BltInfo
->DestSurface
->lDelta
) + BltInfo
->DestRect
.left
;
160 for (j
= BltInfo
->DestRect
.bottom
- 1; BltInfo
->DestRect
.top
<= j
; j
--)
162 SourceBits
= SourceLine
;
164 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
166 *DestBits
++ = XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, *SourceBits
++);
168 SourceLine
-= BltInfo
->SourceSurface
->lDelta
;
169 DestLine
-= BltInfo
->DestSurface
->lDelta
;
176 SourceLine
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + 2 * BltInfo
->SourcePoint
.x
;
179 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
181 SourceBits
= SourceLine
;
184 for (i
= BltInfo
->DestRect
.left
; i
< BltInfo
->DestRect
.right
; i
++)
186 xColor
= *((PWORD
) SourceBits
);
187 *DestBits
= XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, xColor
);
192 SourceLine
+= BltInfo
->SourceSurface
->lDelta
;
193 DestLine
+= BltInfo
->DestSurface
->lDelta
;
198 SourceLine
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + 3 * BltInfo
->SourcePoint
.x
;
201 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
203 SourceBits
= SourceLine
;
206 for (i
= BltInfo
->DestRect
.left
; i
< BltInfo
->DestRect
.right
; i
++)
208 xColor
= (*(SourceBits
+ 2) << 0x10) +
209 (*(SourceBits
+ 1) << 0x08) +
211 *DestBits
= XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, xColor
);
216 SourceLine
+= BltInfo
->SourceSurface
->lDelta
;
217 DestLine
+= BltInfo
->DestSurface
->lDelta
;
222 SourceLine
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + 4 * BltInfo
->SourcePoint
.x
;
225 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
227 SourceBits
= SourceLine
;
230 for (i
= BltInfo
->DestRect
.left
; i
< BltInfo
->DestRect
.right
; i
++)
232 xColor
= *((PDWORD
) SourceBits
);
233 *DestBits
= XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, xColor
);
238 SourceLine
+= BltInfo
->SourceSurface
->lDelta
;
239 DestLine
+= BltInfo
->DestSurface
->lDelta
;
244 DPRINT1("DIB_8BPP_Bitblt: Unhandled Source BPP: %u\n", BitsPerFormat(BltInfo
->SourceSurface
->iBitmapFormat
));
252 DIB_8BPP_BitBlt(PBLTINFO BltInfo
)
255 ULONG SourceX
, SourceY
;
257 ULONG Dest
, Source
= 0, Pattern
= 0;
263 UsesSource
= ROP4_USES_SOURCE(BltInfo
->Rop4
);
264 UsesPattern
= ROP4_USES_PATTERN(BltInfo
->Rop4
);
266 SourceY
= BltInfo
->SourcePoint
.y
;
267 RoundedRight
= BltInfo
->DestRect
.right
-
268 ((BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
) & 0x7);
272 if (BltInfo
->PatternSurface
)
274 PatternY
= (BltInfo
->DestRect
.top
+ BltInfo
->BrushOrigin
.y
) %
275 BltInfo
->PatternSurface
->sizlBitmap
.cy
;
279 Pattern
= BltInfo
->Brush
->iSolidColor
|
280 (BltInfo
->Brush
->iSolidColor
<< 8) |
281 (BltInfo
->Brush
->iSolidColor
<< 16) |
282 (BltInfo
->Brush
->iSolidColor
<< 24);
286 for (DestY
= BltInfo
->DestRect
.top
; DestY
< BltInfo
->DestRect
.bottom
; DestY
++)
288 SourceX
= BltInfo
->SourcePoint
.x
;
290 BltInfo
->DestSurface
->pvScan0
+
291 BltInfo
->DestRect
.left
+
292 DestY
* BltInfo
->DestSurface
->lDelta
);
294 for (DestX
= BltInfo
->DestRect
.left
; DestX
< RoundedRight
; DestX
+= 4, DestBits
++)
300 Source
= DIB_GetSource(BltInfo
->SourceSurface
, SourceX
+ (DestX
- BltInfo
->DestRect
.left
), SourceY
, BltInfo
->XlateSourceToDest
);
301 Source
|= DIB_GetSource(BltInfo
->SourceSurface
, SourceX
+ (DestX
- BltInfo
->DestRect
.left
) + 1, SourceY
, BltInfo
->XlateSourceToDest
) << 8;
302 Source
|= DIB_GetSource(BltInfo
->SourceSurface
, SourceX
+ (DestX
- BltInfo
->DestRect
.left
) + 2, SourceY
, BltInfo
->XlateSourceToDest
) << 16;
303 Source
|= DIB_GetSource(BltInfo
->SourceSurface
, SourceX
+ (DestX
- BltInfo
->DestRect
.left
) + 3, SourceY
, BltInfo
->XlateSourceToDest
) << 24;
306 if (BltInfo
->PatternSurface
)
308 Pattern
= DIB_GetSource(BltInfo
->PatternSurface
, (DestX
+ BltInfo
->BrushOrigin
.x
) % BltInfo
->PatternSurface
->sizlBitmap
.cx
, PatternY
, BltInfo
->XlatePatternToDest
);
309 Pattern
|= DIB_GetSource(BltInfo
->PatternSurface
, (DestX
+ BltInfo
->BrushOrigin
.x
+ 1) % BltInfo
->PatternSurface
->sizlBitmap
.cx
, PatternY
, BltInfo
->XlatePatternToDest
) << 8;
310 Pattern
|= DIB_GetSource(BltInfo
->PatternSurface
, (DestX
+ BltInfo
->BrushOrigin
.x
+ 2) % BltInfo
->PatternSurface
->sizlBitmap
.cx
, PatternY
, BltInfo
->XlatePatternToDest
) << 16;
311 Pattern
|= DIB_GetSource(BltInfo
->PatternSurface
, (DestX
+ BltInfo
->BrushOrigin
.x
+ 3) % BltInfo
->PatternSurface
->sizlBitmap
.cx
, PatternY
, BltInfo
->XlatePatternToDest
) << 24;
314 *DestBits
= DIB_DoRop(BltInfo
->Rop4
, Dest
, Source
, Pattern
);
317 if (DestX
< BltInfo
->DestRect
.right
)
319 for (; DestX
< BltInfo
->DestRect
.right
; DestX
++)
321 Dest
= DIB_8BPP_GetPixel(BltInfo
->DestSurface
, DestX
, DestY
);
325 Source
= DIB_GetSource(BltInfo
->SourceSurface
, SourceX
+ (DestX
- BltInfo
->DestRect
.left
), SourceY
, BltInfo
->XlateSourceToDest
);
328 if (BltInfo
->PatternSurface
)
330 Pattern
= DIB_GetSource(BltInfo
->PatternSurface
, (DestX
+ BltInfo
->BrushOrigin
.x
) % BltInfo
->PatternSurface
->sizlBitmap
.cx
, PatternY
, BltInfo
->XlatePatternToDest
);
333 DIB_8BPP_PutPixel(BltInfo
->DestSurface
, DestX
, DestY
, DIB_DoRop(BltInfo
->Rop4
, Dest
, Source
, Pattern
) & 0xFFFF);
338 if (BltInfo
->PatternSurface
)
341 PatternY
%= BltInfo
->PatternSurface
->sizlBitmap
.cy
;
349 =======================================
350 Stretching functions goes below
351 Some parts of code are based on an
352 article "Bresenhame image scaling"
353 Dr. Dobb Journal, May 2002
354 =======================================
357 typedef unsigned char PIXEL
;
359 /* 16-bit HiColor (565 format) */
360 inline PIXEL
average8(PIXEL a
, PIXEL b
)
362 return a
; // FIXME: Depend on SetStretchMode
365 //NOTE: If you change something here, please do the same in other dibXXbpp.c files!
366 void ScaleLineAvg8(PIXEL
*Target
, PIXEL
*Source
, int SrcWidth
, int TgtWidth
)
368 int NumPixels
= TgtWidth
;
369 int IntPart
= SrcWidth
/ TgtWidth
;
370 int FractPart
= SrcWidth
% TgtWidth
;
371 int Mid
= TgtWidth
>> 1;
376 skip
= (TgtWidth
< SrcWidth
) ? 0 : (TgtWidth
/ (2*SrcWidth
) + 1);
379 while (NumPixels
-- > 0) {
382 p
= average8(p
, *(Source
+1));
396 FinalCopy8(PIXEL
*Target
, PIXEL
*Source
, PSPAN ClipSpans
, UINT ClipSpansCount
, UINT
*SpanIndex
,
397 UINT DestY
, RECTL
*DestRect
)
401 while (ClipSpans
[*SpanIndex
].Y
< DestY
402 || (ClipSpans
[*SpanIndex
].Y
== DestY
403 && ClipSpans
[*SpanIndex
].X
+ ClipSpans
[*SpanIndex
].Width
< DestRect
->left
))
406 if (ClipSpansCount
<= *SpanIndex
)
408 /* No more spans, everything else is clipped away, we're done */
412 while (ClipSpans
[*SpanIndex
].Y
== DestY
)
414 if (ClipSpans
[*SpanIndex
].X
< DestRect
->right
)
416 Left
= max(ClipSpans
[*SpanIndex
].X
, DestRect
->left
);
417 Right
= min(ClipSpans
[*SpanIndex
].X
+ ClipSpans
[*SpanIndex
].Width
, DestRect
->right
);
418 memcpy(Target
+ Left
- DestRect
->left
, Source
+ Left
- DestRect
->left
,
419 (Right
- Left
) * sizeof(PIXEL
));
422 if (ClipSpansCount
<= *SpanIndex
)
424 /* No more spans, everything else is clipped away, we're done */
432 //NOTE: If you change something here, please do the same in other dibXXbpp.c files!
433 BOOLEAN
ScaleRectAvg8(SURFOBJ
*DestSurf
, SURFOBJ
*SourceSurf
,
434 RECTL
* DestRect
, RECTL
*SourceRect
,
435 POINTL
* MaskOrigin
, POINTL BrushOrigin
,
436 CLIPOBJ
*ClipRegion
, XLATEOBJ
*ColorTranslation
,
439 int NumPixels
= DestRect
->bottom
- DestRect
->top
;
440 int IntPart
= (((SourceRect
->bottom
- SourceRect
->top
) / (DestRect
->bottom
- DestRect
->top
)) * SourceSurf
->lDelta
); //((SourceRect->bottom - SourceRect->top) / (DestRect->bottom - DestRect->top)) * (SourceRect->right - SourceRect->left);
441 int FractPart
= (SourceRect
->bottom
- SourceRect
->top
) % (DestRect
->bottom
- DestRect
->top
);
442 int Mid
= (DestRect
->bottom
- DestRect
->top
) >> 1;
445 PIXEL
*ScanLine
, *ScanLineAhead
;
446 PIXEL
*PrevSource
= NULL
;
447 PIXEL
*PrevSourceAhead
= NULL
;
448 PIXEL
*Target
= (PIXEL
*) (DestSurf
->pvScan0
+ (DestRect
->top
* DestSurf
->lDelta
) + DestRect
->left
);
449 PIXEL
*Source
= (PIXEL
*) (SourceSurf
->pvScan0
+ (SourceRect
->top
* SourceSurf
->lDelta
) + SourceRect
->left
);
455 if (! ClipobjToSpans(&ClipSpans
, &ClipSpansCount
, ClipRegion
, DestRect
))
459 if (0 == ClipSpansCount
)
461 /* No clip spans == empty clipping region, everything clipped away */
462 ASSERT(NULL
== ClipSpans
);
465 skip
= (DestRect
->bottom
- DestRect
->top
< SourceRect
->bottom
- SourceRect
->top
) ? 0 : ((DestRect
->bottom
- DestRect
->top
) / (2 * (SourceRect
->bottom
- SourceRect
->top
)) + 1);
468 ScanLine
= (PIXEL
*)ExAllocatePool(PagedPool
, (DestRect
->right
- DestRect
->left
) * sizeof(PIXEL
));
469 ScanLineAhead
= (PIXEL
*)ExAllocatePool(PagedPool
, (DestRect
->right
- DestRect
->left
) * sizeof(PIXEL
));
471 DestY
= DestRect
->top
;
473 while (NumPixels
-- > 0) {
474 if (Source
!= PrevSource
) {
475 if (Source
== PrevSourceAhead
) {
476 /* the next scan line has already been scaled and stored in
477 * ScanLineAhead; swap the buffers that ScanLine and ScanLineAhead
480 PIXEL
*tmp
= ScanLine
;
481 ScanLine
= ScanLineAhead
;
484 ScaleLineAvg8(ScanLine
, Source
, SourceRect
->right
- SourceRect
->left
, DestRect
->right
- DestRect
->left
);
489 if (E
>= Mid
&& PrevSourceAhead
!= (PIXEL
*)((BYTE
*)Source
+ SourceSurf
->lDelta
)) {
491 ScaleLineAvg8(ScanLineAhead
, (PIXEL
*)((BYTE
*)Source
+ SourceSurf
->lDelta
), SourceRect
->right
- SourceRect
->left
, DestRect
->right
- DestRect
->left
);
492 for (x
= 0; x
< DestRect
->right
- DestRect
->left
; x
++)
493 ScanLine
[x
] = average8(ScanLine
[x
], ScanLineAhead
[x
]);
494 PrevSourceAhead
= (PIXEL
*)((BYTE
*)Source
+ SourceSurf
->lDelta
);
497 if (! FinalCopy8(Target
, ScanLine
, ClipSpans
, ClipSpansCount
, &SpanIndex
, DestY
, DestRect
))
499 /* No more spans, everything else is clipped away, we're done */
500 ExFreePool(ClipSpans
);
501 ExFreePool(ScanLine
);
502 ExFreePool(ScanLineAhead
);
506 Target
= (PIXEL
*)((BYTE
*)Target
+ DestSurf
->lDelta
);
509 if (E
>= DestRect
->bottom
- DestRect
->top
) {
510 E
-= DestRect
->bottom
- DestRect
->top
;
511 Source
= (PIXEL
*)((BYTE
*)Source
+ SourceSurf
->lDelta
);
515 if (skip
> 0 && Source
!= PrevSource
)
516 ScaleLineAvg8(ScanLine
, Source
, SourceRect
->right
- SourceRect
->left
, DestRect
->right
- DestRect
->left
);
518 if (! FinalCopy8(Target
, ScanLine
, ClipSpans
, ClipSpansCount
, &SpanIndex
, DestY
, DestRect
))
520 /* No more spans, everything else is clipped away, we're done */
521 ExFreePool(ClipSpans
);
522 ExFreePool(ScanLine
);
523 ExFreePool(ScanLineAhead
);
527 Target
= (PIXEL
*)((BYTE
*)Target
+ DestSurf
->lDelta
);
530 ExFreePool(ClipSpans
);
531 ExFreePool(ScanLine
);
532 ExFreePool(ScanLineAhead
);
537 BOOLEAN
DIB_8BPP_StretchBlt(SURFOBJ
*DestSurf
, SURFOBJ
*SourceSurf
,
538 RECTL
* DestRect
, RECTL
*SourceRect
,
539 POINTL
* MaskOrigin
, POINTL BrushOrigin
,
540 CLIPOBJ
*ClipRegion
, XLATEOBJ
*ColorTranslation
,
543 DPRINT("DIB_8BPP_StretchBlt: Source BPP: %u, srcRect: (%d,%d)-(%d,%d), dstRect: (%d,%d)-(%d,%d)\n",
544 BitsPerFormat(SourceSurf
->iBitmapFormat
), SourceRect
->left
, SourceRect
->top
, SourceRect
->right
, SourceRect
->bottom
,
545 DestRect
->left
, DestRect
->top
, DestRect
->right
, DestRect
->bottom
);
547 switch(SourceSurf
->iBitmapFormat
)
554 /* Not implemented yet. */
559 return ScaleRectAvg8(DestSurf
, SourceSurf
, DestRect
, SourceRect
, MaskOrigin
, BrushOrigin
,
560 ClipRegion
, ColorTranslation
, Mode
);
564 DPRINT1("DIB_8BPP_StretchBlt: Unhandled Source BPP: %u\n", BitsPerFormat(SourceSurf
->iBitmapFormat
));
572 DIB_8BPP_TransparentBlt(SURFOBJ
*DestSurf
, SURFOBJ
*SourceSurf
,
573 RECTL
* DestRect
, POINTL
*SourcePoint
,
574 XLATEOBJ
*ColorTranslation
, ULONG iTransColor
)
576 ULONG RoundedRight
, X
, Y
, SourceX
, SourceY
, Source
, wd
, Dest
;
579 RoundedRight
= DestRect
->right
- ((DestRect
->right
- DestRect
->left
) & 0x3);
580 SourceY
= SourcePoint
->y
;
581 DestBits
= (ULONG
*)(DestSurf
->pvScan0
+ DestRect
->left
+
582 (DestRect
->top
* DestSurf
->lDelta
));
583 wd
= DestSurf
->lDelta
- (DestRect
->right
- DestRect
->left
);
585 for(Y
= DestRect
->top
; Y
< DestRect
->bottom
; Y
++)
587 DestBits
= (ULONG
*)(DestSurf
->pvScan0
+ DestRect
->left
+
588 (Y
* DestSurf
->lDelta
));
589 SourceX
= SourcePoint
->x
;
590 for (X
= DestRect
->left
; X
< RoundedRight
; X
+= 4, DestBits
++)
594 Source
= DIB_GetSourceIndex(SourceSurf
, SourceX
++, SourceY
);
595 if(Source
!= iTransColor
)
598 Dest
|= (XLATEOBJ_iXlate(ColorTranslation
, Source
) & 0xFF);
601 Source
= DIB_GetSourceIndex(SourceSurf
, SourceX
++, SourceY
);
602 if(Source
!= iTransColor
)
605 Dest
|= ((XLATEOBJ_iXlate(ColorTranslation
, Source
) << 8) & 0xFF00);
608 Source
= DIB_GetSourceIndex(SourceSurf
, SourceX
++, SourceY
);
609 if(Source
!= iTransColor
)
612 Dest
|= ((XLATEOBJ_iXlate(ColorTranslation
, Source
) << 16) & 0xFF0000);
615 Source
= DIB_GetSourceIndex(SourceSurf
, SourceX
++, SourceY
);
616 if(Source
!= iTransColor
)
619 Dest
|= ((XLATEOBJ_iXlate(ColorTranslation
, Source
) << 24) & 0xFF000000);
625 if(X
< DestRect
->right
)
627 for (; X
< DestRect
->right
; X
++)
629 Source
= DIB_GetSourceIndex(SourceSurf
, SourceX
++, SourceY
);
630 if(Source
!= iTransColor
)
632 *((BYTE
*)DestBits
) = (BYTE
)(XLATEOBJ_iXlate(ColorTranslation
, Source
) & 0xFF);
634 DestBits
= (PULONG
)((ULONG_PTR
)DestBits
+ 1);