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_16BPP_PutPixel(SURFOBJ
*SurfObj
, LONG x
, LONG y
, ULONG c
)
29 PBYTE byteaddr
= SurfObj
->pvScan0
+ y
* SurfObj
->lDelta
;
30 PWORD addr
= (PWORD
)byteaddr
+ x
;
36 DIB_16BPP_GetPixel(SURFOBJ
*SurfObj
, LONG x
, LONG y
)
38 PBYTE byteaddr
= SurfObj
->pvScan0
+ y
* SurfObj
->lDelta
;
39 PWORD addr
= (PWORD
)byteaddr
+ x
;
41 return (ULONG
)(*addr
);
45 DIB_16BPP_HLine(SURFOBJ
*SurfObj
, LONG x1
, LONG x2
, LONG y
, ULONG c
)
47 PDWORD addr
= (PDWORD
)((PWORD
)(SurfObj
->pvScan0
+ y
* SurfObj
->lDelta
) + x1
);
51 /* This is about 10% faster than the generic C code below */
54 __asm__
__volatile__ (
58 " andl $0xffff, %0\n" /* If the pixel value is "abcd", put "abcdabcd" in %eax */
61 " test $0x03, %%edi\n" /* Align to fullword boundary */
67 " mov %1,%%ecx\n" /* Setup count of fullwords to fill */
69 " rep stosl\n" /* The actual fill */
70 " test $0x01, %1\n" /* One left to do at the right side? */
75 : "r"(c
), "r"(Count
), "m"(addr
)
76 : "%eax", "%ecx", "%edi");
81 if (0 != (cx
& 0x01)) {
84 addr
= (PDWORD
)((PWORD
)(addr
) + 1);
86 cc
= ((c
& 0xffff) << 16) | (c
& 0xffff);
99 DIB_16BPP_VLine(SURFOBJ
*SurfObj
, LONG x
, LONG y1
, LONG y2
, ULONG c
)
103 " testl %2, %2" "\n\t"
105 " movl %2, %%ecx" "\n\t"
106 " shrl $2, %2" "\n\t"
107 " andl $3, %%ecx" "\n\t"
110 " movw %%ax, (%0)" "\n\t"
111 " addl %1, %0" "\n\t"
114 " testl %2, %2" "\n\t"
117 " movw %%ax, (%0)" "\n\t"
118 " addl %1, %0" "\n\t"
119 " movw %%ax, (%0)" "\n\t"
120 " addl %1, %0" "\n\t"
121 " movw %%ax, (%0)" "\n\t"
122 " addl %1, %0" "\n\t"
123 " movw %%ax, (%0)" "\n\t"
124 " addl %1, %0" "\n\t"
129 : "r"(SurfObj
->pvScan0
+ (y1
* SurfObj
->lDelta
) + (x
* sizeof (WORD
))),
130 "r"(SurfObj
->lDelta
), "r"(y2
- y1
), "a"(c
)
131 : "cc", "memory", "%ecx");
133 PBYTE byteaddr
= SurfObj
->pvScan0
+ y1
* SurfObj
->lDelta
;
134 PWORD addr
= (PWORD
)byteaddr
+ x
;
135 LONG lDelta
= SurfObj
->lDelta
;
137 byteaddr
= (PBYTE
)addr
;
142 addr
= (PWORD
)byteaddr
;
148 DIB_16BPP_BitBltSrcCopy(PBLTINFO BltInfo
)
150 LONG i
, j
, sx
, sy
, xColor
, f1
;
151 PBYTE SourceBits
, DestBits
, SourceLine
, DestLine
;
152 PBYTE SourceBits_4BPP
, SourceLine_4BPP
;
153 DestBits
= BltInfo
->DestSurface
->pvScan0
+ (BltInfo
->DestRect
.top
* BltInfo
->DestSurface
->lDelta
) + 2 * BltInfo
->DestRect
.left
;
155 switch(BltInfo
->SourceSurface
->iBitmapFormat
)
158 sx
= BltInfo
->SourcePoint
.x
;
159 sy
= BltInfo
->SourcePoint
.y
;
161 for (j
=BltInfo
->DestRect
.top
; j
<BltInfo
->DestRect
.bottom
; j
++)
163 sx
= BltInfo
->SourcePoint
.x
;
164 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
166 if(DIB_1BPP_GetPixel(BltInfo
->SourceSurface
, sx
, sy
) == 0)
168 DIB_16BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, 0));
170 DIB_16BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, 1));
179 SourceBits_4BPP
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + (BltInfo
->SourcePoint
.x
>> 1);
181 for (j
=BltInfo
->DestRect
.top
; j
<BltInfo
->DestRect
.bottom
; j
++)
183 SourceLine_4BPP
= SourceBits_4BPP
;
184 sx
= BltInfo
->SourcePoint
.x
;
187 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
189 xColor
= XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
,
190 (*SourceLine_4BPP
& altnotmask
[f1
]) >> (4 * (1 - f1
)));
191 DIB_16BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, xColor
);
192 if(f1
== 1) { SourceLine_4BPP
++; f1
= 0; } else { f1
= 1; }
196 SourceBits_4BPP
+= BltInfo
->SourceSurface
->lDelta
;
201 SourceLine
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + BltInfo
->SourcePoint
.x
;
204 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
206 SourceBits
= SourceLine
;
209 for (i
= BltInfo
->DestRect
.left
; i
< BltInfo
->DestRect
.right
; i
++)
211 *((WORD
*)DestBits
) = (WORD
)XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, *SourceBits
);
216 SourceLine
+= BltInfo
->SourceSurface
->lDelta
;
217 DestLine
+= BltInfo
->DestSurface
->lDelta
;
222 if (NULL
== BltInfo
->XlateSourceToDest
|| 0 != (BltInfo
->XlateSourceToDest
->flXlate
& XO_TRIVIAL
))
224 if (BltInfo
->DestRect
.top
< BltInfo
->SourcePoint
.y
)
226 SourceBits
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + 2 * BltInfo
->SourcePoint
.x
;
227 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
229 RtlMoveMemory(DestBits
, SourceBits
, 2 * (BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
));
230 SourceBits
+= BltInfo
->SourceSurface
->lDelta
;
231 DestBits
+= BltInfo
->DestSurface
->lDelta
;
236 SourceBits
= BltInfo
->SourceSurface
->pvScan0
+ ((BltInfo
->SourcePoint
.y
+ BltInfo
->DestRect
.bottom
- BltInfo
->DestRect
.top
- 1) * BltInfo
->SourceSurface
->lDelta
) + 2 * BltInfo
->SourcePoint
.x
;
237 DestBits
= BltInfo
->DestSurface
->pvScan0
+ ((BltInfo
->DestRect
.bottom
- 1) * BltInfo
->DestSurface
->lDelta
) + 2 * BltInfo
->DestRect
.left
;
238 for (j
= BltInfo
->DestRect
.bottom
- 1; BltInfo
->DestRect
.top
<= j
; j
--)
240 RtlMoveMemory(DestBits
, SourceBits
, 2 * (BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
));
241 SourceBits
-= BltInfo
->SourceSurface
->lDelta
;
242 DestBits
-= BltInfo
->DestSurface
->lDelta
;
248 if (BltInfo
->DestRect
.top
< BltInfo
->SourcePoint
.y
)
250 SourceLine
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + 2 * BltInfo
->SourcePoint
.x
;
252 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
254 SourceBits
= SourceLine
;
256 for (i
= BltInfo
->DestRect
.left
; i
< BltInfo
->DestRect
.right
; i
++)
258 *((WORD
*)DestBits
) = (WORD
)XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, *((WORD
*)SourceBits
));
262 SourceLine
+= BltInfo
->SourceSurface
->lDelta
;
263 DestLine
+= BltInfo
->DestSurface
->lDelta
;
268 SourceLine
= BltInfo
->SourceSurface
->pvScan0
+ ((BltInfo
->SourcePoint
.y
+ BltInfo
->DestRect
.bottom
- BltInfo
->DestRect
.top
- 1) * BltInfo
->SourceSurface
->lDelta
) + 2 * BltInfo
->SourcePoint
.x
;
269 DestLine
= BltInfo
->DestSurface
->pvScan0
+ ((BltInfo
->DestRect
.bottom
- 1) * BltInfo
->DestSurface
->lDelta
) + 2 * BltInfo
->DestRect
.left
;
270 for (j
= BltInfo
->DestRect
.bottom
- 1; BltInfo
->DestRect
.top
<= j
; j
--)
272 SourceBits
= SourceLine
;
274 for (i
= BltInfo
->DestRect
.left
; i
< BltInfo
->DestRect
.right
; i
++)
276 *((WORD
*)DestBits
) = (WORD
)XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, *((WORD
*)SourceBits
));
280 SourceLine
-= BltInfo
->SourceSurface
->lDelta
;
281 DestLine
-= BltInfo
->DestSurface
->lDelta
;
288 SourceLine
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + 3 * BltInfo
->SourcePoint
.x
;
291 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
293 SourceBits
= SourceLine
;
296 for (i
= BltInfo
->DestRect
.left
; i
< BltInfo
->DestRect
.right
; i
++)
298 xColor
= (*(SourceBits
+ 2) << 0x10) +
299 (*(SourceBits
+ 1) << 0x08) +
301 *((WORD
*)DestBits
) = (WORD
)XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, xColor
);
306 SourceLine
+= BltInfo
->SourceSurface
->lDelta
;
307 DestLine
+= BltInfo
->DestSurface
->lDelta
;
312 SourceLine
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + 4 * BltInfo
->SourcePoint
.x
;
315 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
317 SourceBits
= SourceLine
;
320 for (i
= BltInfo
->DestRect
.left
; i
< BltInfo
->DestRect
.right
; i
++)
322 *((WORD
*)DestBits
) = (WORD
)XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, *((PDWORD
) SourceBits
));
327 SourceLine
+= BltInfo
->SourceSurface
->lDelta
;
328 DestLine
+= BltInfo
->DestSurface
->lDelta
;
333 DPRINT1("DIB_16BPP_Bitblt: Unhandled Source BPP: %u\n", BitsPerFormat(BltInfo
->SourceSurface
->iBitmapFormat
));
341 DIB_16BPP_BitBlt(PBLTINFO BltInfo
)
344 ULONG SourceX
, SourceY
;
346 ULONG Dest
, Source
= 0, Pattern
= 0;
352 UsesSource
= ROP4_USES_SOURCE(BltInfo
->Rop4
);
353 UsesPattern
= ROP4_USES_PATTERN(BltInfo
->Rop4
);
355 RoundedRight
= BltInfo
->DestRect
.right
-
356 ((BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
) & 0x1);
357 SourceY
= BltInfo
->SourcePoint
.y
;
359 BltInfo
->DestSurface
->pvScan0
+
360 (BltInfo
->DestRect
.left
<< 1) +
361 BltInfo
->DestRect
.top
* BltInfo
->DestSurface
->lDelta
);
365 if (BltInfo
->PatternSurface
)
367 PatternY
= (BltInfo
->DestRect
.top
+ BltInfo
->BrushOrigin
.y
) %
368 BltInfo
->PatternSurface
->sizlBitmap
.cy
;
372 Pattern
= BltInfo
->Brush
->iSolidColor
|
373 (BltInfo
->Brush
->iSolidColor
<< 16);
377 for (DestY
= BltInfo
->DestRect
.top
; DestY
< BltInfo
->DestRect
.bottom
; DestY
++)
379 SourceX
= BltInfo
->SourcePoint
.x
;
381 for (DestX
= BltInfo
->DestRect
.left
; DestX
< RoundedRight
; DestX
+= 2, DestBits
++, SourceX
+= 2)
387 Source
= DIB_GetSource(BltInfo
->SourceSurface
, SourceX
, SourceY
, BltInfo
->XlateSourceToDest
);
388 Source
|= DIB_GetSource(BltInfo
->SourceSurface
, SourceX
+ 1, SourceY
, BltInfo
->XlateSourceToDest
) << 16;
391 if (BltInfo
->PatternSurface
)
393 Pattern
= DIB_GetSource(BltInfo
->PatternSurface
, (DestX
+ BltInfo
->BrushOrigin
.x
) % BltInfo
->PatternSurface
->sizlBitmap
.cx
, PatternY
, BltInfo
->XlatePatternToDest
);
394 Pattern
|= DIB_GetSource(BltInfo
->PatternSurface
, (DestX
+ BltInfo
->BrushOrigin
.x
+ 1) % BltInfo
->PatternSurface
->sizlBitmap
.cx
, PatternY
, BltInfo
->XlatePatternToDest
) << 16;
397 *DestBits
= DIB_DoRop(BltInfo
->Rop4
, Dest
, Source
, Pattern
);
400 if (DestX
< BltInfo
->DestRect
.right
)
402 Dest
= *((PUSHORT
)DestBits
);
406 Source
= DIB_GetSource(BltInfo
->SourceSurface
, SourceX
, SourceY
, BltInfo
->XlateSourceToDest
);
409 if (BltInfo
->PatternSurface
)
411 Pattern
= DIB_GetSource(BltInfo
->PatternSurface
, (DestX
+ BltInfo
->BrushOrigin
.x
) % BltInfo
->PatternSurface
->sizlBitmap
.cx
, PatternY
, BltInfo
->XlatePatternToDest
);
414 DIB_16BPP_PutPixel(BltInfo
->DestSurface
, DestX
, DestY
, DIB_DoRop(BltInfo
->Rop4
, Dest
, Source
, Pattern
) & 0xFFFF);
415 DestBits
= (PULONG
)((ULONG_PTR
)DestBits
+ 2);
419 if (BltInfo
->PatternSurface
)
422 PatternY
%= BltInfo
->PatternSurface
->sizlBitmap
.cy
;
425 (ULONG_PTR
)DestBits
-
426 ((BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
) << 1) +
427 BltInfo
->DestSurface
->lDelta
);
433 /* Optimize for bitBlt */
435 DIB_16BPP_ColorFill(SURFOBJ
* DestSurface
, RECTL
* DestRect
, ULONG color
)
440 /* This is about 10% faster than the generic C code below */
441 ULONG delta
= DestSurface
->lDelta
;
442 ULONG width
= (DestRect
->right
- DestRect
->left
) ;
443 PULONG pos
= (PULONG
) (DestSurface
->pvScan0
+ DestRect
->top
* delta
+ (DestRect
->left
<<1));
444 color
= (color
&0xffff); /* If the color value is "abcd", put "abcdabcd" into color */
445 color
+= (color
<<16);
447 for (DestY
= DestRect
->top
; DestY
< DestRect
->bottom
; DestY
++)
449 __asm__
__volatile__ (
453 " test $0x03, %%edi\n" /* Align to fullword boundary */
459 " mov %%ebx,%%ecx\n" /* Setup count of fullwords to fill */
461 " rep stosl\n" /* The actual fill */
462 " test $0x01, %%ebx\n" /* One left to do at the right side? */
467 : "a" (color
), "r" (width
), "m" (pos
)
468 : "%ecx", "%ebx", "%edi");
469 pos
=(PULONG
)((ULONG_PTR
)pos
+ delta
);
474 for (DestY
= DestRect
->top
; DestY
< DestRect
->bottom
; DestY
++)
476 DIB_16BPP_HLine (DestSurface
, DestRect
->left
, DestRect
->right
, DestY
, color
);
482 =======================================
483 Stretching functions goes below
484 Some parts of code are based on an
485 article "Bresenhame image scaling"
486 Dr. Dobb Journal, May 2002
487 =======================================
490 typedef unsigned short PIXEL
;
492 /* 16-bit HiColor (565 format) */
493 inline PIXEL
average16(PIXEL a
, PIXEL b
)
495 // This one doesn't work
500 unsigned short mask = ~ (((a | b) & 0x0410) << 1);
501 return ((a & mask) + (b & mask)) >> 1;
504 // This one should be correct, but it's too long
506 unsigned char r1, g1, b1, r2, g2, b2, rr, gr, br;
509 r1 = (a & 0xF800) >> 11;
510 g1 = (a & 0x7E0) >> 5;
513 r2 = (b & 0xF800) >> 11;
514 g2 = (b & 0x7E0) >> 5;
521 res = (rr << 11) + (gr << 5) + br;
525 return a
; // FIXME: Depend on SetStretchMode
528 //NOTE: If you change something here, please do the same in other dibXXbpp.c files!
529 void ScaleLineAvg16(PIXEL
*Target
, PIXEL
*Source
, int SrcWidth
, int TgtWidth
)
531 int NumPixels
= TgtWidth
;
532 int IntPart
= SrcWidth
/ TgtWidth
;
533 int FractPart
= SrcWidth
% TgtWidth
;
534 int Mid
= TgtWidth
>> 1;
539 skip
= (TgtWidth
< SrcWidth
) ? 0 : (TgtWidth
/ (2*SrcWidth
) + 1);
542 while (NumPixels
-- > 0) {
545 p
= average16(p
, *(Source
+1));
559 FinalCopy16(PIXEL
*Target
, PIXEL
*Source
, PSPAN ClipSpans
, UINT ClipSpansCount
, UINT
*SpanIndex
,
560 UINT DestY
, RECTL
*DestRect
)
564 while (ClipSpans
[*SpanIndex
].Y
< DestY
565 || (ClipSpans
[*SpanIndex
].Y
== DestY
566 && ClipSpans
[*SpanIndex
].X
+ ClipSpans
[*SpanIndex
].Width
< DestRect
->left
))
569 if (ClipSpansCount
<= *SpanIndex
)
571 /* No more spans, everything else is clipped away, we're done */
575 while (ClipSpans
[*SpanIndex
].Y
== DestY
)
577 if (ClipSpans
[*SpanIndex
].X
< DestRect
->right
)
579 Left
= max(ClipSpans
[*SpanIndex
].X
, DestRect
->left
);
580 Right
= min(ClipSpans
[*SpanIndex
].X
+ ClipSpans
[*SpanIndex
].Width
, DestRect
->right
);
581 memcpy(Target
+ Left
- DestRect
->left
, Source
+ Left
- DestRect
->left
,
582 (Right
- Left
) * sizeof(PIXEL
));
585 if (ClipSpansCount
<= *SpanIndex
)
587 /* No more spans, everything else is clipped away, we're done */
595 //NOTE: If you change something here, please do the same in other dibXXbpp.c files!
596 BOOLEAN
ScaleRectAvg16(SURFOBJ
*DestSurf
, SURFOBJ
*SourceSurf
,
597 RECTL
* DestRect
, RECTL
*SourceRect
,
598 POINTL
* MaskOrigin
, POINTL BrushOrigin
,
599 CLIPOBJ
*ClipRegion
, XLATEOBJ
*ColorTranslation
,
602 int NumPixels
= DestRect
->bottom
- DestRect
->top
;
603 int IntPart
= (((SourceRect
->bottom
- SourceRect
->top
) / (DestRect
->bottom
- DestRect
->top
)) * SourceSurf
->lDelta
) >> 1;
604 int FractPart
= (SourceRect
->bottom
- SourceRect
->top
) % (DestRect
->bottom
- DestRect
->top
);
605 int Mid
= (DestRect
->bottom
- DestRect
->top
) >> 1;
608 PIXEL
*ScanLine
, *ScanLineAhead
;
609 PIXEL
*PrevSource
= NULL
;
610 PIXEL
*PrevSourceAhead
= NULL
;
611 PIXEL
*Target
= (PIXEL
*) (DestSurf
->pvScan0
+ (DestRect
->top
* DestSurf
->lDelta
) + 2 * DestRect
->left
);
612 PIXEL
*Source
= (PIXEL
*) (SourceSurf
->pvScan0
+ (SourceRect
->top
* SourceSurf
->lDelta
) + 2 * SourceRect
->left
);
618 if (! ClipobjToSpans(&ClipSpans
, &ClipSpansCount
, ClipRegion
, DestRect
))
622 if (0 == ClipSpansCount
)
624 /* No clip spans == empty clipping region, everything clipped away */
625 ASSERT(NULL
== ClipSpans
);
628 skip
= (DestRect
->bottom
- DestRect
->top
< SourceRect
->bottom
- SourceRect
->top
) ? 0 : ((DestRect
->bottom
- DestRect
->top
) / (2 * (SourceRect
->bottom
- SourceRect
->top
)) + 1);
631 ScanLine
= (PIXEL
*)ExAllocatePool(PagedPool
, (DestRect
->right
- DestRect
->left
) * sizeof(PIXEL
));
632 ScanLineAhead
= (PIXEL
*)ExAllocatePool(PagedPool
, (DestRect
->right
- DestRect
->left
) * sizeof(PIXEL
));
634 DestY
= DestRect
->top
;
636 while (NumPixels
-- > 0) {
637 if (Source
!= PrevSource
) {
638 if (Source
== PrevSourceAhead
) {
639 /* the next scan line has already been scaled and stored in
640 * ScanLineAhead; swap the buffers that ScanLine and ScanLineAhead
643 PIXEL
*tmp
= ScanLine
;
644 ScanLine
= ScanLineAhead
;
647 ScaleLineAvg16(ScanLine
, Source
, SourceRect
->right
- SourceRect
->left
, DestRect
->right
- DestRect
->left
);
652 if (E
>= Mid
&& PrevSourceAhead
!= (PIXEL
*)((BYTE
*)Source
+ SourceSurf
->lDelta
)) {
654 ScaleLineAvg16(ScanLineAhead
, (PIXEL
*)((BYTE
*)Source
+ SourceSurf
->lDelta
), SourceRect
->right
- SourceRect
->left
, DestRect
->right
- DestRect
->left
);
655 for (x
= 0; x
< DestRect
->right
- DestRect
->left
; x
++)
656 ScanLine
[x
] = average16(ScanLine
[x
], ScanLineAhead
[x
]);
657 PrevSourceAhead
= (PIXEL
*)((BYTE
*)Source
+ SourceSurf
->lDelta
);
660 if (! FinalCopy16(Target
, ScanLine
, ClipSpans
, ClipSpansCount
, &SpanIndex
, DestY
, DestRect
))
662 /* No more spans, everything else is clipped away, we're done */
663 ExFreePool(ClipSpans
);
664 ExFreePool(ScanLine
);
665 ExFreePool(ScanLineAhead
);
669 Target
= (PIXEL
*)((BYTE
*)Target
+ DestSurf
->lDelta
);
672 if (E
>= DestRect
->bottom
- DestRect
->top
) {
673 E
-= DestRect
->bottom
- DestRect
->top
;
674 Source
= (PIXEL
*)((BYTE
*)Source
+ SourceSurf
->lDelta
);
678 if (skip
> 0 && Source
!= PrevSource
)
679 ScaleLineAvg16(ScanLine
, Source
, SourceRect
->right
- SourceRect
->left
, DestRect
->right
- DestRect
->left
);
681 if (! FinalCopy16(Target
, ScanLine
, ClipSpans
, ClipSpansCount
, &SpanIndex
, DestY
, DestRect
))
683 /* No more spans, everything else is clipped away, we're done */
684 ExFreePool(ClipSpans
);
685 ExFreePool(ScanLine
);
686 ExFreePool(ScanLineAhead
);
690 Target
= (PIXEL
*)((BYTE
*)Target
+ DestSurf
->lDelta
);
693 ExFreePool(ClipSpans
);
694 ExFreePool(ScanLine
);
695 ExFreePool(ScanLineAhead
);
700 //NOTE: If you change something here, please do the same in other dibXXbpp.c files!
701 BOOLEAN
DIB_16BPP_StretchBlt(SURFOBJ
*DestSurf
, SURFOBJ
*SourceSurf
,
702 RECTL
* DestRect
, RECTL
*SourceRect
,
703 POINTL
* MaskOrigin
, POINTL BrushOrigin
,
704 CLIPOBJ
*ClipRegion
, XLATEOBJ
*ColorTranslation
,
721 BOOLEAN DesIsBiggerY
=FALSE
;
723 DPRINT("DIB_16BPP_StretchBlt: Source BPP: %u, srcRect: (%d,%d)-(%d,%d), dstRect: (%d,%d)-(%d,%d)\n",
724 BitsPerFormat(SourceSurf
->iBitmapFormat
), SourceRect
->left
, SourceRect
->top
, SourceRect
->right
, SourceRect
->bottom
,
725 DestRect
->left
, DestRect
->top
, DestRect
->right
, DestRect
->bottom
);
727 SrcSizeY
= SourceRect
->bottom
;
728 SrcSizeX
= SourceRect
->right
;
730 DesSizeY
= DestRect
->bottom
;
731 DesSizeX
= DestRect
->right
;
733 zoomX
= DesSizeX
/ SrcSizeX
;
734 if (zoomX
==0) zoomX
=1;
736 zoomY
= DesSizeY
/ SrcSizeY
;
737 if (zoomY
==0) zoomY
=1;
739 if (DesSizeY
>SrcSizeY
)
744 switch(SourceSurf
->iBitmapFormat
)
749 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
750 /* This is a reference implementation, it hasn't been optimized for speed */
753 /* Draw one Hline on X - Led to the Des Zoom In*/
754 if (DesSizeX
>SrcSizeX
)
756 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
759 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
761 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
763 if (sy
> SourceRect
->bottom
) break;
767 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
769 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
771 if (sx
> SourceRect
->right
) break;
773 saveX
= DesX
+ zoomX
;
775 if (DIB_1BPP_GetPixel(SourceSurf
, sx
, sy
) == 0)
776 for (count
=DesY
;count
<saveY
;count
++)
777 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, 0);
779 for (count
=DesY
;count
<saveY
;count
++)
780 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, 1);
787 /* Draw one Hline on X - Led to the Des Zoom Out*/
789 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
792 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
794 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
796 if (sy
> SourceRect
->bottom
) break;
800 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
802 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
804 if (sx
> SourceRect
->right
) break;
806 saveX
= DesX
+ zoomX
;
808 if (DIB_1BPP_GetPixel(SourceSurf
, sx
, sy
) == 0)
809 for (count
=DesY
;count
<saveY
;count
++)
810 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, 0);
812 for (count
=DesY
;count
<saveY
;count
++)
813 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, 1);
822 if (DesSizeX
>SrcSizeX
)
824 /* Draw one pixel on X - Led to the Des Zoom In*/
825 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
828 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
830 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
832 if (sy
> SourceRect
->bottom
) break;
836 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
838 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
840 if (sx
> SourceRect
->right
) break;
842 if (DIB_1BPP_GetPixel(SourceSurf
, sx
, sy
) == 0)
843 for (count
=DesY
;count
<saveY
;count
++)
844 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, 0);
846 for (count
=DesY
;count
<saveY
;count
++)
847 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, 1);
855 /* Draw one pixel on X - Led to the Des Zoom Out*/
856 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
859 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
861 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
863 if (sy
> SourceRect
->bottom
) break;
867 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
869 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
871 if (sx
> SourceRect
->right
) break;
873 if (DIB_1BPP_GetPixel(SourceSurf
, sx
, sy
) == 0)
874 for (count
=DesY
;count
<saveY
;count
++)
875 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, 0);
877 for (count
=DesY
;count
<saveY
;count
++)
878 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, 1);
887 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
888 /* This is a reference implementation, it hasn't been optimized for speed */
891 /* Draw one Hline on X - Led to the Des Zoom In*/
892 if (DesSizeX
>SrcSizeX
)
894 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
897 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
899 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
901 if (sy
> SourceRect
->bottom
) break;
905 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
907 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
909 if (sx
> SourceRect
->right
) break;
911 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_4BPP_GetPixel(SourceSurf
, sx
, sy
));
913 saveX
= DesX
+ zoomX
;
914 for (count
=DesY
;count
<saveY
;count
++)
915 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
921 /* Draw one Hline on X - Led to the Des Zoom Out*/
923 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
926 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
928 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
930 if (sy
> SourceRect
->bottom
) break;
934 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
936 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
938 if (sx
> SourceRect
->right
) break;
940 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_4BPP_GetPixel(SourceSurf
, sx
, sy
));
942 saveX
= DesX
+ zoomX
;
943 for (count
=DesY
;count
<saveY
;count
++)
944 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
953 if (DesSizeX
>SrcSizeX
)
955 /* Draw one pixel on X - Led to the Des Zoom In*/
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
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
971 if (sx
> SourceRect
->right
) break;
973 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_4BPP_GetPixel(SourceSurf
, sx
, sy
));
975 for (count
=DesY
;count
<saveY
;count
++)
976 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, color
);
982 /* Draw one pixel on X - Led to the Des Zoom Out*/
983 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
986 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
988 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
990 if (sy
> SourceRect
->bottom
) break;
994 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
996 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
998 if (sx
> SourceRect
->right
) break;
1000 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_4BPP_GetPixel(SourceSurf
, sx
, sy
));
1002 for (count
=DesY
;count
<saveY
;count
++)
1003 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1011 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
1012 /* This is a reference implementation, it hasn't been optimized for speed */
1015 /* Draw one Hline on X - Led to the Des Zoom In*/
1016 if (DesSizeX
>SrcSizeX
)
1018 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1021 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1023 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1025 if (sy
> SourceRect
->bottom
) break;
1029 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1031 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1033 if (sx
> SourceRect
->right
) break;
1035 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_8BPP_GetPixel(SourceSurf
, sx
, sy
));
1037 saveX
= DesX
+ zoomX
;
1038 for (count
=DesY
;count
<saveY
;count
++)
1039 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1045 /* Draw one Hline on X - Led to the Des Zoom Out*/
1047 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1050 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1052 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1054 if (sy
> SourceRect
->bottom
) break;
1058 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1060 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1062 if (sx
> SourceRect
->right
) break;
1064 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_8BPP_GetPixel(SourceSurf
, sx
, sy
));
1066 saveX
= DesX
+ zoomX
;
1067 for (count
=DesY
;count
<saveY
;count
++)
1068 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1077 if (DesSizeX
>SrcSizeX
)
1079 /* Draw one pixel on X - Led to the Des Zoom In*/
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
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1095 if (sx
> SourceRect
->right
) break;
1097 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_8BPP_GetPixel(SourceSurf
, sx
, sy
));
1099 for (count
=DesY
;count
<saveY
;count
++)
1100 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1106 /* Draw one pixel on X - Led to the Des Zoom Out*/
1107 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1110 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1112 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1114 if (sy
> SourceRect
->bottom
) break;
1118 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1120 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1122 if (sx
> SourceRect
->right
) break;
1124 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_8BPP_GetPixel(SourceSurf
, sx
, sy
));
1126 for (count
=DesY
;count
<saveY
;count
++)
1127 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1135 return ScaleRectAvg16(DestSurf
, SourceSurf
, DestRect
, SourceRect
, MaskOrigin
, BrushOrigin
,
1136 ClipRegion
, ColorTranslation
, Mode
);
1140 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
1141 /* This is a reference implementation, it hasn't been optimized for speed */
1144 /* Draw one Hline on X - Led to the Des Zoom In*/
1145 if (DesSizeX
>SrcSizeX
)
1147 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1150 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1152 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1154 if (sy
> SourceRect
->bottom
) break;
1158 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1160 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1162 if (sx
> SourceRect
->right
) break;
1164 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_24BPP_GetPixel(SourceSurf
, sx
, sy
));
1166 saveX
= DesX
+ zoomX
;
1167 for (count
=DesY
;count
<saveY
;count
++)
1168 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1174 /* Draw one Hline on X - Led to the Des Zoom Out*/
1176 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1179 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1181 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1183 if (sy
> SourceRect
->bottom
) break;
1187 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1189 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1191 if (sx
> SourceRect
->right
) break;
1193 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_24BPP_GetPixel(SourceSurf
, sx
, sy
));
1195 saveX
= DesX
+ zoomX
;
1196 for (count
=DesY
;count
<saveY
;count
++)
1197 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1206 if (DesSizeX
>SrcSizeX
)
1208 /* Draw one pixel on X - Led to the Des Zoom In*/
1209 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1212 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1214 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1216 if (sy
> SourceRect
->bottom
) break;
1220 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1222 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1224 if (sx
> SourceRect
->right
) break;
1226 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_24BPP_GetPixel(SourceSurf
, sx
, sy
));
1228 for (count
=DesY
;count
<saveY
;count
++)
1229 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1235 /* Draw one pixel on X - Led to the Des Zoom Out*/
1236 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1239 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1241 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1243 if (sy
> SourceRect
->bottom
) break;
1247 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1249 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1251 if (sx
> SourceRect
->right
) break;
1253 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_24BPP_GetPixel(SourceSurf
, sx
, sy
));
1255 for (count
=DesY
;count
<saveY
;count
++)
1256 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1264 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
1265 /* This is a reference implementation, it hasn't been optimized for speed */
1268 /* Draw one Hline on X - Led to the Des Zoom In*/
1269 if (DesSizeX
>SrcSizeX
)
1271 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1274 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1276 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1278 if (sy
> SourceRect
->bottom
) break;
1282 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1284 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1286 if (sx
> SourceRect
->right
) break;
1288 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_32BPP_GetPixel(SourceSurf
, sx
, sy
));
1290 saveX
= DesX
+ zoomX
;
1291 for (count
=DesY
;count
<saveY
;count
++)
1292 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1298 /* Draw one Hline on X - Led to the Des Zoom Out*/
1300 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1303 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1305 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1307 if (sy
> SourceRect
->bottom
) break;
1311 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1313 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1315 if (sx
> SourceRect
->right
) break;
1317 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_32BPP_GetPixel(SourceSurf
, sx
, sy
));
1319 saveX
= DesX
+ zoomX
;
1320 for (count
=DesY
;count
<saveY
;count
++)
1321 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1330 if (DesSizeX
>SrcSizeX
)
1332 /* Draw one pixel on X - Led to the Des Zoom In*/
1333 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1336 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1338 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1340 if (sy
> SourceRect
->bottom
) break;
1344 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1346 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1348 if (sx
> SourceRect
->right
) break;
1350 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_32BPP_GetPixel(SourceSurf
, sx
, sy
));
1352 for (count
=DesY
;count
<saveY
;count
++)
1353 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1359 /* Draw one pixel on X - Led to the Des Zoom Out*/
1360 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1363 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1365 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1367 if (sy
> SourceRect
->bottom
) break;
1371 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1373 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1375 if (sx
> SourceRect
->right
) break;
1377 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_32BPP_GetPixel(SourceSurf
, sx
, sy
));
1379 for (count
=DesY
;count
<saveY
;count
++)
1380 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1390 DPRINT1("DIB_16BPP_StretchBlt: Unhandled Source BPP: %u\n", BitsPerFormat(SourceSurf
->iBitmapFormat
));
1400 DIB_16BPP_TransparentBlt(SURFOBJ
*DestSurf
, SURFOBJ
*SourceSurf
,
1401 RECTL
* DestRect
, POINTL
*SourcePoint
,
1402 XLATEOBJ
*ColorTranslation
, ULONG iTransColor
)
1404 ULONG RoundedRight
, X
, Y
, SourceX
, SourceY
, Source
, wd
, Dest
;
1407 RoundedRight
= DestRect
->right
- ((DestRect
->right
- DestRect
->left
) & 0x1);
1408 SourceY
= SourcePoint
->y
;
1409 DestBits
= (ULONG
*)(DestSurf
->pvScan0
+
1410 (DestRect
->left
<< 1) +
1411 DestRect
->top
* DestSurf
->lDelta
);
1412 wd
= DestSurf
->lDelta
- ((DestRect
->right
- DestRect
->left
) << 1);
1414 for(Y
= DestRect
->top
; Y
< DestRect
->bottom
; Y
++)
1416 SourceX
= SourcePoint
->x
;
1417 for(X
= DestRect
->left
; X
< RoundedRight
; X
+= 2, DestBits
++, SourceX
+= 2)
1421 Source
= DIB_GetSourceIndex(SourceSurf
, SourceX
, SourceY
);
1422 if(Source
!= iTransColor
)
1425 Dest
|= (XLATEOBJ_iXlate(ColorTranslation
, Source
) & 0xFFFF);
1428 Source
= DIB_GetSourceIndex(SourceSurf
, SourceX
+ 1, SourceY
);
1429 if(Source
!= iTransColor
)
1432 Dest
|= (XLATEOBJ_iXlate(ColorTranslation
, Source
) << 16);
1438 if(X
< DestRect
->right
)
1440 Source
= DIB_GetSourceIndex(SourceSurf
, SourceX
, SourceY
);
1441 if(Source
!= iTransColor
)
1443 *((USHORT
*)DestBits
) = (USHORT
)XLATEOBJ_iXlate(ColorTranslation
, Source
);
1446 DestBits
= (PULONG
)((ULONG_PTR
)DestBits
+ 2);
1449 DestBits
= (ULONG
*)((ULONG_PTR
)DestBits
+ wd
);