2dc2c1abf037f21b7ac1a6ffc63bb629f62fbfb9
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.
27 DIB_24BPP_PutPixel(SURFOBJ
*SurfObj
, LONG x
, LONG y
, ULONG c
)
29 PBYTE addr
= (PBYTE
)SurfObj
->pvScan0
+ (y
* SurfObj
->lDelta
) + (x
<< 1) + x
;
30 *(PUSHORT
)(addr
) = c
& 0xFFFF;
31 *(addr
+ 2) = (c
>> 16) & 0xFF;
35 DIB_24BPP_GetPixel(SURFOBJ
*SurfObj
, LONG x
, LONG y
)
37 PBYTE addr
= (PBYTE
)SurfObj
->pvScan0
+ y
* SurfObj
->lDelta
+ (x
<< 1) + x
;
38 return *(PUSHORT
)(addr
) + (*(addr
+ 2) << 16);
42 DIB_24BPP_HLine(SURFOBJ
*SurfObj
, LONG x1
, LONG x2
, LONG y
, ULONG c
)
44 PBYTE addr
= (PBYTE
)SurfObj
->pvScan0
+ y
* SurfObj
->lDelta
+ (x1
<< 1) + x1
;
45 ULONG Count
= x2
- x1
;
53 /* For small fills, don't bother doing anything fancy */
64 /* Align to 4-byte address */
65 while (0 != ((ULONG_PTR
) addr
& 0x3))
73 /* If the color we need to fill with is 0ABC, then the final mem pattern
74 * (note little-endianness) would be:
76 * |C.B.A|C.B.A|C.B.A|C.B.A| <- pixel borders
77 * |C.B.A.C|B.A.C.B|A.C.B.A| <- ULONG borders
79 * So, taking endianness into account again, we need to fill with these
80 * ULONGs: CABC BCAB ABCA */
82 /* This is about 30% faster than the generic C code below */
83 __asm__
__volatile__ (
85 " andl $0xffffff, %%ecx\n" /* 0ABC */
86 " movl %%ecx, %%ebx\n" /* Construct BCAB in ebx */
88 " movl %%ecx, %%eax\n"
91 " movl %%ecx, %%edx\n" /* Construct ABCA in edx */
93 " movl %%ecx, %%eax\n"
96 " movl %%ecx, %%eax\n" /* Construct CABC in eax */
99 " movl %2, %%ecx\n" /* Load count */
101 " movl %3, %%edi\n" /* Load dest */
103 " movl %%eax, (%%edi)\n" /* Store 4 pixels, 12 bytes */
104 " movl %%ebx, 4(%%edi)\n"
105 " movl %%edx, 8(%%edi)\n"
111 : "m"(c
), "m"(Count
), "m"(addr
)
112 : "%eax", "%ebx", "%ecx", "%edx", "%edi");
114 c
= c
& 0xffffff; /* 0ABC */
115 Fill
[0] = c
| (c
<< 24); /* CABC */
116 Fill
[1] = (c
>> 8) | (c
<< 16); /* BCAB */
117 Fill
[2] = (c
<< 8) | (c
>> 16); /* ABCA */
118 MultiCount
= Count
/ 4;
121 *(PULONG
)addr
= Fill
[0];
123 *(PULONG
)addr
= Fill
[1];
125 *(PULONG
)addr
= Fill
[2];
128 while (0 != --MultiCount
);
130 Count
= Count
& 0x03;
133 *(PUSHORT
)(addr
) = c
;
142 DIB_24BPP_VLine(SURFOBJ
*SurfObj
, LONG x
, LONG y1
, LONG y2
, ULONG c
)
144 PBYTE addr
= (PBYTE
)SurfObj
->pvScan0
+ y1
* SurfObj
->lDelta
+ (x
<< 1) + x
;
145 LONG lDelta
= SurfObj
->lDelta
;
149 *(PUSHORT
)(addr
) = c
& 0xFFFF;
150 *(addr
+ 2) = c
>> 16;
157 DIB_24BPP_BitBltSrcCopy(PBLTINFO BltInfo
)
159 LONG i
, j
, sx
, sy
, xColor
, f1
;
160 PBYTE SourceBits
, DestBits
, SourceLine
, DestLine
;
161 PBYTE SourceBits_4BPP
, SourceLine_4BPP
;
162 PWORD SourceBits_16BPP
, SourceLine_16BPP
;
164 DestBits
= (PBYTE
)BltInfo
->DestSurface
->pvScan0
+ (BltInfo
->DestRect
.top
* BltInfo
->DestSurface
->lDelta
) + BltInfo
->DestRect
.left
* 3;
166 switch(BltInfo
->SourceSurface
->iBitmapFormat
)
169 sx
= BltInfo
->SourcePoint
.x
;
170 sy
= BltInfo
->SourcePoint
.y
;
172 for (j
=BltInfo
->DestRect
.top
; j
<BltInfo
->DestRect
.bottom
; j
++)
174 sx
= BltInfo
->SourcePoint
.x
;
175 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
177 if(DIB_1BPP_GetPixel(BltInfo
->SourceSurface
, sx
, sy
) == 0)
179 DIB_24BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, 0));
181 DIB_24BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, 1));
190 SourceBits_4BPP
= (PBYTE
)BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + (BltInfo
->SourcePoint
.x
>> 1);
192 for (j
=BltInfo
->DestRect
.top
; j
<BltInfo
->DestRect
.bottom
; j
++)
194 SourceLine_4BPP
= SourceBits_4BPP
;
196 sx
= BltInfo
->SourcePoint
.x
;
199 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
201 xColor
= XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
,
202 (*SourceLine_4BPP
& altnotmask
[f1
]) >> (4 * (1 - f1
)));
203 *DestLine
++ = xColor
& 0xff;
204 *(PWORD
)DestLine
= xColor
>> 8;
206 if(f1
== 1) { SourceLine_4BPP
++; f1
= 0; } else { f1
= 1; }
210 SourceBits_4BPP
+= BltInfo
->SourceSurface
->lDelta
;
211 DestBits
+= BltInfo
->DestSurface
->lDelta
;
216 SourceLine
= (PBYTE
)BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + BltInfo
->SourcePoint
.x
;
219 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
221 SourceBits
= SourceLine
;
224 for (i
= BltInfo
->DestRect
.left
; i
< BltInfo
->DestRect
.right
; i
++)
226 xColor
= XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, *SourceBits
);
227 *DestBits
= xColor
& 0xff;
228 *(PWORD
)(DestBits
+ 1) = xColor
>> 8;
233 SourceLine
+= BltInfo
->SourceSurface
->lDelta
;
234 DestLine
+= BltInfo
->DestSurface
->lDelta
;
239 SourceBits_16BPP
= (PWORD
)((PBYTE
)BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + 2 * BltInfo
->SourcePoint
.x
);
241 for (j
=BltInfo
->DestRect
.top
; j
<BltInfo
->DestRect
.bottom
; j
++)
243 SourceLine_16BPP
= SourceBits_16BPP
;
246 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
248 xColor
= XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, *SourceLine_16BPP
);
249 *DestLine
++ = xColor
& 0xff;
250 *(PWORD
)DestLine
= xColor
>> 8;
255 SourceBits_16BPP
= (PWORD
)((PBYTE
)SourceBits_16BPP
+ BltInfo
->SourceSurface
->lDelta
);
256 DestBits
+= BltInfo
->DestSurface
->lDelta
;
261 if (NULL
== BltInfo
->XlateSourceToDest
|| 0 != (BltInfo
->XlateSourceToDest
->flXlate
& XO_TRIVIAL
))
263 if (BltInfo
->DestRect
.top
< BltInfo
->SourcePoint
.y
)
265 SourceBits
= (PBYTE
)BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + 3 * BltInfo
->SourcePoint
.x
;
266 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
268 RtlMoveMemory(DestBits
, SourceBits
, 3 * (BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
));
269 SourceBits
+= BltInfo
->SourceSurface
->lDelta
;
270 DestBits
+= BltInfo
->DestSurface
->lDelta
;
275 SourceBits
= (PBYTE
)BltInfo
->SourceSurface
->pvScan0
+ ((BltInfo
->SourcePoint
.y
+ BltInfo
->DestRect
.bottom
- BltInfo
->DestRect
.top
- 1) * BltInfo
->SourceSurface
->lDelta
) + 3 * BltInfo
->SourcePoint
.x
;
276 DestBits
= (PBYTE
)BltInfo
->DestSurface
->pvScan0
+ ((BltInfo
->DestRect
.bottom
- 1) * BltInfo
->DestSurface
->lDelta
) + 3 * BltInfo
->DestRect
.left
;
277 for (j
= BltInfo
->DestRect
.bottom
- 1; BltInfo
->DestRect
.top
<= j
; j
--)
279 RtlMoveMemory(DestBits
, SourceBits
, 3 * (BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
));
280 SourceBits
-= BltInfo
->SourceSurface
->lDelta
;
281 DestBits
-= BltInfo
->DestSurface
->lDelta
;
288 DPRINT1("DIB_24BPP_Bitblt: Unhandled BltInfo->XlateSourceToDest for 16 -> 16 copy\n");
294 SourceLine
= (PBYTE
)BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + 4 * BltInfo
->SourcePoint
.x
;
297 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
299 SourceBits
= SourceLine
;
302 for (i
= BltInfo
->DestRect
.left
; i
< BltInfo
->DestRect
.right
; i
++)
304 xColor
= XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, *((PDWORD
) SourceBits
));
305 *DestBits
= xColor
& 0xff;
306 *(PWORD
)(DestBits
+ 1) = xColor
>> 8;
311 SourceLine
+= BltInfo
->SourceSurface
->lDelta
;
312 DestLine
+= BltInfo
->DestSurface
->lDelta
;
317 DbgPrint("DIB_24BPP_Bitblt: Unhandled Source BPP: %u\n", BitsPerFormat(BltInfo
->SourceSurface
->iBitmapFormat
));
325 DIB_24BPP_BitBlt(PBLTINFO BltInfo
)
328 ULONG SourceX
, SourceY
;
330 ULONG Dest
, Source
= 0, Pattern
= 0;
335 UsesSource
= ROP4_USES_SOURCE(BltInfo
->Rop4
);
336 UsesPattern
= ROP4_USES_PATTERN(BltInfo
->Rop4
);
338 SourceY
= BltInfo
->SourcePoint
.y
;
340 (PBYTE
)BltInfo
->DestSurface
->pvScan0
+
341 (BltInfo
->DestRect
.left
<< 1) + BltInfo
->DestRect
.left
+
342 BltInfo
->DestRect
.top
* BltInfo
->DestSurface
->lDelta
);
346 if (BltInfo
->PatternSurface
)
348 PatternY
= (BltInfo
->DestRect
.top
+ BltInfo
->BrushOrigin
.y
) %
349 BltInfo
->PatternSurface
->sizlBitmap
.cy
;
353 Pattern
= BltInfo
->Brush
->iSolidColor
;
357 for (DestY
= BltInfo
->DestRect
.top
; DestY
< BltInfo
->DestRect
.bottom
; DestY
++)
359 SourceX
= BltInfo
->SourcePoint
.x
;
361 for (DestX
= BltInfo
->DestRect
.left
; DestX
< BltInfo
->DestRect
.right
; DestX
++, DestBits
+= 3, SourceX
++)
363 Dest
= *((PUSHORT
)DestBits
) + (*(DestBits
+ 2) << 16);
367 Source
= DIB_GetSource(BltInfo
->SourceSurface
, SourceX
, SourceY
, BltInfo
->XlateSourceToDest
);
370 if (BltInfo
->PatternSurface
)
372 Pattern
= DIB_GetSource(BltInfo
->PatternSurface
, (DestX
+ BltInfo
->BrushOrigin
.x
) % BltInfo
->PatternSurface
->sizlBitmap
.cx
, PatternY
, BltInfo
->XlatePatternToDest
);
375 Dest
= DIB_DoRop(BltInfo
->Rop4
, Dest
, Source
, Pattern
) & 0xFFFFFF;
376 *(PUSHORT
)(DestBits
) = Dest
& 0xFFFF;
377 *(DestBits
+ 2) = Dest
>> 16;
381 if (BltInfo
->PatternSurface
)
384 PatternY
%= BltInfo
->PatternSurface
->sizlBitmap
.cy
;
386 DestBits
-= (BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
) * 3;
387 DestBits
+= BltInfo
->DestSurface
->lDelta
;
393 /* BitBlt Optimize */
395 DIB_24BPP_ColorFill(SURFOBJ
* DestSurface
, RECTL
* DestRect
, ULONG color
)
400 PBYTE xaddr
= (PBYTE
)DestSurface
->pvScan0
+ DestRect
->top
* DestSurface
->lDelta
+ (DestRect
->left
<< 1) + DestRect
->left
;
403 ULONG xCount
=DestRect
->right
- DestRect
->left
;
405 for (DestY
= DestRect
->top
; DestY
< DestRect
->bottom
; DestY
++)
409 xaddr
= (PBYTE
)((ULONG_PTR
)addr
+ DestSurface
->lDelta
);
413 /* For small fills, don't bother doing anything fancy */
416 *(PUSHORT
)(addr
) = color
;
418 *(addr
) = color
>> 16;
424 /* Align to 4-byte address */
425 while (0 != ((ULONG_PTR
) addr
& 0x3))
427 *(PUSHORT
)(addr
) = color
;
429 *(addr
) = color
>> 16;
433 /* If the color we need to fill with is 0ABC, then the final mem pattern
434 * (note little-endianness) would be:
436 * |C.B.A|C.B.A|C.B.A|C.B.A| <- pixel borders
437 * |C.B.A.C|B.A.C.B|A.C.B.A| <- ULONG borders
439 * So, taking endianness into account again, we need to fill with these
440 * ULONGs: CABC BCAB ABCA */
442 /* This is about 30% faster than the generic C code below */
443 __asm__
__volatile__ (
445 " andl $0xffffff, %%ecx\n" /* 0ABC */
446 " movl %%ecx, %%ebx\n" /* Construct BCAB in ebx */
448 " movl %%ecx, %%eax\n"
450 " orl %%eax, %%ebx\n"
451 " movl %%ecx, %%edx\n" /* Construct ABCA in edx */
453 " movl %%ecx, %%eax\n"
455 " orl %%eax, %%edx\n"
456 " movl %%ecx, %%eax\n" /* Construct CABC in eax */
458 " orl %%ecx, %%eax\n"
459 " movl %2, %%ecx\n" /* Load count */
461 " movl %3, %%edi\n" /* Load dest */
463 " movl %%eax, (%%edi)\n" /* Store 4 pixels, 12 bytes */
464 " movl %%ebx, 4(%%edi)\n"
465 " movl %%edx, 8(%%edi)\n"
471 : "m"(color
), "m"(Count
), "m"(addr
)
472 : "%eax", "%ebx", "%ecx", "%edx", "%edi");
473 Count
= Count
& 0x03;
476 *(PUSHORT
)(addr
) = color
;
478 *(addr
) = color
>> 16;
485 for (DestY
= DestRect
->top
; DestY
< DestRect
->bottom
; DestY
++)
487 DIB_24BPP_HLine(DestSurface
, DestRect
->left
, DestRect
->right
, DestY
, color
);
493 //NOTE: If you change something here, please do the same in other dibXXbpp.c files!
494 BOOLEAN
DIB_24BPP_StretchBlt(SURFOBJ
*DestSurf
, SURFOBJ
*SourceSurf
,
495 RECTL
* DestRect
, RECTL
*SourceRect
,
496 POINTL
* MaskOrigin
, POINTL BrushOrigin
,
497 CLIPOBJ
*ClipRegion
, XLATEOBJ
*ColorTranslation
,
514 BOOLEAN DesIsBiggerY
=FALSE
;
516 SrcSizeY
= SourceRect
->bottom
- SourceRect
->top
;
517 SrcSizeX
= SourceRect
->right
- SourceRect
->left
;
519 DesSizeY
= DestRect
->bottom
- DestRect
->top
;
520 DesSizeX
= DestRect
->right
- DestRect
->left
;
522 zoomX
= DesSizeX
/ SrcSizeX
;
523 if (zoomX
==0) zoomX
=1;
525 zoomY
= DesSizeY
/ SrcSizeY
;
526 if (zoomY
==0) zoomY
=1;
528 if (DesSizeY
>SrcSizeY
)
531 switch(SourceSurf
->iBitmapFormat
)
534 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
535 /* This is a reference implementation, it hasn't been optimized for speed */
538 /* Draw one Hline on X - Led to the Des Zoom In*/
539 if (DesSizeX
>SrcSizeX
)
541 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
544 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
546 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
548 if (sy
> SourceRect
->bottom
) break;
552 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
554 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
556 if (sx
> SourceRect
->right
) break;
558 saveX
= DesX
+ zoomX
;
560 if (DIB_1BPP_GetPixel(SourceSurf
, sx
, sy
) == 0)
561 for (count
=DesY
;count
<saveY
;count
++)
562 DIB_24BPP_HLine(DestSurf
, DesX
, saveX
, count
, 0);
564 for (count
=DesY
;count
<saveY
;count
++)
565 DIB_24BPP_HLine(DestSurf
, DesX
, saveX
, count
, 1);
572 /* Draw one Hline on X - Led to the Des Zoom Out*/
574 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
577 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
579 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
581 if (sy
> SourceRect
->bottom
) break;
585 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
587 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
589 if (sx
> SourceRect
->right
) break;
591 saveX
= DesX
+ zoomX
;
593 if (DIB_1BPP_GetPixel(SourceSurf
, sx
, sy
) == 0)
594 for (count
=DesY
;count
<saveY
;count
++)
595 DIB_24BPP_HLine(DestSurf
, DesX
, saveX
, count
, 0);
597 for (count
=DesY
;count
<saveY
;count
++)
598 DIB_24BPP_HLine(DestSurf
, DesX
, saveX
, count
, 1);
607 if (DesSizeX
>SrcSizeX
)
609 /* Draw one pixel on X - Led to the Des Zoom In*/
610 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
613 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
615 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
617 if (sy
> SourceRect
->bottom
) break;
621 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
623 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
625 if (sx
> SourceRect
->right
) break;
627 if (DIB_1BPP_GetPixel(SourceSurf
, sx
, sy
) == 0)
628 for (count
=DesY
;count
<saveY
;count
++)
629 DIB_24BPP_PutPixel(DestSurf
, DesX
, count
, 0);
631 for (count
=DesY
;count
<saveY
;count
++)
632 DIB_24BPP_PutPixel(DestSurf
, DesX
, count
, 1);
640 /* Draw one pixel on X - Led to the Des Zoom Out*/
641 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
644 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
646 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
648 if (sy
> SourceRect
->bottom
) break;
652 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
654 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
656 if (sx
> SourceRect
->right
) break;
658 if (DIB_1BPP_GetPixel(SourceSurf
, sx
, sy
) == 0)
659 for (count
=DesY
;count
<saveY
;count
++)
660 DIB_24BPP_PutPixel(DestSurf
, DesX
, count
, 0);
662 for (count
=DesY
;count
<saveY
;count
++)
663 DIB_24BPP_PutPixel(DestSurf
, DesX
, count
, 1);
672 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
673 /* This is a reference implementation, it hasn't been optimized for speed */
676 /* Draw one Hline on X - Led to the Des Zoom In*/
677 if (DesSizeX
>SrcSizeX
)
679 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
682 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
684 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
686 if (sy
> SourceRect
->bottom
) break;
690 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
692 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
694 if (sx
> SourceRect
->right
) break;
696 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_4BPP_GetPixel(SourceSurf
, sx
, sy
));
698 saveX
= DesX
+ zoomX
;
699 for (count
=DesY
;count
<saveY
;count
++)
700 DIB_24BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
706 /* Draw one Hline on X - Led to the Des Zoom Out*/
708 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
711 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
713 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
715 if (sy
> SourceRect
->bottom
) break;
719 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
721 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
723 if (sx
> SourceRect
->right
) break;
725 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_4BPP_GetPixel(SourceSurf
, sx
, sy
));
727 saveX
= DesX
+ zoomX
;
728 for (count
=DesY
;count
<saveY
;count
++)
729 DIB_24BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
738 if (DesSizeX
>SrcSizeX
)
740 /* Draw one pixel on X - Led to the Des Zoom In*/
741 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
744 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
746 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
748 if (sy
> SourceRect
->bottom
) break;
752 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
754 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
756 if (sx
> SourceRect
->right
) break;
758 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_4BPP_GetPixel(SourceSurf
, sx
, sy
));
760 for (count
=DesY
;count
<saveY
;count
++)
761 DIB_24BPP_PutPixel(DestSurf
, DesX
, count
, color
);
767 /* Draw one pixel on X - Led to the Des Zoom Out*/
768 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
771 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
773 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
775 if (sy
> SourceRect
->bottom
) break;
779 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
781 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
783 if (sx
> SourceRect
->right
) break;
785 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_4BPP_GetPixel(SourceSurf
, sx
, sy
));
787 for (count
=DesY
;count
<saveY
;count
++)
788 DIB_24BPP_PutPixel(DestSurf
, DesX
, count
, color
);
796 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
797 /* This is a reference implementation, it hasn't been optimized for speed */
800 /* Draw one Hline on X - Led to the Des Zoom In*/
801 if (DesSizeX
>SrcSizeX
)
803 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
806 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
808 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
810 if (sy
> SourceRect
->bottom
) break;
814 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
816 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
818 if (sx
> SourceRect
->right
) break;
820 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_8BPP_GetPixel(SourceSurf
, sx
, sy
));
822 saveX
= DesX
+ zoomX
;
823 for (count
=DesY
;count
<saveY
;count
++)
824 DIB_24BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
830 /* Draw one Hline on X - Led to the Des Zoom Out*/
832 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
835 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
837 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
839 if (sy
> SourceRect
->bottom
) break;
843 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
845 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
847 if (sx
> SourceRect
->right
) break;
849 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_8BPP_GetPixel(SourceSurf
, sx
, sy
));
851 saveX
= DesX
+ zoomX
;
852 for (count
=DesY
;count
<saveY
;count
++)
853 DIB_24BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
862 if (DesSizeX
>SrcSizeX
)
864 /* Draw one pixel on X - Led to the Des Zoom In*/
865 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
868 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
870 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
872 if (sy
> SourceRect
->bottom
) break;
876 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
878 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
880 if (sx
> SourceRect
->right
) break;
882 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_8BPP_GetPixel(SourceSurf
, sx
, sy
));
884 for (count
=DesY
;count
<saveY
;count
++)
885 DIB_24BPP_PutPixel(DestSurf
, DesX
, count
, color
);
891 /* Draw one pixel on X - Led to the Des Zoom Out*/
892 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
895 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
897 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
899 if (sy
> SourceRect
->bottom
) break;
903 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
905 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
907 if (sx
> SourceRect
->right
) break;
909 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_8BPP_GetPixel(SourceSurf
, sx
, sy
));
911 for (count
=DesY
;count
<saveY
;count
++)
912 DIB_24BPP_PutPixel(DestSurf
, DesX
, count
, color
);
920 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
921 /* This is a reference implementation, it hasn't been optimized for speed */
924 /* Draw one Hline on X - Led to the Des Zoom In*/
925 if (DesSizeX
>SrcSizeX
)
927 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
930 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
932 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
934 if (sy
> SourceRect
->bottom
) break;
938 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
940 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
942 if (sx
> SourceRect
->right
) break;
944 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_16BPP_GetPixel(SourceSurf
, sx
, sy
));
946 saveX
= DesX
+ zoomX
;
947 for (count
=DesY
;count
<saveY
;count
++)
948 DIB_24BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
954 /* Draw one Hline on X - Led to the Des Zoom Out*/
956 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
959 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
961 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
963 if (sy
> SourceRect
->bottom
) break;
967 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
969 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
971 if (sx
> SourceRect
->right
) break;
973 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_16BPP_GetPixel(SourceSurf
, sx
, sy
));
975 saveX
= DesX
+ zoomX
;
976 for (count
=DesY
;count
<saveY
;count
++)
977 DIB_24BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
986 if (DesSizeX
>SrcSizeX
)
988 /* Draw one pixel on X - Led to the Des Zoom In*/
989 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
992 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
994 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
996 if (sy
> SourceRect
->bottom
) break;
1000 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1002 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1004 if (sx
> SourceRect
->right
) break;
1006 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_16BPP_GetPixel(SourceSurf
, sx
, sy
));
1008 for (count
=DesY
;count
<saveY
;count
++)
1009 DIB_24BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1015 /* Draw one pixel on X - Led to the Des Zoom Out*/
1016 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1019 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1021 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1023 if (sy
> SourceRect
->bottom
) break;
1027 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1029 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1031 if (sx
> SourceRect
->right
) break;
1033 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_16BPP_GetPixel(SourceSurf
, sx
, sy
));
1035 for (count
=DesY
;count
<saveY
;count
++)
1036 DIB_24BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1044 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
1045 /* This is a reference implementation, it hasn't been optimized for speed */
1048 /* Draw one Hline on X - Led to the Des Zoom In*/
1049 if (DesSizeX
>SrcSizeX
)
1051 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1054 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1056 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1058 if (sy
> SourceRect
->bottom
) break;
1062 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1064 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1066 if (sx
> SourceRect
->right
) break;
1068 color
= DIB_24BPP_GetPixel(SourceSurf
, sx
, sy
);
1070 saveX
= DesX
+ zoomX
;
1071 for (count
=DesY
;count
<saveY
;count
++)
1072 DIB_24BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1078 /* Draw one Hline on X - Led to the Des Zoom Out*/
1080 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1083 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1085 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1087 if (sy
> SourceRect
->bottom
) break;
1091 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1093 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1095 if (sx
> SourceRect
->right
) break;
1097 color
= DIB_24BPP_GetPixel(SourceSurf
, sx
, sy
);
1099 saveX
= DesX
+ zoomX
;
1100 for (count
=DesY
;count
<saveY
;count
++)
1101 DIB_24BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1110 if (DesSizeX
>SrcSizeX
)
1112 /* Draw one pixel on X - Led to the Des Zoom In*/
1113 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1116 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1118 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1120 if (sy
> SourceRect
->bottom
) break;
1124 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1126 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1128 if (sx
> SourceRect
->right
) break;
1130 color
= DIB_24BPP_GetPixel(SourceSurf
, sx
, sy
);
1132 for (count
=DesY
;count
<saveY
;count
++)
1133 DIB_24BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1139 /* Draw one pixel on X - Led to the Des Zoom Out*/
1140 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1143 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1145 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1147 if (sy
> SourceRect
->bottom
) break;
1151 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1153 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1155 if (sx
> SourceRect
->right
) break;
1157 color
= DIB_24BPP_GetPixel(SourceSurf
, sx
, sy
);
1159 for (count
=DesY
;count
<saveY
;count
++)
1160 DIB_24BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1168 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
1169 /* This is a reference implementation, it hasn't been optimized for speed */
1172 /* Draw one Hline on X - Led to the Des Zoom In*/
1173 if (DesSizeX
>SrcSizeX
)
1175 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1178 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1180 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1182 if (sy
> SourceRect
->bottom
) break;
1186 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1188 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1190 if (sx
> SourceRect
->right
) break;
1192 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_32BPP_GetPixel(SourceSurf
, sx
, sy
));
1194 saveX
= DesX
+ zoomX
;
1195 for (count
=DesY
;count
<saveY
;count
++)
1196 DIB_24BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1202 /* Draw one Hline on X - Led to the Des Zoom Out*/
1204 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1207 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1209 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1211 if (sy
> SourceRect
->bottom
) break;
1215 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1217 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1219 if (sx
> SourceRect
->right
) break;
1221 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_32BPP_GetPixel(SourceSurf
, sx
, sy
));
1223 saveX
= DesX
+ zoomX
;
1224 for (count
=DesY
;count
<saveY
;count
++)
1225 DIB_24BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1234 if (DesSizeX
>SrcSizeX
)
1236 /* Draw one pixel on X - Led to the Des Zoom In*/
1237 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1240 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1242 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1244 if (sy
> SourceRect
->bottom
) break;
1248 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1250 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1252 if (sx
> SourceRect
->right
) break;
1254 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_32BPP_GetPixel(SourceSurf
, sx
, sy
));
1256 for (count
=DesY
;count
<saveY
;count
++)
1257 DIB_24BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1263 /* Draw one pixel on X - Led to the Des Zoom Out*/
1264 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1267 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1269 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1271 if (sy
> SourceRect
->bottom
) break;
1275 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1277 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1279 if (sx
> SourceRect
->right
) break;
1281 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_32BPP_GetPixel(SourceSurf
, sx
, sy
));
1283 for (count
=DesY
;count
<saveY
;count
++)
1284 DIB_24BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1292 //DPRINT1("DIB_24BPP_StretchBlt: Unhandled Source BPP: %u\n", BitsPerFormat(SourceSurf->iBitmapFormat));
1300 DIB_24BPP_TransparentBlt(SURFOBJ
*DestSurf
, SURFOBJ
*SourceSurf
,
1301 RECTL
* DestRect
, POINTL
*SourcePoint
,
1302 XLATEOBJ
*ColorTranslation
, ULONG iTransColor
)
1304 ULONG X
, Y
, SourceX
, SourceY
, Source
, wd
, Dest
;
1307 SourceY
= SourcePoint
->y
;
1308 DestBits
= (BYTE
*)((PBYTE
)DestSurf
->pvScan0
+
1309 (DestRect
->left
<< 2) +
1310 DestRect
->top
* DestSurf
->lDelta
);
1311 wd
= DestSurf
->lDelta
- ((DestRect
->right
- DestRect
->left
) << 2);
1313 for(Y
= DestRect
->top
; Y
< DestRect
->bottom
; Y
++)
1315 SourceX
= SourcePoint
->x
;
1316 for(X
= DestRect
->left
; X
< DestRect
->right
; X
++, DestBits
+= 3, SourceX
++)
1318 Source
= DIB_GetSourceIndex(SourceSurf
, SourceX
, SourceY
);
1319 if(Source
!= iTransColor
)
1321 Dest
= XLATEOBJ_iXlate(ColorTranslation
, Source
) & 0xFFFFFF;
1322 *(PUSHORT
)(DestBits
) = Dest
& 0xFFFF;
1323 *(DestBits
+ 2) = Dest
>> 16;
1328 DestBits
= (BYTE
*)((ULONG_PTR
)DestBits
+ wd
);
1347 return (val
> 255) ? 255 : val
;
1351 DIB_24BPP_AlphaBlend(SURFOBJ
* Dest
, SURFOBJ
* Source
, RECTL
* DestRect
,
1352 RECTL
* SourceRect
, CLIPOBJ
* ClipRegion
,
1353 XLATEOBJ
* ColorTranslation
, BLENDOBJ
* BlendObj
)
1355 INT Rows
, Cols
, SrcX
, SrcY
;
1356 register PUCHAR Dst
;
1358 BLENDFUNCTION BlendFunc
;
1359 register NICEPIXEL32 DstPixel
, SrcPixel
;
1360 UCHAR Alpha
, SrcBpp
;
1362 DPRINT("DIB_24BPP_AlphaBlend: srcRect: (%d,%d)-(%d,%d), dstRect: (%d,%d)-(%d,%d)\n",
1363 SourceRect
->left
, SourceRect
->top
, SourceRect
->right
, SourceRect
->bottom
,
1364 DestRect
->left
, DestRect
->top
, DestRect
->right
, DestRect
->bottom
);
1366 ASSERT(DestRect
->bottom
- DestRect
->top
== SourceRect
->bottom
- SourceRect
->top
&&
1367 DestRect
->right
- DestRect
->left
== SourceRect
->right
- SourceRect
->left
);
1369 BlendFunc
= BlendObj
->BlendFunction
;
1370 if (BlendFunc
.BlendOp
!= AC_SRC_OVER
)
1372 DPRINT1("BlendOp != AC_SRC_OVER\n");
1375 if (BlendFunc
.BlendFlags
!= 0)
1377 DPRINT1("BlendFlags != 0\n");
1380 if ((BlendFunc
.AlphaFormat
& ~AC_SRC_ALPHA
) != 0)
1382 DPRINT1("Unsupported AlphaFormat (0x%x)\n", BlendFunc
.AlphaFormat
);
1385 if ((BlendFunc
.AlphaFormat
& AC_SRC_ALPHA
) != 0 &&
1386 BitsPerFormat(Source
->iBitmapFormat
) != 32)
1388 DPRINT1("Source bitmap must be 32bpp when AC_SRC_ALPHA is set\n");
1392 Dst
= (PUCHAR
)((ULONG_PTR
)Dest
->pvScan0
+ (DestRect
->top
* Dest
->lDelta
) +
1393 (DestRect
->left
* 3));
1394 DstDelta
= Dest
->lDelta
- ((DestRect
->right
- DestRect
->left
) * 3);
1395 SrcBpp
= BitsPerFormat(Source
->iBitmapFormat
);
1397 Rows
= DestRect
->bottom
- DestRect
->top
;
1398 SrcY
= SourceRect
->top
;
1401 Cols
= DestRect
->right
- DestRect
->left
;
1402 SrcX
= SourceRect
->left
;
1405 SrcPixel
.ul
= DIB_GetSource(Source
, SrcX
++, SrcY
, ColorTranslation
);
1406 SrcPixel
.col
.red
= SrcPixel
.col
.red
* BlendFunc
.SourceConstantAlpha
/ 255;
1407 SrcPixel
.col
.green
= SrcPixel
.col
.green
* BlendFunc
.SourceConstantAlpha
/ 255;
1408 SrcPixel
.col
.blue
= SrcPixel
.col
.blue
* BlendFunc
.SourceConstantAlpha
/ 255;
1409 SrcPixel
.col
.alpha
= (SrcBpp
== 32) ? (SrcPixel
.col
.alpha
* BlendFunc
.SourceConstantAlpha
/ 255) : BlendFunc
.SourceConstantAlpha
;
1411 Alpha
= ((BlendFunc
.AlphaFormat
& AC_SRC_ALPHA
) != 0) ?
1412 SrcPixel
.col
.alpha
: BlendFunc
.SourceConstantAlpha
;
1415 DstPixel
.col
.red
= Clamp8(DstPixel
.col
.red
* (255 - Alpha
) / 255 + SrcPixel
.col
.red
);
1416 DstPixel
.col
.green
= Clamp8(DstPixel
.col
.green
* (255 - Alpha
) / 255 + SrcPixel
.col
.green
);
1417 DstPixel
.col
.blue
= Clamp8(DstPixel
.col
.blue
* (255 - Alpha
) / 255 + SrcPixel
.col
.blue
);
1419 Dst
= (PUCHAR
)((ULONG_PTR
)Dst
+ 3);
1421 Dst
= (PUCHAR
)((ULONG_PTR
)Dst
+ DstDelta
);