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 PBYTE byteaddr
= SurfObj
->pvScan0
+ y
* SurfObj
->lDelta
;
42 PBYTE addr
= byteaddr
+ x1
;
53 DIB_8BPP_VLine(SURFOBJ
*SurfObj
, LONG x
, LONG y1
, LONG y2
, ULONG c
)
55 PBYTE byteaddr
= SurfObj
->pvScan0
+ y1
* SurfObj
->lDelta
;
56 PBYTE addr
= byteaddr
+ x
;
57 LONG lDelta
= SurfObj
->lDelta
;
68 DIB_8BPP_BitBltSrcCopy(PBLTINFO BltInfo
)
70 LONG i
, j
, sx
, sy
, xColor
, f1
;
71 PBYTE SourceBits
, DestBits
, SourceLine
, DestLine
;
72 PBYTE SourceBits_4BPP
, SourceLine_4BPP
;
74 DestBits
= BltInfo
->DestSurface
->pvScan0
+ (BltInfo
->DestRect
.top
* BltInfo
->DestSurface
->lDelta
) + BltInfo
->DestRect
.left
;
76 switch(BltInfo
->SourceSurface
->iBitmapFormat
)
79 sx
= BltInfo
->SourcePoint
.x
;
80 sy
= BltInfo
->SourcePoint
.y
;
82 for (j
=BltInfo
->DestRect
.top
; j
<BltInfo
->DestRect
.bottom
; j
++)
84 sx
= BltInfo
->SourcePoint
.x
;
85 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
87 if(DIB_1BPP_GetPixel(BltInfo
->SourceSurface
, sx
, sy
) == 0)
89 DIB_8BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, 0));
91 DIB_8BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, 1));
100 SourceBits_4BPP
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + (BltInfo
->SourcePoint
.x
>> 1);
102 for (j
=BltInfo
->DestRect
.top
; j
<BltInfo
->DestRect
.bottom
; j
++)
104 SourceLine_4BPP
= SourceBits_4BPP
;
105 sx
= BltInfo
->SourcePoint
.x
;
108 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
110 xColor
= XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
,
111 (*SourceLine_4BPP
& altnotmask
[f1
]) >> (4 * (1 - f1
)));
112 DIB_8BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, xColor
);
113 if(f1
== 1) { SourceLine_4BPP
++; f1
= 0; } else { f1
= 1; }
117 SourceBits_4BPP
+= BltInfo
->SourceSurface
->lDelta
;
122 if (NULL
== BltInfo
->XlateSourceToDest
|| 0 != (BltInfo
->XlateSourceToDest
->flXlate
& XO_TRIVIAL
))
124 if (BltInfo
->DestRect
.top
< BltInfo
->SourcePoint
.y
)
126 SourceBits
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + BltInfo
->SourcePoint
.x
;
127 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
129 RtlMoveMemory(DestBits
, SourceBits
, BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
);
130 SourceBits
+= BltInfo
->SourceSurface
->lDelta
;
131 DestBits
+= BltInfo
->DestSurface
->lDelta
;
136 SourceBits
= BltInfo
->SourceSurface
->pvScan0
+ ((BltInfo
->SourcePoint
.y
+ BltInfo
->DestRect
.bottom
- BltInfo
->DestRect
.top
- 1) * BltInfo
->SourceSurface
->lDelta
) + BltInfo
->SourcePoint
.x
;
137 DestBits
= BltInfo
->DestSurface
->pvScan0
+ ((BltInfo
->DestRect
.bottom
- 1) * BltInfo
->DestSurface
->lDelta
) + BltInfo
->DestRect
.left
;
138 for (j
= BltInfo
->DestRect
.bottom
- 1; BltInfo
->DestRect
.top
<= j
; j
--)
140 RtlMoveMemory(DestBits
, SourceBits
, BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
);
141 SourceBits
-= BltInfo
->SourceSurface
->lDelta
;
142 DestBits
-= BltInfo
->DestSurface
->lDelta
;
148 if (BltInfo
->DestRect
.top
< BltInfo
->SourcePoint
.y
)
150 SourceLine
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + BltInfo
->SourcePoint
.x
;
152 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
154 SourceBits
= SourceLine
;
156 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
158 *DestBits
++ = XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, *SourceBits
++);
160 SourceLine
+= BltInfo
->SourceSurface
->lDelta
;
161 DestLine
+= BltInfo
->DestSurface
->lDelta
;
166 SourceLine
= BltInfo
->SourceSurface
->pvScan0
+ ((BltInfo
->SourcePoint
.y
+ BltInfo
->DestRect
.bottom
- BltInfo
->DestRect
.top
- 1) * BltInfo
->SourceSurface
->lDelta
) + BltInfo
->SourcePoint
.x
;
167 DestLine
= BltInfo
->DestSurface
->pvScan0
+ ((BltInfo
->DestRect
.bottom
- 1) * BltInfo
->DestSurface
->lDelta
) + BltInfo
->DestRect
.left
;
168 for (j
= BltInfo
->DestRect
.bottom
- 1; BltInfo
->DestRect
.top
<= j
; j
--)
170 SourceBits
= SourceLine
;
172 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
174 *DestBits
++ = XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, *SourceBits
++);
176 SourceLine
-= BltInfo
->SourceSurface
->lDelta
;
177 DestLine
-= BltInfo
->DestSurface
->lDelta
;
184 SourceLine
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + 2 * BltInfo
->SourcePoint
.x
;
187 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
189 SourceBits
= SourceLine
;
192 for (i
= BltInfo
->DestRect
.left
; i
< BltInfo
->DestRect
.right
; i
++)
194 xColor
= *((PWORD
) SourceBits
);
195 *DestBits
= XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, xColor
);
200 SourceLine
+= BltInfo
->SourceSurface
->lDelta
;
201 DestLine
+= BltInfo
->DestSurface
->lDelta
;
206 SourceLine
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + 3 * BltInfo
->SourcePoint
.x
;
209 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
211 SourceBits
= SourceLine
;
214 for (i
= BltInfo
->DestRect
.left
; i
< BltInfo
->DestRect
.right
; i
++)
216 xColor
= (*(SourceBits
+ 2) << 0x10) +
217 (*(SourceBits
+ 1) << 0x08) +
219 *DestBits
= XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, xColor
);
224 SourceLine
+= BltInfo
->SourceSurface
->lDelta
;
225 DestLine
+= BltInfo
->DestSurface
->lDelta
;
230 SourceLine
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + 4 * BltInfo
->SourcePoint
.x
;
233 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
235 SourceBits
= SourceLine
;
238 for (i
= BltInfo
->DestRect
.left
; i
< BltInfo
->DestRect
.right
; i
++)
240 xColor
= *((PDWORD
) SourceBits
);
241 *DestBits
= XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, xColor
);
246 SourceLine
+= BltInfo
->SourceSurface
->lDelta
;
247 DestLine
+= BltInfo
->DestSurface
->lDelta
;
252 DPRINT1("DIB_8BPP_Bitblt: Unhandled Source BPP: %u\n", BitsPerFormat(BltInfo
->SourceSurface
->iBitmapFormat
));
260 DIB_8BPP_BitBlt(PBLTINFO BltInfo
)
263 ULONG SourceX
, SourceY
;
265 ULONG Dest
, Source
= 0, Pattern
= 0;
271 UsesSource
= ROP_USES_SOURCE(BltInfo
->Rop4
);
272 UsesPattern
= ROP_USES_PATTERN(BltInfo
->Rop4
);
274 SourceY
= BltInfo
->SourcePoint
.y
;
275 RoundedRight
= BltInfo
->DestRect
.right
-
276 ((BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
) & 0x7);
280 if (BltInfo
->PatternSurface
)
282 PatternY
= (BltInfo
->DestRect
.top
+ BltInfo
->BrushOrigin
.y
) %
283 BltInfo
->PatternSurface
->sizlBitmap
.cy
;
287 Pattern
= BltInfo
->Brush
->iSolidColor
|
288 (BltInfo
->Brush
->iSolidColor
<< 8) |
289 (BltInfo
->Brush
->iSolidColor
<< 16) |
290 (BltInfo
->Brush
->iSolidColor
<< 24);
294 for (DestY
= BltInfo
->DestRect
.top
; DestY
< BltInfo
->DestRect
.bottom
; DestY
++)
296 SourceX
= BltInfo
->SourcePoint
.x
;
298 BltInfo
->DestSurface
->pvScan0
+
299 BltInfo
->DestRect
.left
+
300 DestY
* BltInfo
->DestSurface
->lDelta
);
302 for (DestX
= BltInfo
->DestRect
.left
; DestX
< RoundedRight
; DestX
+= 4, DestBits
++)
308 Source
= DIB_GetSource(BltInfo
->SourceSurface
, SourceX
+ (DestX
- BltInfo
->DestRect
.left
), SourceY
, BltInfo
->XlateSourceToDest
);
309 Source
|= DIB_GetSource(BltInfo
->SourceSurface
, SourceX
+ (DestX
- BltInfo
->DestRect
.left
) + 1, SourceY
, BltInfo
->XlateSourceToDest
) << 8;
310 Source
|= DIB_GetSource(BltInfo
->SourceSurface
, SourceX
+ (DestX
- BltInfo
->DestRect
.left
) + 2, SourceY
, BltInfo
->XlateSourceToDest
) << 16;
311 Source
|= DIB_GetSource(BltInfo
->SourceSurface
, SourceX
+ (DestX
- BltInfo
->DestRect
.left
) + 3, SourceY
, BltInfo
->XlateSourceToDest
) << 24;
314 if (BltInfo
->PatternSurface
)
316 Pattern
= DIB_GetSource(BltInfo
->PatternSurface
, (DestX
+ BltInfo
->BrushOrigin
.x
) % BltInfo
->PatternSurface
->sizlBitmap
.cx
, PatternY
, BltInfo
->XlatePatternToDest
);
317 Pattern
|= DIB_GetSource(BltInfo
->PatternSurface
, (DestX
+ BltInfo
->BrushOrigin
.x
+ 1) % BltInfo
->PatternSurface
->sizlBitmap
.cx
, PatternY
, BltInfo
->XlatePatternToDest
) << 8;
318 Pattern
|= DIB_GetSource(BltInfo
->PatternSurface
, (DestX
+ BltInfo
->BrushOrigin
.x
+ 2) % BltInfo
->PatternSurface
->sizlBitmap
.cx
, PatternY
, BltInfo
->XlatePatternToDest
) << 16;
319 Pattern
|= DIB_GetSource(BltInfo
->PatternSurface
, (DestX
+ BltInfo
->BrushOrigin
.x
+ 3) % BltInfo
->PatternSurface
->sizlBitmap
.cx
, PatternY
, BltInfo
->XlatePatternToDest
) << 24;
322 *DestBits
= DIB_DoRop(BltInfo
->Rop4
, Dest
, Source
, Pattern
);
325 if (DestX
< BltInfo
->DestRect
.right
)
327 for (; DestX
< BltInfo
->DestRect
.right
; DestX
++)
329 Dest
= DIB_8BPP_GetPixel(BltInfo
->DestSurface
, DestX
, DestY
);
333 Source
= DIB_GetSource(BltInfo
->SourceSurface
, SourceX
+ (DestX
- BltInfo
->DestRect
.left
), SourceY
, BltInfo
->XlateSourceToDest
);
336 if (BltInfo
->PatternSurface
)
338 Pattern
= DIB_GetSource(BltInfo
->PatternSurface
, (DestX
+ BltInfo
->BrushOrigin
.x
) % BltInfo
->PatternSurface
->sizlBitmap
.cx
, PatternY
, BltInfo
->XlatePatternToDest
);
341 DIB_8BPP_PutPixel(BltInfo
->DestSurface
, DestX
, DestY
, DIB_DoRop(BltInfo
->Rop4
, Dest
, Source
, Pattern
) & 0xFFFF);
346 if (BltInfo
->PatternSurface
)
349 PatternY
%= BltInfo
->PatternSurface
->sizlBitmap
.cy
;
357 =======================================
358 Stretching functions goes below
359 Some parts of code are based on an
360 article "Bresenhame image scaling"
361 Dr. Dobb Journal, May 2002
362 =======================================
365 typedef unsigned char PIXEL
;
367 /* 16-bit HiColor (565 format) */
368 inline PIXEL
average8(PIXEL a
, PIXEL b
)
370 return a
; // FIXME: Depend on SetStretchMode
373 //NOTE: If you change something here, please do the same in other dibXXbpp.c files!
374 void ScaleLineAvg8(PIXEL
*Target
, PIXEL
*Source
, int SrcWidth
, int TgtWidth
)
376 int NumPixels
= TgtWidth
;
377 int IntPart
= SrcWidth
/ TgtWidth
;
378 int FractPart
= SrcWidth
% TgtWidth
;
379 int Mid
= TgtWidth
>> 1;
384 skip
= (TgtWidth
< SrcWidth
) ? 0 : (TgtWidth
/ (2*SrcWidth
) + 1);
387 while (NumPixels
-- > 0) {
390 p
= average8(p
, *(Source
+1));
404 FinalCopy8(PIXEL
*Target
, PIXEL
*Source
, PSPAN ClipSpans
, UINT ClipSpansCount
, UINT
*SpanIndex
,
405 UINT DestY
, RECTL
*DestRect
)
409 while (ClipSpans
[*SpanIndex
].Y
< DestY
410 || (ClipSpans
[*SpanIndex
].Y
== DestY
411 && ClipSpans
[*SpanIndex
].X
+ ClipSpans
[*SpanIndex
].Width
< DestRect
->left
))
414 if (ClipSpansCount
<= *SpanIndex
)
416 /* No more spans, everything else is clipped away, we're done */
420 while (ClipSpans
[*SpanIndex
].Y
== DestY
)
422 if (ClipSpans
[*SpanIndex
].X
< DestRect
->right
)
424 Left
= max(ClipSpans
[*SpanIndex
].X
, DestRect
->left
);
425 Right
= min(ClipSpans
[*SpanIndex
].X
+ ClipSpans
[*SpanIndex
].Width
, DestRect
->right
);
426 memcpy(Target
+ Left
- DestRect
->left
, Source
+ Left
- DestRect
->left
,
427 (Right
- Left
) * sizeof(PIXEL
));
430 if (ClipSpansCount
<= *SpanIndex
)
432 /* No more spans, everything else is clipped away, we're done */
440 //NOTE: If you change something here, please do the same in other dibXXbpp.c files!
441 BOOLEAN
ScaleRectAvg8(SURFOBJ
*DestSurf
, SURFOBJ
*SourceSurf
,
442 RECTL
* DestRect
, RECTL
*SourceRect
,
443 POINTL
* MaskOrigin
, POINTL BrushOrigin
,
444 CLIPOBJ
*ClipRegion
, XLATEOBJ
*ColorTranslation
,
447 int NumPixels
= DestRect
->bottom
- DestRect
->top
;
448 int IntPart
= (((SourceRect
->bottom
- SourceRect
->top
) / (DestRect
->bottom
- DestRect
->top
)) * SourceSurf
->lDelta
); //((SourceRect->bottom - SourceRect->top) / (DestRect->bottom - DestRect->top)) * (SourceRect->right - SourceRect->left);
449 int FractPart
= (SourceRect
->bottom
- SourceRect
->top
) % (DestRect
->bottom
- DestRect
->top
);
450 int Mid
= (DestRect
->bottom
- DestRect
->top
) >> 1;
453 PIXEL
*ScanLine
, *ScanLineAhead
;
454 PIXEL
*PrevSource
= NULL
;
455 PIXEL
*PrevSourceAhead
= NULL
;
456 PIXEL
*Target
= (PIXEL
*) (DestSurf
->pvScan0
+ (DestRect
->top
* DestSurf
->lDelta
) + DestRect
->left
);
457 PIXEL
*Source
= (PIXEL
*) (SourceSurf
->pvScan0
+ (SourceRect
->top
* SourceSurf
->lDelta
) + SourceRect
->left
);
463 if (! ClipobjToSpans(&ClipSpans
, &ClipSpansCount
, ClipRegion
, DestRect
))
467 if (0 == ClipSpansCount
)
469 /* No clip spans == empty clipping region, everything clipped away */
470 ASSERT(NULL
== ClipSpans
);
473 skip
= (DestRect
->bottom
- DestRect
->top
< SourceRect
->bottom
- SourceRect
->top
) ? 0 : ((DestRect
->bottom
- DestRect
->top
) / (2 * (SourceRect
->bottom
- SourceRect
->top
)) + 1);
476 ScanLine
= (PIXEL
*)ExAllocatePool(PagedPool
, (DestRect
->right
- DestRect
->left
) * sizeof(PIXEL
));
477 ScanLineAhead
= (PIXEL
*)ExAllocatePool(PagedPool
, (DestRect
->right
- DestRect
->left
) * sizeof(PIXEL
));
479 DestY
= DestRect
->top
;
481 while (NumPixels
-- > 0) {
482 if (Source
!= PrevSource
) {
483 if (Source
== PrevSourceAhead
) {
484 /* the next scan line has already been scaled and stored in
485 * ScanLineAhead; swap the buffers that ScanLine and ScanLineAhead
488 PIXEL
*tmp
= ScanLine
;
489 ScanLine
= ScanLineAhead
;
492 ScaleLineAvg8(ScanLine
, Source
, SourceRect
->right
- SourceRect
->left
, DestRect
->right
- DestRect
->left
);
497 if (E
>= Mid
&& PrevSourceAhead
!= (PIXEL
*)((BYTE
*)Source
+ SourceSurf
->lDelta
)) {
499 ScaleLineAvg8(ScanLineAhead
, (PIXEL
*)((BYTE
*)Source
+ SourceSurf
->lDelta
), SourceRect
->right
- SourceRect
->left
, DestRect
->right
- DestRect
->left
);
500 for (x
= 0; x
< DestRect
->right
- DestRect
->left
; x
++)
501 ScanLine
[x
] = average8(ScanLine
[x
], ScanLineAhead
[x
]);
502 PrevSourceAhead
= (PIXEL
*)((BYTE
*)Source
+ SourceSurf
->lDelta
);
505 if (! FinalCopy8(Target
, ScanLine
, ClipSpans
, ClipSpansCount
, &SpanIndex
, DestY
, DestRect
))
507 /* No more spans, everything else is clipped away, we're done */
508 ExFreePool(ClipSpans
);
509 ExFreePool(ScanLine
);
510 ExFreePool(ScanLineAhead
);
514 Target
= (PIXEL
*)((BYTE
*)Target
+ DestSurf
->lDelta
);
517 if (E
>= DestRect
->bottom
- DestRect
->top
) {
518 E
-= DestRect
->bottom
- DestRect
->top
;
519 Source
= (PIXEL
*)((BYTE
*)Source
+ SourceSurf
->lDelta
);
523 if (skip
> 0 && Source
!= PrevSource
)
524 ScaleLineAvg8(ScanLine
, Source
, SourceRect
->right
- SourceRect
->left
, DestRect
->right
- DestRect
->left
);
526 if (! FinalCopy8(Target
, ScanLine
, ClipSpans
, ClipSpansCount
, &SpanIndex
, DestY
, DestRect
))
528 /* No more spans, everything else is clipped away, we're done */
529 ExFreePool(ClipSpans
);
530 ExFreePool(ScanLine
);
531 ExFreePool(ScanLineAhead
);
535 Target
= (PIXEL
*)((BYTE
*)Target
+ DestSurf
->lDelta
);
538 ExFreePool(ClipSpans
);
539 ExFreePool(ScanLine
);
540 ExFreePool(ScanLineAhead
);
545 BOOLEAN
DIB_8BPP_StretchBlt(SURFOBJ
*DestSurf
, SURFOBJ
*SourceSurf
,
546 RECTL
* DestRect
, RECTL
*SourceRect
,
547 POINTL
* MaskOrigin
, POINTL BrushOrigin
,
548 CLIPOBJ
*ClipRegion
, XLATEOBJ
*ColorTranslation
,
551 DPRINT("DIB_8BPP_StretchBlt: Source BPP: %u, srcRect: (%d,%d)-(%d,%d), dstRect: (%d,%d)-(%d,%d)\n",
552 BitsPerFormat(SourceSurf
->iBitmapFormat
), SourceRect
->left
, SourceRect
->top
, SourceRect
->right
, SourceRect
->bottom
,
553 DestRect
->left
, DestRect
->top
, DestRect
->right
, DestRect
->bottom
);
555 switch(SourceSurf
->iBitmapFormat
)
562 /* Not implemented yet. */
567 return ScaleRectAvg8(DestSurf
, SourceSurf
, DestRect
, SourceRect
, MaskOrigin
, BrushOrigin
,
568 ClipRegion
, ColorTranslation
, Mode
);
572 DPRINT1("DIB_8BPP_StretchBlt: Unhandled Source BPP: %u\n", BitsPerFormat(SourceSurf
->iBitmapFormat
));
580 DIB_8BPP_TransparentBlt(SURFOBJ
*DestSurf
, SURFOBJ
*SourceSurf
,
581 RECTL
* DestRect
, POINTL
*SourcePoint
,
582 XLATEOBJ
*ColorTranslation
, ULONG iTransColor
)
584 ULONG RoundedRight
, X
, Y
, SourceX
, SourceY
, Source
, wd
, Dest
;
587 RoundedRight
= DestRect
->right
- ((DestRect
->right
- DestRect
->left
) & 0x3);
588 SourceY
= SourcePoint
->y
;
589 DestBits
= (ULONG
*)(DestSurf
->pvScan0
+ DestRect
->left
+
590 (DestRect
->top
* DestSurf
->lDelta
));
591 wd
= DestSurf
->lDelta
- (DestRect
->right
- DestRect
->left
);
593 for(Y
= DestRect
->top
; Y
< DestRect
->bottom
; Y
++)
595 DestBits
= (ULONG
*)(DestSurf
->pvScan0
+ DestRect
->left
+
596 (Y
* DestSurf
->lDelta
));
597 SourceX
= SourcePoint
->x
;
598 for (X
= DestRect
->left
; X
< RoundedRight
; X
+= 4, DestBits
++)
602 Source
= DIB_GetSourceIndex(SourceSurf
, SourceX
++, SourceY
);
603 if(Source
!= iTransColor
)
606 Dest
|= (XLATEOBJ_iXlate(ColorTranslation
, Source
) & 0xFF);
609 Source
= DIB_GetSourceIndex(SourceSurf
, SourceX
++, SourceY
);
610 if(Source
!= iTransColor
)
613 Dest
|= ((XLATEOBJ_iXlate(ColorTranslation
, Source
) << 8) & 0xFF00);
616 Source
= DIB_GetSourceIndex(SourceSurf
, SourceX
++, SourceY
);
617 if(Source
!= iTransColor
)
620 Dest
|= ((XLATEOBJ_iXlate(ColorTranslation
, Source
) << 16) & 0xFF0000);
623 Source
= DIB_GetSourceIndex(SourceSurf
, SourceX
++, SourceY
);
624 if(Source
!= iTransColor
)
627 Dest
|= ((XLATEOBJ_iXlate(ColorTranslation
, Source
) << 24) & 0xFF000000);
633 if(X
< DestRect
->right
)
635 for (; X
< DestRect
->right
; X
++)
637 Source
= DIB_GetSourceIndex(SourceSurf
, SourceX
++, SourceY
);
638 if(Source
!= iTransColor
)
640 *((BYTE
*)DestBits
) = (BYTE
)(XLATEOBJ_iXlate(ColorTranslation
, Source
) & 0xFF);
642 DestBits
= (PULONG
)((ULONG_PTR
)DestBits
+ 1);