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.
26 DIB_16BPP_PutPixel(SURFOBJ
*SurfObj
, LONG x
, LONG y
, ULONG c
)
28 PBYTE byteaddr
= (PBYTE
)SurfObj
->pvScan0
+ y
* SurfObj
->lDelta
;
29 PWORD addr
= (PWORD
)byteaddr
+ x
;
35 DIB_16BPP_GetPixel(SURFOBJ
*SurfObj
, LONG x
, LONG y
)
37 PBYTE byteaddr
= (PBYTE
)SurfObj
->pvScan0
+ y
* SurfObj
->lDelta
;
38 PWORD addr
= (PWORD
)byteaddr
+ x
;
40 return (ULONG
)(*addr
);
44 DIB_16BPP_HLine(SURFOBJ
*SurfObj
, LONG x1
, LONG x2
, LONG y
, ULONG c
)
46 PDWORD addr
= (PDWORD
)((PWORD
)((PBYTE
)SurfObj
->pvScan0
+ y
* SurfObj
->lDelta
) + x1
);
50 /* This is about 10% faster than the generic C code below */
53 __asm__
__volatile__ (
57 " andl $0xffff, %0\n" /* If the pixel value is "abcd", put "abcdabcd" in %eax */
60 " test $0x03, %%edi\n" /* Align to fullword boundary */
66 " mov %1,%%ecx\n" /* Setup count of fullwords to fill */
68 " rep stosl\n" /* The actual fill */
69 " test $0x01, %1\n" /* One left to do at the right side? */
74 : "r"(c
), "r"(Count
), "m"(addr
)
75 : "%eax", "%ecx", "%edi");
80 if (0 != (cx
& 0x01)) {
83 addr
= (PDWORD
)((PWORD
)(addr
) + 1);
85 cc
= ((c
& 0xffff) << 16) | (c
& 0xffff);
98 DIB_16BPP_VLine(SURFOBJ
*SurfObj
, LONG x
, LONG y1
, LONG y2
, ULONG c
)
102 " testl %2, %2" "\n\t"
104 " movl %2, %%ecx" "\n\t"
105 " shrl $2, %2" "\n\t"
106 " andl $3, %%ecx" "\n\t"
109 " movw %%ax, (%0)" "\n\t"
110 " addl %1, %0" "\n\t"
113 " testl %2, %2" "\n\t"
116 " movw %%ax, (%0)" "\n\t"
117 " addl %1, %0" "\n\t"
118 " movw %%ax, (%0)" "\n\t"
119 " addl %1, %0" "\n\t"
120 " movw %%ax, (%0)" "\n\t"
121 " addl %1, %0" "\n\t"
122 " movw %%ax, (%0)" "\n\t"
123 " addl %1, %0" "\n\t"
128 : "r"((PBYTE
)SurfObj
->pvScan0
+ (y1
* SurfObj
->lDelta
) + (x
* sizeof (WORD
))),
129 "r"(SurfObj
->lDelta
), "r"(y2
- y1
), "a"(c
)
130 : "cc", "memory", "%ecx");
132 PBYTE byteaddr
= SurfObj
->pvScan0
+ y1
* SurfObj
->lDelta
;
133 PWORD addr
= (PWORD
)byteaddr
+ x
;
134 LONG lDelta
= SurfObj
->lDelta
;
136 byteaddr
= (PBYTE
)addr
;
141 addr
= (PWORD
)byteaddr
;
147 DIB_16BPP_BitBltSrcCopy(PBLTINFO BltInfo
)
149 LONG i
, j
, sx
, sy
, xColor
, f1
;
150 PBYTE SourceBits
, DestBits
, SourceLine
, DestLine
;
151 PBYTE SourceBits_4BPP
, SourceLine_4BPP
;
152 DestBits
= (PBYTE
)BltInfo
->DestSurface
->pvScan0
+ (BltInfo
->DestRect
.top
* BltInfo
->DestSurface
->lDelta
) + 2 * BltInfo
->DestRect
.left
;
154 switch(BltInfo
->SourceSurface
->iBitmapFormat
)
157 sx
= BltInfo
->SourcePoint
.x
;
158 sy
= BltInfo
->SourcePoint
.y
;
160 for (j
=BltInfo
->DestRect
.top
; j
<BltInfo
->DestRect
.bottom
; j
++)
162 sx
= BltInfo
->SourcePoint
.x
;
163 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
165 if(DIB_1BPP_GetPixel(BltInfo
->SourceSurface
, sx
, sy
) == 0)
167 DIB_16BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, 0));
169 DIB_16BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, 1));
178 SourceBits_4BPP
= (PBYTE
)BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + (BltInfo
->SourcePoint
.x
>> 1);
180 for (j
=BltInfo
->DestRect
.top
; j
<BltInfo
->DestRect
.bottom
; j
++)
182 SourceLine_4BPP
= SourceBits_4BPP
;
183 sx
= BltInfo
->SourcePoint
.x
;
186 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
188 xColor
= XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
,
189 (*SourceLine_4BPP
& altnotmask
[f1
]) >> (4 * (1 - f1
)));
190 DIB_16BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, xColor
);
191 if(f1
== 1) { SourceLine_4BPP
++; f1
= 0; } else { f1
= 1; }
195 SourceBits_4BPP
+= BltInfo
->SourceSurface
->lDelta
;
200 SourceLine
= (PBYTE
)BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + BltInfo
->SourcePoint
.x
;
203 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
205 SourceBits
= SourceLine
;
208 for (i
= BltInfo
->DestRect
.left
; i
< BltInfo
->DestRect
.right
; i
++)
210 *((WORD
*)DestBits
) = (WORD
)XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, *SourceBits
);
215 SourceLine
+= BltInfo
->SourceSurface
->lDelta
;
216 DestLine
+= BltInfo
->DestSurface
->lDelta
;
221 if (NULL
== BltInfo
->XlateSourceToDest
|| 0 != (BltInfo
->XlateSourceToDest
->flXlate
& XO_TRIVIAL
))
223 if (BltInfo
->DestRect
.top
< BltInfo
->SourcePoint
.y
)
225 SourceBits
= (PBYTE
)BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + 2 * BltInfo
->SourcePoint
.x
;
226 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
228 RtlMoveMemory(DestBits
, SourceBits
, 2 * (BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
));
229 SourceBits
+= BltInfo
->SourceSurface
->lDelta
;
230 DestBits
+= BltInfo
->DestSurface
->lDelta
;
235 SourceBits
= (PBYTE
)BltInfo
->SourceSurface
->pvScan0
+ ((BltInfo
->SourcePoint
.y
+ BltInfo
->DestRect
.bottom
- BltInfo
->DestRect
.top
- 1) * BltInfo
->SourceSurface
->lDelta
) + 2 * BltInfo
->SourcePoint
.x
;
236 DestBits
= (PBYTE
)BltInfo
->DestSurface
->pvScan0
+ ((BltInfo
->DestRect
.bottom
- 1) * BltInfo
->DestSurface
->lDelta
) + 2 * BltInfo
->DestRect
.left
;
237 for (j
= BltInfo
->DestRect
.bottom
- 1; BltInfo
->DestRect
.top
<= j
; j
--)
239 RtlMoveMemory(DestBits
, SourceBits
, 2 * (BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
));
240 SourceBits
-= BltInfo
->SourceSurface
->lDelta
;
241 DestBits
-= BltInfo
->DestSurface
->lDelta
;
247 if (BltInfo
->DestRect
.top
< BltInfo
->SourcePoint
.y
)
249 SourceLine
= (PBYTE
)BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + 2 * BltInfo
->SourcePoint
.x
;
251 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
253 SourceBits
= SourceLine
;
255 for (i
= BltInfo
->DestRect
.left
; i
< BltInfo
->DestRect
.right
; i
++)
257 *((WORD
*)DestBits
) = (WORD
)XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, *((WORD
*)SourceBits
));
261 SourceLine
+= BltInfo
->SourceSurface
->lDelta
;
262 DestLine
+= BltInfo
->DestSurface
->lDelta
;
267 SourceLine
= (PBYTE
)BltInfo
->SourceSurface
->pvScan0
+ ((BltInfo
->SourcePoint
.y
+ BltInfo
->DestRect
.bottom
- BltInfo
->DestRect
.top
- 1) * BltInfo
->SourceSurface
->lDelta
) + 2 * BltInfo
->SourcePoint
.x
;
268 DestLine
= (PBYTE
)BltInfo
->DestSurface
->pvScan0
+ ((BltInfo
->DestRect
.bottom
- 1) * BltInfo
->DestSurface
->lDelta
) + 2 * BltInfo
->DestRect
.left
;
269 for (j
= BltInfo
->DestRect
.bottom
- 1; BltInfo
->DestRect
.top
<= j
; j
--)
271 SourceBits
= SourceLine
;
273 for (i
= BltInfo
->DestRect
.left
; i
< BltInfo
->DestRect
.right
; i
++)
275 *((WORD
*)DestBits
) = (WORD
)XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, *((WORD
*)SourceBits
));
279 SourceLine
-= BltInfo
->SourceSurface
->lDelta
;
280 DestLine
-= BltInfo
->DestSurface
->lDelta
;
287 SourceLine
= (PBYTE
)BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + 3 * BltInfo
->SourcePoint
.x
;
290 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
292 SourceBits
= SourceLine
;
295 for (i
= BltInfo
->DestRect
.left
; i
< BltInfo
->DestRect
.right
; i
++)
297 xColor
= (*(SourceBits
+ 2) << 0x10) +
298 (*(SourceBits
+ 1) << 0x08) +
300 *((WORD
*)DestBits
) = (WORD
)XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, xColor
);
305 SourceLine
+= BltInfo
->SourceSurface
->lDelta
;
306 DestLine
+= BltInfo
->DestSurface
->lDelta
;
311 SourceLine
= (PBYTE
)BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + 4 * BltInfo
->SourcePoint
.x
;
314 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
316 SourceBits
= SourceLine
;
319 for (i
= BltInfo
->DestRect
.left
; i
< BltInfo
->DestRect
.right
; i
++)
321 *((WORD
*)DestBits
) = (WORD
)XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, *((PDWORD
) SourceBits
));
326 SourceLine
+= BltInfo
->SourceSurface
->lDelta
;
327 DestLine
+= BltInfo
->DestSurface
->lDelta
;
332 DPRINT1("DIB_16BPP_Bitblt: Unhandled Source BPP: %u\n", BitsPerFormat(BltInfo
->SourceSurface
->iBitmapFormat
));
339 /* Optimize for bitBlt */
341 DIB_16BPP_ColorFill(SURFOBJ
* DestSurface
, RECTL
* DestRect
, ULONG color
)
346 /* This is about 10% faster than the generic C code below */
347 ULONG delta
= DestSurface
->lDelta
;
348 ULONG width
= (DestRect
->right
- DestRect
->left
) ;
349 PULONG pos
= (PULONG
) ((PBYTE
)DestSurface
->pvScan0
+ DestRect
->top
* delta
+ (DestRect
->left
<<1));
350 color
= (color
&0xffff); /* If the color value is "abcd", put "abcdabcd" into color */
351 color
+= (color
<<16);
353 for (DestY
= DestRect
->top
; DestY
< DestRect
->bottom
; DestY
++)
355 __asm__
__volatile__ (
359 " test $0x03, %%edi\n" /* Align to fullword boundary */
365 " mov %%ebx,%%ecx\n" /* Setup count of fullwords to fill */
367 " rep stosl\n" /* The actual fill */
368 " test $0x01, %%ebx\n" /* One left to do at the right side? */
373 : "a" (color
), "r" (width
), "m" (pos
)
374 : "%ecx", "%ebx", "%edi");
375 pos
=(PULONG
)((ULONG_PTR
)pos
+ delta
);
380 for (DestY
= DestRect
->top
; DestY
< DestRect
->bottom
; DestY
++)
382 DIB_16BPP_HLine (DestSurface
, DestRect
->left
, DestRect
->right
, DestY
, color
);
388 =======================================
389 Stretching functions goes below
390 Some parts of code are based on an
391 article "Bresenhame image scaling"
392 Dr. Dobb Journal, May 2002
393 =======================================
396 typedef unsigned short PIXEL
;
398 /* 16-bit HiColor (565 format) */
399 __inline PIXEL
average16(PIXEL a
, PIXEL b
)
401 // This one doesn't work
406 unsigned short mask = ~ (((a | b) & 0x0410) << 1);
407 return ((a & mask) + (b & mask)) >> 1;
410 // This one should be correct, but it's too long
412 unsigned char r1, g1, b1, r2, g2, b2, rr, gr, br;
415 r1 = (a & 0xF800) >> 11;
416 g1 = (a & 0x7E0) >> 5;
419 r2 = (b & 0xF800) >> 11;
420 g2 = (b & 0x7E0) >> 5;
427 res = (rr << 11) + (gr << 5) + br;
431 return a
; // FIXME: Depend on SetStretchMode
434 //NOTE: If you change something here, please do the same in other dibXXbpp.c files!
435 void ScaleLineAvg16(PIXEL
*Target
, PIXEL
*Source
, int SrcWidth
, int TgtWidth
)
437 int NumPixels
= TgtWidth
;
438 int IntPart
= SrcWidth
/ TgtWidth
;
439 int FractPart
= SrcWidth
% TgtWidth
;
440 int Mid
= TgtWidth
>> 1;
445 skip
= (TgtWidth
< SrcWidth
) ? 0 : (TgtWidth
/ (2*SrcWidth
) + 1);
448 while (NumPixels
-- > 0) {
451 p
= average16(p
, *(Source
+1));
465 FinalCopy16(PIXEL
*Target
, PIXEL
*Source
, PSPAN ClipSpans
, UINT ClipSpansCount
, UINT
*SpanIndex
,
466 UINT DestY
, RECTL
*DestRect
)
470 while (ClipSpans
[*SpanIndex
].Y
< DestY
471 || (ClipSpans
[*SpanIndex
].Y
== DestY
472 && ClipSpans
[*SpanIndex
].X
+ ClipSpans
[*SpanIndex
].Width
< DestRect
->left
))
475 if (ClipSpansCount
<= *SpanIndex
)
477 /* No more spans, everything else is clipped away, we're done */
481 while (ClipSpans
[*SpanIndex
].Y
== DestY
)
483 if (ClipSpans
[*SpanIndex
].X
< DestRect
->right
)
485 Left
= max(ClipSpans
[*SpanIndex
].X
, DestRect
->left
);
486 Right
= min(ClipSpans
[*SpanIndex
].X
+ ClipSpans
[*SpanIndex
].Width
, DestRect
->right
);
487 memcpy(Target
+ Left
- DestRect
->left
, Source
+ Left
- DestRect
->left
,
488 (Right
- Left
) * sizeof(PIXEL
));
491 if (ClipSpansCount
<= *SpanIndex
)
493 /* No more spans, everything else is clipped away, we're done */
501 //NOTE: If you change something here, please do the same in other dibXXbpp.c files!
502 BOOLEAN
ScaleRectAvg16(SURFOBJ
*DestSurf
, SURFOBJ
*SourceSurf
,
503 RECTL
* DestRect
, RECTL
*SourceRect
,
504 POINTL
* MaskOrigin
, POINTL BrushOrigin
,
505 CLIPOBJ
*ClipRegion
, XLATEOBJ
*ColorTranslation
,
508 int NumPixels
= DestRect
->bottom
- DestRect
->top
;
509 int IntPart
= (((SourceRect
->bottom
- SourceRect
->top
) / (DestRect
->bottom
- DestRect
->top
)) * SourceSurf
->lDelta
) >> 1;
510 int FractPart
= (SourceRect
->bottom
- SourceRect
->top
) % (DestRect
->bottom
- DestRect
->top
);
511 int Mid
= (DestRect
->bottom
- DestRect
->top
) >> 1;
514 PIXEL
*ScanLine
, *ScanLineAhead
;
515 PIXEL
*PrevSource
= NULL
;
516 PIXEL
*PrevSourceAhead
= NULL
;
517 PIXEL
*Target
= (PIXEL
*) ((PBYTE
)DestSurf
->pvScan0
+ (DestRect
->top
* DestSurf
->lDelta
) + 2 * DestRect
->left
);
518 PIXEL
*Source
= (PIXEL
*) ((PBYTE
)SourceSurf
->pvScan0
+ (SourceRect
->top
* SourceSurf
->lDelta
) + 2 * SourceRect
->left
);
524 if (! ClipobjToSpans(&ClipSpans
, &ClipSpansCount
, ClipRegion
, DestRect
))
528 if (0 == ClipSpansCount
)
530 /* No clip spans == empty clipping region, everything clipped away */
531 ASSERT(NULL
== ClipSpans
);
534 skip
= (DestRect
->bottom
- DestRect
->top
< SourceRect
->bottom
- SourceRect
->top
) ? 0 : ((DestRect
->bottom
- DestRect
->top
) / (2 * (SourceRect
->bottom
- SourceRect
->top
)) + 1);
537 ScanLine
= (PIXEL
*)ExAllocatePool(PagedPool
, (DestRect
->right
- DestRect
->left
) * sizeof(PIXEL
));
538 ScanLineAhead
= (PIXEL
*)ExAllocatePool(PagedPool
, (DestRect
->right
- DestRect
->left
) * sizeof(PIXEL
));
540 DestY
= DestRect
->top
;
542 while (NumPixels
-- > 0) {
543 if (Source
!= PrevSource
) {
544 if (Source
== PrevSourceAhead
) {
545 /* the next scan line has already been scaled and stored in
546 * ScanLineAhead; swap the buffers that ScanLine and ScanLineAhead
549 PIXEL
*tmp
= ScanLine
;
550 ScanLine
= ScanLineAhead
;
553 ScaleLineAvg16(ScanLine
, Source
, SourceRect
->right
- SourceRect
->left
, DestRect
->right
- DestRect
->left
);
558 if (E
>= Mid
&& PrevSourceAhead
!= (PIXEL
*)((BYTE
*)Source
+ SourceSurf
->lDelta
)) {
560 ScaleLineAvg16(ScanLineAhead
, (PIXEL
*)((BYTE
*)Source
+ SourceSurf
->lDelta
), SourceRect
->right
- SourceRect
->left
, DestRect
->right
- DestRect
->left
);
561 for (x
= 0; x
< DestRect
->right
- DestRect
->left
; x
++)
562 ScanLine
[x
] = average16(ScanLine
[x
], ScanLineAhead
[x
]);
563 PrevSourceAhead
= (PIXEL
*)((BYTE
*)Source
+ SourceSurf
->lDelta
);
566 if (! FinalCopy16(Target
, ScanLine
, ClipSpans
, ClipSpansCount
, &SpanIndex
, DestY
, DestRect
))
568 /* No more spans, everything else is clipped away, we're done */
569 ExFreePool(ClipSpans
);
570 ExFreePool(ScanLine
);
571 ExFreePool(ScanLineAhead
);
575 Target
= (PIXEL
*)((BYTE
*)Target
+ DestSurf
->lDelta
);
578 if (E
>= DestRect
->bottom
- DestRect
->top
) {
579 E
-= DestRect
->bottom
- DestRect
->top
;
580 Source
= (PIXEL
*)((BYTE
*)Source
+ SourceSurf
->lDelta
);
584 if (skip
> 0 && Source
!= PrevSource
)
585 ScaleLineAvg16(ScanLine
, Source
, SourceRect
->right
- SourceRect
->left
, DestRect
->right
- DestRect
->left
);
587 if (! FinalCopy16(Target
, ScanLine
, ClipSpans
, ClipSpansCount
, &SpanIndex
, DestY
, DestRect
))
589 /* No more spans, everything else is clipped away, we're done */
590 ExFreePool(ClipSpans
);
591 ExFreePool(ScanLine
);
592 ExFreePool(ScanLineAhead
);
596 Target
= (PIXEL
*)((BYTE
*)Target
+ DestSurf
->lDelta
);
599 ExFreePool(ClipSpans
);
600 ExFreePool(ScanLine
);
601 ExFreePool(ScanLineAhead
);
606 //NOTE: If you change something here, please do the same in other dibXXbpp.c files!
607 BOOLEAN
DIB_16BPP_StretchBlt(SURFOBJ
*DestSurf
, SURFOBJ
*SourceSurf
,
608 RECTL
* DestRect
, RECTL
*SourceRect
,
609 POINTL
* MaskOrigin
, POINTL BrushOrigin
,
610 CLIPOBJ
*ClipRegion
, XLATEOBJ
*ColorTranslation
,
627 BOOLEAN DesIsBiggerY
=FALSE
;
629 DPRINT("DIB_16BPP_StretchBlt: Source BPP: %u, srcRect: (%d,%d)-(%d,%d), dstRect: (%d,%d)-(%d,%d)\n",
630 BitsPerFormat(SourceSurf
->iBitmapFormat
), SourceRect
->left
, SourceRect
->top
, SourceRect
->right
, SourceRect
->bottom
,
631 DestRect
->left
, DestRect
->top
, DestRect
->right
, DestRect
->bottom
);
633 SrcSizeY
= SourceRect
->bottom
- SourceRect
->top
;
634 SrcSizeX
= SourceRect
->right
- SourceRect
->left
;
636 DesSizeY
= DestRect
->bottom
;
637 DesSizeX
= DestRect
->right
;
639 zoomX
= DesSizeX
/ SrcSizeX
;
640 if (zoomX
==0) zoomX
=1;
642 zoomY
= DesSizeY
/ SrcSizeY
;
643 if (zoomY
==0) zoomY
=1;
645 if (DesSizeY
>SrcSizeY
)
650 switch(SourceSurf
->iBitmapFormat
)
655 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
656 /* This is a reference implementation, it hasn't been optimized for speed */
659 /* Draw one Hline on X - Led to the Des Zoom In*/
660 if (DesSizeX
>SrcSizeX
)
662 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=DestRect
->top
; DesY
-=zoomY
)
665 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
667 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
669 if (sy
> SourceRect
->bottom
) break;
673 for (DesX
=DestRect
->right
-zoomX
; DesX
>=DestRect
->left
; DesX
-=zoomX
)
675 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
677 if (sx
> SourceRect
->right
) break;
679 saveX
= DesX
+ zoomX
;
681 if (DIB_1BPP_GetPixel(SourceSurf
, sx
, sy
) == 0)
682 for (count
=DesY
;count
<saveY
;count
++)
683 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, 0);
685 for (count
=DesY
;count
<saveY
;count
++)
686 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, 1);
693 /* Draw one Hline on X - Led to the Des Zoom Out*/
695 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=DestRect
->top
; DesY
-=zoomY
)
698 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
700 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
702 if (sy
> SourceRect
->bottom
) break;
706 for (DesX
=DestRect
->right
-zoomX
; DesX
>=DestRect
->left
; DesX
-=zoomX
)
708 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
710 if (sx
> SourceRect
->right
) break;
712 saveX
= DesX
+ zoomX
;
714 if (DIB_1BPP_GetPixel(SourceSurf
, sx
, sy
) == 0)
715 for (count
=DesY
;count
<saveY
;count
++)
716 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, 0);
718 for (count
=DesY
;count
<saveY
;count
++)
719 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, 1);
728 if (DesSizeX
>SrcSizeX
)
730 /* Draw one pixel on X - Led to the Des Zoom In*/
731 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=DestRect
->top
; DesY
-=zoomY
)
734 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
736 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
738 if (sy
> SourceRect
->bottom
) break;
742 for (DesX
=DestRect
->right
-zoomX
; DesX
>=DestRect
->left
; DesX
-=zoomX
)
744 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
746 if (sx
> SourceRect
->right
) break;
748 if (DIB_1BPP_GetPixel(SourceSurf
, sx
, sy
) == 0)
749 for (count
=DesY
;count
<saveY
;count
++)
750 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, 0);
752 for (count
=DesY
;count
<saveY
;count
++)
753 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, 1);
761 /* Draw one pixel on X - Led to the Des Zoom Out*/
762 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=DestRect
->top
; DesY
-=zoomY
)
765 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
767 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
769 if (sy
> SourceRect
->bottom
) break;
773 for (DesX
=DestRect
->right
-zoomX
; DesX
>=DestRect
->left
; DesX
-=zoomX
)
775 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
777 if (sx
> SourceRect
->right
) break;
779 if (DIB_1BPP_GetPixel(SourceSurf
, sx
, sy
) == 0)
780 for (count
=DesY
;count
<saveY
;count
++)
781 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, 0);
783 for (count
=DesY
;count
<saveY
;count
++)
784 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, 1);
793 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
794 /* This is a reference implementation, it hasn't been optimized for speed */
797 /* Draw one Hline on X - Led to the Des Zoom In*/
798 if (DesSizeX
>SrcSizeX
)
800 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=DestRect
->top
; DesY
-=zoomY
)
803 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
805 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
807 if (sy
> SourceRect
->bottom
) break;
811 for (DesX
=DestRect
->right
-zoomX
; DesX
>=DestRect
->left
; DesX
-=zoomX
)
813 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
815 if (sx
> SourceRect
->right
) break;
817 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_4BPP_GetPixel(SourceSurf
, sx
, sy
));
819 saveX
= DesX
+ zoomX
;
820 for (count
=DesY
;count
<saveY
;count
++)
821 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
827 /* Draw one Hline on X - Led to the Des Zoom Out*/
829 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=DestRect
->top
; DesY
-=zoomY
)
832 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
834 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
836 if (sy
> SourceRect
->bottom
) break;
840 for (DesX
=DestRect
->right
-zoomX
; DesX
>=DestRect
->left
; DesX
-=zoomX
)
842 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
844 if (sx
> SourceRect
->right
) break;
846 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_4BPP_GetPixel(SourceSurf
, sx
, sy
));
848 saveX
= DesX
+ zoomX
;
849 for (count
=DesY
;count
<saveY
;count
++)
850 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
859 if (DesSizeX
>SrcSizeX
)
861 /* Draw one pixel on X - Led to the Des Zoom In*/
862 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=DestRect
->top
; DesY
-=zoomY
)
865 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
867 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
869 if (sy
> SourceRect
->bottom
) break;
873 for (DesX
=DestRect
->right
-zoomX
; DesX
>=DestRect
->left
; DesX
-=zoomX
)
875 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
877 if (sx
> SourceRect
->right
) break;
879 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_4BPP_GetPixel(SourceSurf
, sx
, sy
));
881 for (count
=DesY
;count
<saveY
;count
++)
882 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, color
);
888 /* Draw one pixel on X - Led to the Des Zoom Out*/
889 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=DestRect
->top
; DesY
-=zoomY
)
892 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
894 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
896 if (sy
> SourceRect
->bottom
) break;
900 for (DesX
=DestRect
->right
-zoomX
; DesX
>=DestRect
->left
; DesX
-=zoomX
)
902 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
904 if (sx
> SourceRect
->right
) break;
906 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_4BPP_GetPixel(SourceSurf
, sx
, sy
));
908 for (count
=DesY
;count
<saveY
;count
++)
909 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, color
);
917 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
918 /* This is a reference implementation, it hasn't been optimized for speed */
921 /* Draw one Hline on X - Led to the Des Zoom In*/
922 if (DesSizeX
>SrcSizeX
)
924 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=DestRect
->top
; DesY
-=zoomY
)
927 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
929 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
931 if (sy
> SourceRect
->bottom
) break;
935 for (DesX
=DestRect
->right
-zoomX
; DesX
>=DestRect
->left
; DesX
-=zoomX
)
937 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
939 if (sx
> SourceRect
->right
) break;
941 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_8BPP_GetPixel(SourceSurf
, sx
, sy
));
943 saveX
= DesX
+ zoomX
;
944 for (count
=DesY
;count
<saveY
;count
++)
945 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
951 /* Draw one Hline on X - Led to the Des Zoom Out*/
953 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=DestRect
->top
; DesY
-=zoomY
)
956 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
958 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
960 if (sy
> SourceRect
->bottom
) break;
964 for (DesX
=DestRect
->right
-zoomX
; DesX
>=DestRect
->left
; DesX
-=zoomX
)
966 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
968 if (sx
> SourceRect
->right
) break;
970 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_8BPP_GetPixel(SourceSurf
, sx
, sy
));
972 saveX
= DesX
+ zoomX
;
973 for (count
=DesY
;count
<saveY
;count
++)
974 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
983 if (DesSizeX
>SrcSizeX
)
985 /* Draw one pixel on X - Led to the Des Zoom In*/
986 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=DestRect
->top
; DesY
-=zoomY
)
989 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
991 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
993 if (sy
> SourceRect
->bottom
) break;
997 for (DesX
=DestRect
->right
-zoomX
; DesX
>=DestRect
->left
; DesX
-=zoomX
)
999 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1001 if (sx
> SourceRect
->right
) break;
1003 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_8BPP_GetPixel(SourceSurf
, sx
, sy
));
1005 for (count
=DesY
;count
<saveY
;count
++)
1006 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1012 /* Draw one pixel on X - Led to the Des Zoom Out*/
1013 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=DestRect
->top
; DesY
-=zoomY
)
1016 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1018 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1020 if (sy
> SourceRect
->bottom
) break;
1024 for (DesX
=DestRect
->right
-zoomX
; DesX
>=DestRect
->left
; DesX
-=zoomX
)
1026 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1028 if (sx
> SourceRect
->right
) break;
1030 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_8BPP_GetPixel(SourceSurf
, sx
, sy
));
1032 for (count
=DesY
;count
<saveY
;count
++)
1033 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1041 return ScaleRectAvg16(DestSurf
, SourceSurf
, DestRect
, SourceRect
, MaskOrigin
, BrushOrigin
,
1042 ClipRegion
, ColorTranslation
, Mode
);
1046 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
1047 /* This is a reference implementation, it hasn't been optimized for speed */
1050 /* Draw one Hline on X - Led to the Des Zoom In*/
1051 if (DesSizeX
>SrcSizeX
)
1053 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=DestRect
->top
; DesY
-=zoomY
)
1056 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1058 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1060 if (sy
> SourceRect
->bottom
) break;
1064 for (DesX
=DestRect
->right
-zoomX
; DesX
>=DestRect
->left
; DesX
-=zoomX
)
1066 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1068 if (sx
> SourceRect
->right
) break;
1070 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_24BPP_GetPixel(SourceSurf
, sx
, sy
));
1072 saveX
= DesX
+ zoomX
;
1073 for (count
=DesY
;count
<saveY
;count
++)
1074 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1080 /* Draw one Hline on X - Led to the Des Zoom Out*/
1082 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=DestRect
->top
; DesY
-=zoomY
)
1085 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1087 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1089 if (sy
> SourceRect
->bottom
) break;
1093 for (DesX
=DestRect
->right
-zoomX
; DesX
>=DestRect
->left
; DesX
-=zoomX
)
1095 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1097 if (sx
> SourceRect
->right
) break;
1099 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_24BPP_GetPixel(SourceSurf
, sx
, sy
));
1101 saveX
= DesX
+ zoomX
;
1102 for (count
=DesY
;count
<saveY
;count
++)
1103 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1112 if (DesSizeX
>SrcSizeX
)
1114 /* Draw one pixel on X - Led to the Des Zoom In*/
1115 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=DestRect
->top
; DesY
-=zoomY
)
1118 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1120 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1122 if (sy
> SourceRect
->bottom
) break;
1126 for (DesX
=DestRect
->right
-zoomX
; DesX
>=DestRect
->left
; DesX
-=zoomX
)
1128 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1130 if (sx
> SourceRect
->right
) break;
1132 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_24BPP_GetPixel(SourceSurf
, sx
, sy
));
1134 for (count
=DesY
;count
<saveY
;count
++)
1135 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1141 /* Draw one pixel on X - Led to the Des Zoom Out*/
1142 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=DestRect
->top
; DesY
-=zoomY
)
1145 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1147 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1149 if (sy
> SourceRect
->bottom
) break;
1153 for (DesX
=DestRect
->right
-zoomX
; DesX
>=DestRect
->left
; DesX
-=zoomX
)
1155 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1157 if (sx
> SourceRect
->right
) break;
1159 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_24BPP_GetPixel(SourceSurf
, sx
, sy
));
1161 for (count
=DesY
;count
<saveY
;count
++)
1162 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1170 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
1171 /* This is a reference implementation, it hasn't been optimized for speed */
1174 /* Draw one Hline on X - Led to the Des Zoom In*/
1175 if (DesSizeX
>SrcSizeX
)
1177 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=DestRect
->top
; DesY
-=zoomY
)
1180 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1182 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1184 if (sy
> SourceRect
->bottom
) break;
1188 for (DesX
=DestRect
->right
-zoomX
; DesX
>=DestRect
->left
; DesX
-=zoomX
)
1190 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1192 if (sx
> SourceRect
->right
) break;
1194 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_32BPP_GetPixel(SourceSurf
, sx
, sy
));
1196 saveX
= DesX
+ zoomX
;
1197 for (count
=DesY
;count
<saveY
;count
++)
1198 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1204 /* Draw one Hline on X - Led to the Des Zoom Out*/
1206 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=DestRect
->top
; DesY
-=zoomY
)
1209 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1211 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1213 if (sy
> SourceRect
->bottom
) break;
1217 for (DesX
=DestRect
->right
-zoomX
; DesX
>=DestRect
->left
; DesX
-=zoomX
)
1219 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1221 if (sx
> SourceRect
->right
) break;
1223 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_32BPP_GetPixel(SourceSurf
, sx
, sy
));
1225 saveX
= DesX
+ zoomX
;
1226 for (count
=DesY
;count
<saveY
;count
++)
1227 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1236 if (DesSizeX
>SrcSizeX
)
1238 /* Draw one pixel on X - Led to the Des Zoom In*/
1239 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=DestRect
->top
; DesY
-=zoomY
)
1242 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1244 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1246 if (sy
> SourceRect
->bottom
) break;
1250 for (DesX
=DestRect
->right
-zoomX
; DesX
>=DestRect
->left
; DesX
-=zoomX
)
1252 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1254 if (sx
> SourceRect
->right
) break;
1256 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_32BPP_GetPixel(SourceSurf
, sx
, sy
));
1258 for (count
=DesY
;count
<saveY
;count
++)
1259 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1265 /* Draw one pixel on X - Led to the Des Zoom Out*/
1266 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=DestRect
->top
; DesY
-=zoomY
)
1269 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1271 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1273 if (sy
> SourceRect
->bottom
) break;
1277 for (DesX
=DestRect
->right
-zoomX
; DesX
>=DestRect
->left
; DesX
-=zoomX
)
1279 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1281 if (sx
> SourceRect
->right
) break;
1283 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_32BPP_GetPixel(SourceSurf
, sx
, sy
));
1285 for (count
=DesY
;count
<saveY
;count
++)
1286 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1296 DPRINT1("DIB_16BPP_StretchBlt: Unhandled Source BPP: %u\n", BitsPerFormat(SourceSurf
->iBitmapFormat
));
1306 DIB_16BPP_TransparentBlt(SURFOBJ
*DestSurf
, SURFOBJ
*SourceSurf
,
1307 RECTL
* DestRect
, POINTL
*SourcePoint
,
1308 XLATEOBJ
*ColorTranslation
, ULONG iTransColor
)
1310 ULONG RoundedRight
, X
, Y
, SourceX
, SourceY
, Source
, wd
, Dest
;
1313 RoundedRight
= DestRect
->right
- ((DestRect
->right
- DestRect
->left
) & 0x1);
1314 SourceY
= SourcePoint
->y
;
1315 DestBits
= (ULONG
*)((PBYTE
)DestSurf
->pvScan0
+
1316 (DestRect
->left
<< 1) +
1317 DestRect
->top
* DestSurf
->lDelta
);
1318 wd
= DestSurf
->lDelta
- ((DestRect
->right
- DestRect
->left
) << 1);
1320 for(Y
= DestRect
->top
; Y
< DestRect
->bottom
; Y
++)
1322 SourceX
= SourcePoint
->x
;
1323 for(X
= DestRect
->left
; X
< RoundedRight
; X
+= 2, DestBits
++, SourceX
+= 2)
1327 Source
= DIB_GetSourceIndex(SourceSurf
, SourceX
, SourceY
);
1328 if(Source
!= iTransColor
)
1331 Dest
|= (XLATEOBJ_iXlate(ColorTranslation
, Source
) & 0xFFFF);
1334 Source
= DIB_GetSourceIndex(SourceSurf
, SourceX
+ 1, SourceY
);
1335 if(Source
!= iTransColor
)
1338 Dest
|= (XLATEOBJ_iXlate(ColorTranslation
, Source
) << 16);
1344 if(X
< DestRect
->right
)
1346 Source
= DIB_GetSourceIndex(SourceSurf
, SourceX
, SourceY
);
1347 if(Source
!= iTransColor
)
1349 *((USHORT
*)DestBits
) = (USHORT
)XLATEOBJ_iXlate(ColorTranslation
, Source
);
1352 DestBits
= (PULONG
)((ULONG_PTR
)DestBits
+ 2);
1355 DestBits
= (ULONG
*)((ULONG_PTR
)DestBits
+ wd
);
1383 return (val
> 31) ? 31 : val
;
1389 return (val
> 63) ? 63 : val
;
1393 DIB_16BPP_AlphaBlend(SURFOBJ
* Dest
, SURFOBJ
* Source
, RECTL
* DestRect
,
1394 RECTL
* SourceRect
, CLIPOBJ
* ClipRegion
,
1395 XLATEOBJ
* ColorTranslation
, BLENDOBJ
* BlendObj
)
1397 INT Rows
, Cols
, SrcX
, SrcY
;
1398 register PUSHORT Dst
;
1400 BLENDFUNCTION BlendFunc
;
1401 register NICEPIXEL16 DstPixel
;
1402 register NICEPIXEL32 SrcPixel
;
1403 UCHAR Alpha
, SrcBpp
;
1405 DPRINT("DIB_16BPP_AlphaBlend: srcRect: (%d,%d)-(%d,%d), dstRect: (%d,%d)-(%d,%d)\n",
1406 SourceRect
->left
, SourceRect
->top
, SourceRect
->right
, SourceRect
->bottom
,
1407 DestRect
->left
, DestRect
->top
, DestRect
->right
, DestRect
->bottom
);
1409 ASSERT(DestRect
->bottom
- DestRect
->top
== SourceRect
->bottom
- SourceRect
->top
&&
1410 DestRect
->right
- DestRect
->left
== SourceRect
->right
- SourceRect
->left
);
1412 BlendFunc
= BlendObj
->BlendFunction
;
1413 if (BlendFunc
.BlendOp
!= AC_SRC_OVER
)
1415 DPRINT1("BlendOp != AC_SRC_OVER\n");
1418 if (BlendFunc
.BlendFlags
!= 0)
1420 DPRINT1("BlendFlags != 0\n");
1423 if ((BlendFunc
.AlphaFormat
& ~AC_SRC_ALPHA
) != 0)
1425 DPRINT1("Unsupported AlphaFormat (0x%x)\n", BlendFunc
.AlphaFormat
);
1428 if ((BlendFunc
.AlphaFormat
& AC_SRC_ALPHA
) != 0 &&
1429 BitsPerFormat(Source
->iBitmapFormat
) != 32)
1431 DPRINT1("Source bitmap must be 32bpp when AC_SRC_ALPHA is set\n");
1435 Dst
= (PUSHORT
)((ULONG_PTR
)Dest
->pvScan0
+ (DestRect
->top
* Dest
->lDelta
) +
1436 (DestRect
->left
<< 1));
1437 DstDelta
= Dest
->lDelta
- ((DestRect
->right
- DestRect
->left
) << 1);
1438 SrcBpp
= BitsPerFormat(Source
->iBitmapFormat
);
1440 Rows
= DestRect
->bottom
- DestRect
->top
;
1441 SrcY
= SourceRect
->top
;
1444 Cols
= DestRect
->right
- DestRect
->left
;
1445 SrcX
= SourceRect
->left
;
1450 DstPixel
.us
= DIB_GetSource(Source
, SrcX
++, SrcY
, ColorTranslation
);
1451 SrcPixel
.col
.red
= (DstPixel
.col
.red
<< 3) | (DstPixel
.col
.red
>> 2);
1452 SrcPixel
.col
.green
= (DstPixel
.col
.green
<< 2) | (DstPixel
.col
.green
>> 4);
1453 SrcPixel
.col
.blue
= (DstPixel
.col
.blue
<< 3) | (DstPixel
.col
.blue
>> 2);
1457 SrcPixel
.ul
= DIB_GetSourceIndex(Source
, SrcX
++, SrcY
);
1459 SrcPixel
.col
.red
= SrcPixel
.col
.red
* BlendFunc
.SourceConstantAlpha
/ 255;
1460 SrcPixel
.col
.green
= SrcPixel
.col
.green
* BlendFunc
.SourceConstantAlpha
/ 255;
1461 SrcPixel
.col
.blue
= SrcPixel
.col
.blue
* BlendFunc
.SourceConstantAlpha
/ 255;
1462 SrcPixel
.col
.alpha
= (SrcBpp
== 32) ? (SrcPixel
.col
.alpha
* BlendFunc
.SourceConstantAlpha
/ 255) : BlendFunc
.SourceConstantAlpha
;
1464 Alpha
= ((BlendFunc
.AlphaFormat
& AC_SRC_ALPHA
) != 0) ?
1465 SrcPixel
.col
.alpha
: BlendFunc
.SourceConstantAlpha
;
1468 DstPixel
.col
.red
= Clamp5(DstPixel
.col
.red
* (255 - Alpha
) / 255 + (SrcPixel
.col
.red
>> 3));
1469 DstPixel
.col
.green
= Clamp6(DstPixel
.col
.green
* (255 - Alpha
) / 255 + (SrcPixel
.col
.green
>> 2));
1470 DstPixel
.col
.blue
= Clamp5(DstPixel
.col
.blue
* (255 - Alpha
) / 255 + (SrcPixel
.col
.blue
>> 3));
1471 *Dst
++ = DstPixel
.us
;
1473 Dst
= (PUSHORT
)((ULONG_PTR
)Dst
+ DstDelta
);