2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 DIB_16BPP_PutPixel(SURFOBJ
*SurfObj
, LONG x
, LONG y
, ULONG c
)
25 PBYTE byteaddr
= SurfObj
->pvScan0
+ y
* SurfObj
->lDelta
;
26 PWORD addr
= (PWORD
)byteaddr
+ x
;
32 DIB_16BPP_GetPixel(SURFOBJ
*SurfObj
, LONG x
, LONG y
)
34 PBYTE byteaddr
= SurfObj
->pvScan0
+ y
* SurfObj
->lDelta
;
35 PWORD addr
= (PWORD
)byteaddr
+ x
;
37 return (ULONG
)(*addr
);
41 DIB_16BPP_HLine(SURFOBJ
*SurfObj
, LONG x1
, LONG x2
, LONG y
, ULONG c
)
43 PDWORD addr
= (PDWORD
)((PWORD
)(SurfObj
->pvScan0
+ y
* SurfObj
->lDelta
) + x1
);
46 /* This is about 10% faster than the generic C code below */
51 " andl $0xffff, %0\n" /* If the pixel value is "abcd", put "abcdabcd" in %eax */
55 " test $0x01, %%edi\n" /* Align to fullword boundary */
61 " mov %1,%%ecx\n" /* Setup count of fullwords to fill */
63 " rep stosl\n" /* The actual fill */
64 " test $0x01, %1\n" /* One left to do at the right side? */
69 : "r"(c
), "r"(Count
), "D"(addr
)
75 if (0 != (cx
& 0x01)) {
78 addr
= (PDWORD
)((PWORD
)(addr
) + 1);
80 cc
= ((c
& 0xffff) << 16) | (c
& 0xffff);
92 DIB_16BPP_VLine(SURFOBJ
*SurfObj
, LONG x
, LONG y1
, LONG y2
, ULONG c
)
96 " testl %2, %2" "\n\t"
98 " movl %2, %%ecx" "\n\t"
100 " andl $3, %%ecx" "\n\t"
103 " movw %%ax, (%0)" "\n\t"
104 " addl %1, %0" "\n\t"
107 " testl %2, %2" "\n\t"
110 " movw %%ax, (%0)" "\n\t"
111 " addl %1, %0" "\n\t"
112 " movw %%ax, (%0)" "\n\t"
113 " addl %1, %0" "\n\t"
114 " movw %%ax, (%0)" "\n\t"
115 " addl %1, %0" "\n\t"
116 " movw %%ax, (%0)" "\n\t"
117 " addl %1, %0" "\n\t"
122 : "r"(SurfObj
->pvScan0
+ (y1
* SurfObj
->lDelta
) + (x
* sizeof (WORD
))),
123 "r"(SurfObj
->lDelta
), "r"(y2
- y1
), "a"(c
)
124 : "cc", "memory", "%ecx");
126 PBYTE byteaddr
= SurfObj
->pvScan0
+ y1
* SurfObj
->lDelta
;
127 PWORD addr
= (PWORD
)byteaddr
+ x
;
128 LONG lDelta
= SurfObj
->lDelta
;
130 byteaddr
= (PBYTE
)addr
;
135 addr
= (PWORD
)byteaddr
;
141 DIB_16BPP_BitBltSrcCopy(PBLTINFO BltInfo
)
143 LONG i
, j
, sx
, sy
, xColor
, f1
;
144 PBYTE SourceBits
, DestBits
, SourceLine
, DestLine
;
145 PBYTE SourceBits_4BPP
, SourceLine_4BPP
;
146 DestBits
= BltInfo
->DestSurface
->pvScan0
+ (BltInfo
->DestRect
.top
* BltInfo
->DestSurface
->lDelta
) + 2 * BltInfo
->DestRect
.left
;
148 switch(BltInfo
->SourceSurface
->iBitmapFormat
)
151 sx
= BltInfo
->SourcePoint
.x
;
152 sy
= BltInfo
->SourcePoint
.y
;
154 for (j
=BltInfo
->DestRect
.top
; j
<BltInfo
->DestRect
.bottom
; j
++)
156 sx
= BltInfo
->SourcePoint
.x
;
157 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
159 if(DIB_1BPP_GetPixel(BltInfo
->SourceSurface
, sx
, sy
) == 0)
161 DIB_16BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, 0));
163 DIB_16BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, 1));
172 SourceBits_4BPP
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + (BltInfo
->SourcePoint
.x
>> 1);
174 for (j
=BltInfo
->DestRect
.top
; j
<BltInfo
->DestRect
.bottom
; j
++)
176 SourceLine_4BPP
= SourceBits_4BPP
;
177 sx
= BltInfo
->SourcePoint
.x
;
180 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
182 xColor
= XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
,
183 (*SourceLine_4BPP
& altnotmask
[f1
]) >> (4 * (1 - f1
)));
184 DIB_16BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, xColor
);
185 if(f1
== 1) { SourceLine_4BPP
++; f1
= 0; } else { f1
= 1; }
189 SourceBits_4BPP
+= BltInfo
->SourceSurface
->lDelta
;
194 SourceLine
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + BltInfo
->SourcePoint
.x
;
197 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
199 SourceBits
= SourceLine
;
202 for (i
= BltInfo
->DestRect
.left
; i
< BltInfo
->DestRect
.right
; i
++)
204 *((WORD
*)DestBits
) = (WORD
)XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, *SourceBits
);
209 SourceLine
+= BltInfo
->SourceSurface
->lDelta
;
210 DestLine
+= BltInfo
->DestSurface
->lDelta
;
215 if (NULL
== BltInfo
->XlateSourceToDest
|| 0 != (BltInfo
->XlateSourceToDest
->flXlate
& XO_TRIVIAL
))
217 if (BltInfo
->DestRect
.top
< BltInfo
->SourcePoint
.y
)
219 SourceBits
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + 2 * BltInfo
->SourcePoint
.x
;
220 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
222 RtlMoveMemory(DestBits
, SourceBits
, 2 * (BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
));
223 SourceBits
+= BltInfo
->SourceSurface
->lDelta
;
224 DestBits
+= BltInfo
->DestSurface
->lDelta
;
229 SourceBits
= BltInfo
->SourceSurface
->pvScan0
+ ((BltInfo
->SourcePoint
.y
+ BltInfo
->DestRect
.bottom
- BltInfo
->DestRect
.top
- 1) * BltInfo
->SourceSurface
->lDelta
) + 2 * BltInfo
->SourcePoint
.x
;
230 DestBits
= BltInfo
->DestSurface
->pvScan0
+ ((BltInfo
->DestRect
.bottom
- 1) * BltInfo
->DestSurface
->lDelta
) + 2 * BltInfo
->DestRect
.left
;
231 for (j
= BltInfo
->DestRect
.bottom
- 1; BltInfo
->DestRect
.top
<= j
; j
--)
233 RtlMoveMemory(DestBits
, SourceBits
, 2 * (BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
));
234 SourceBits
-= BltInfo
->SourceSurface
->lDelta
;
235 DestBits
-= BltInfo
->DestSurface
->lDelta
;
241 if (BltInfo
->DestRect
.top
< BltInfo
->SourcePoint
.y
)
243 SourceLine
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + 2 * BltInfo
->SourcePoint
.x
;
245 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
247 SourceBits
= SourceLine
;
249 for (i
= BltInfo
->DestRect
.left
; i
< BltInfo
->DestRect
.right
; i
++)
251 *((WORD
*)DestBits
) = (WORD
)XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, *((WORD
*)SourceBits
));
255 SourceLine
+= BltInfo
->SourceSurface
->lDelta
;
256 DestLine
+= BltInfo
->DestSurface
->lDelta
;
261 SourceLine
= BltInfo
->SourceSurface
->pvScan0
+ ((BltInfo
->SourcePoint
.y
+ BltInfo
->DestRect
.bottom
- BltInfo
->DestRect
.top
- 1) * BltInfo
->SourceSurface
->lDelta
) + 2 * BltInfo
->SourcePoint
.x
;
262 DestLine
= BltInfo
->DestSurface
->pvScan0
+ ((BltInfo
->DestRect
.bottom
- 1) * BltInfo
->DestSurface
->lDelta
) + 2 * BltInfo
->DestRect
.left
;
263 for (j
= BltInfo
->DestRect
.bottom
- 1; BltInfo
->DestRect
.top
<= j
; j
--)
265 SourceBits
= SourceLine
;
267 for (i
= BltInfo
->DestRect
.left
; i
< BltInfo
->DestRect
.right
; i
++)
269 *((WORD
*)DestBits
) = (WORD
)XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, *((WORD
*)SourceBits
));
273 SourceLine
-= BltInfo
->SourceSurface
->lDelta
;
274 DestLine
-= BltInfo
->DestSurface
->lDelta
;
281 SourceLine
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + 3 * BltInfo
->SourcePoint
.x
;
284 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
286 SourceBits
= SourceLine
;
289 for (i
= BltInfo
->DestRect
.left
; i
< BltInfo
->DestRect
.right
; i
++)
291 xColor
= (*(SourceBits
+ 2) << 0x10) +
292 (*(SourceBits
+ 1) << 0x08) +
294 *((WORD
*)DestBits
) = (WORD
)XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, xColor
);
299 SourceLine
+= BltInfo
->SourceSurface
->lDelta
;
300 DestLine
+= BltInfo
->DestSurface
->lDelta
;
305 SourceLine
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + 4 * BltInfo
->SourcePoint
.x
;
308 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
310 SourceBits
= SourceLine
;
313 for (i
= BltInfo
->DestRect
.left
; i
< BltInfo
->DestRect
.right
; i
++)
315 *((WORD
*)DestBits
) = (WORD
)XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, *((PDWORD
) SourceBits
));
320 SourceLine
+= BltInfo
->SourceSurface
->lDelta
;
321 DestLine
+= BltInfo
->DestSurface
->lDelta
;
326 DPRINT1("DIB_16BPP_Bitblt: Unhandled Source BPP: %u\n", BitsPerFormat(BltInfo
->SourceSurface
->iBitmapFormat
));
334 DIB_16BPP_BitBlt(PBLTINFO BltInfo
)
337 ULONG SourceX
, SourceY
;
339 ULONG Dest
, Source
= 0, Pattern
= 0;
345 UsesSource
= ROP4_USES_SOURCE(BltInfo
->Rop4
);
346 UsesPattern
= ROP4_USES_PATTERN(BltInfo
->Rop4
);
348 RoundedRight
= BltInfo
->DestRect
.right
-
349 ((BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
) & 0x1);
350 SourceY
= BltInfo
->SourcePoint
.y
;
352 BltInfo
->DestSurface
->pvScan0
+
353 (BltInfo
->DestRect
.left
<< 1) +
354 BltInfo
->DestRect
.top
* BltInfo
->DestSurface
->lDelta
);
358 if (BltInfo
->PatternSurface
)
360 PatternY
= (BltInfo
->DestRect
.top
+ BltInfo
->BrushOrigin
.y
) %
361 BltInfo
->PatternSurface
->sizlBitmap
.cy
;
365 Pattern
= BltInfo
->Brush
->iSolidColor
|
366 (BltInfo
->Brush
->iSolidColor
<< 16);
370 for (DestY
= BltInfo
->DestRect
.top
; DestY
< BltInfo
->DestRect
.bottom
; DestY
++)
372 SourceX
= BltInfo
->SourcePoint
.x
;
374 for (DestX
= BltInfo
->DestRect
.left
; DestX
< RoundedRight
; DestX
+= 2, DestBits
++, SourceX
+= 2)
380 Source
= DIB_GetSource(BltInfo
->SourceSurface
, SourceX
, SourceY
, BltInfo
->XlateSourceToDest
);
381 Source
|= DIB_GetSource(BltInfo
->SourceSurface
, SourceX
+ 1, SourceY
, BltInfo
->XlateSourceToDest
) << 16;
384 if (BltInfo
->PatternSurface
)
386 Pattern
= DIB_GetSource(BltInfo
->PatternSurface
, (DestX
+ BltInfo
->BrushOrigin
.x
) % BltInfo
->PatternSurface
->sizlBitmap
.cx
, PatternY
, BltInfo
->XlatePatternToDest
);
387 Pattern
|= DIB_GetSource(BltInfo
->PatternSurface
, (DestX
+ BltInfo
->BrushOrigin
.x
+ 1) % BltInfo
->PatternSurface
->sizlBitmap
.cx
, PatternY
, BltInfo
->XlatePatternToDest
) << 16;
390 *DestBits
= DIB_DoRop(BltInfo
->Rop4
, Dest
, Source
, Pattern
);
393 if (DestX
< BltInfo
->DestRect
.right
)
395 Dest
= *((PUSHORT
)DestBits
);
399 Source
= DIB_GetSource(BltInfo
->SourceSurface
, SourceX
, SourceY
, BltInfo
->XlateSourceToDest
);
402 if (BltInfo
->PatternSurface
)
404 Pattern
= DIB_GetSource(BltInfo
->PatternSurface
, (DestX
+ BltInfo
->BrushOrigin
.x
) % BltInfo
->PatternSurface
->sizlBitmap
.cx
, PatternY
, BltInfo
->XlatePatternToDest
);
407 DIB_16BPP_PutPixel(BltInfo
->DestSurface
, DestX
, DestY
, DIB_DoRop(BltInfo
->Rop4
, Dest
, Source
, Pattern
) & 0xFFFF);
408 DestBits
= (PULONG
)((ULONG_PTR
)DestBits
+ 2);
412 if (BltInfo
->PatternSurface
)
415 PatternY
%= BltInfo
->PatternSurface
->sizlBitmap
.cy
;
418 (ULONG_PTR
)DestBits
-
419 ((BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
) << 1) +
420 BltInfo
->DestSurface
->lDelta
);
428 =======================================
429 Stretching functions goes below
430 Some parts of code are based on an
431 article "Bresenhame image scaling"
432 Dr. Dobb Journal, May 2002
433 =======================================
436 typedef unsigned short PIXEL
;
438 /* 16-bit HiColor (565 format) */
439 inline PIXEL
average16(PIXEL a
, PIXEL b
)
441 // This one doesn't work
446 unsigned short mask = ~ (((a | b) & 0x0410) << 1);
447 return ((a & mask) + (b & mask)) >> 1;
450 // This one should be correct, but it's too long
452 unsigned char r1, g1, b1, r2, g2, b2, rr, gr, br;
455 r1 = (a & 0xF800) >> 11;
456 g1 = (a & 0x7E0) >> 5;
459 r2 = (b & 0xF800) >> 11;
460 g2 = (b & 0x7E0) >> 5;
467 res = (rr << 11) + (gr << 5) + br;
471 return a
; // FIXME: Depend on SetStretchMode
474 //NOTE: If you change something here, please do the same in other dibXXbpp.c files!
475 void ScaleLineAvg16(PIXEL
*Target
, PIXEL
*Source
, int SrcWidth
, int TgtWidth
)
477 int NumPixels
= TgtWidth
;
478 int IntPart
= SrcWidth
/ TgtWidth
;
479 int FractPart
= SrcWidth
% TgtWidth
;
480 int Mid
= TgtWidth
>> 1;
485 skip
= (TgtWidth
< SrcWidth
) ? 0 : (TgtWidth
/ (2*SrcWidth
) + 1);
488 while (NumPixels
-- > 0) {
491 p
= average16(p
, *(Source
+1));
505 FinalCopy16(PIXEL
*Target
, PIXEL
*Source
, PSPAN ClipSpans
, UINT ClipSpansCount
, UINT
*SpanIndex
,
506 UINT DestY
, RECTL
*DestRect
)
510 while (ClipSpans
[*SpanIndex
].Y
< DestY
511 || (ClipSpans
[*SpanIndex
].Y
== DestY
512 && ClipSpans
[*SpanIndex
].X
+ ClipSpans
[*SpanIndex
].Width
< DestRect
->left
))
515 if (ClipSpansCount
<= *SpanIndex
)
517 /* No more spans, everything else is clipped away, we're done */
521 while (ClipSpans
[*SpanIndex
].Y
== DestY
)
523 if (ClipSpans
[*SpanIndex
].X
< DestRect
->right
)
525 Left
= max(ClipSpans
[*SpanIndex
].X
, DestRect
->left
);
526 Right
= min(ClipSpans
[*SpanIndex
].X
+ ClipSpans
[*SpanIndex
].Width
, DestRect
->right
);
527 memcpy(Target
+ Left
- DestRect
->left
, Source
+ Left
- DestRect
->left
,
528 (Right
- Left
) * sizeof(PIXEL
));
531 if (ClipSpansCount
<= *SpanIndex
)
533 /* No more spans, everything else is clipped away, we're done */
541 //NOTE: If you change something here, please do the same in other dibXXbpp.c files!
542 BOOLEAN
ScaleRectAvg16(SURFOBJ
*DestSurf
, SURFOBJ
*SourceSurf
,
543 RECTL
* DestRect
, RECTL
*SourceRect
,
544 POINTL
* MaskOrigin
, POINTL BrushOrigin
,
545 CLIPOBJ
*ClipRegion
, XLATEOBJ
*ColorTranslation
,
548 int NumPixels
= DestRect
->bottom
- DestRect
->top
;
549 int IntPart
= (((SourceRect
->bottom
- SourceRect
->top
) / (DestRect
->bottom
- DestRect
->top
)) * SourceSurf
->lDelta
) >> 1;
550 int FractPart
= (SourceRect
->bottom
- SourceRect
->top
) % (DestRect
->bottom
- DestRect
->top
);
551 int Mid
= (DestRect
->bottom
- DestRect
->top
) >> 1;
554 PIXEL
*ScanLine
, *ScanLineAhead
;
555 PIXEL
*PrevSource
= NULL
;
556 PIXEL
*PrevSourceAhead
= NULL
;
557 PIXEL
*Target
= (PIXEL
*) (DestSurf
->pvScan0
+ (DestRect
->top
* DestSurf
->lDelta
) + 2 * DestRect
->left
);
558 PIXEL
*Source
= (PIXEL
*) (SourceSurf
->pvScan0
+ (SourceRect
->top
* SourceSurf
->lDelta
) + 2 * SourceRect
->left
);
564 if (! ClipobjToSpans(&ClipSpans
, &ClipSpansCount
, ClipRegion
, DestRect
))
568 if (0 == ClipSpansCount
)
570 /* No clip spans == empty clipping region, everything clipped away */
571 ASSERT(NULL
== ClipSpans
);
574 skip
= (DestRect
->bottom
- DestRect
->top
< SourceRect
->bottom
- SourceRect
->top
) ? 0 : ((DestRect
->bottom
- DestRect
->top
) / (2 * (SourceRect
->bottom
- SourceRect
->top
)) + 1);
577 ScanLine
= (PIXEL
*)ExAllocatePool(PagedPool
, (DestRect
->right
- DestRect
->left
) * sizeof(PIXEL
));
578 ScanLineAhead
= (PIXEL
*)ExAllocatePool(PagedPool
, (DestRect
->right
- DestRect
->left
) * sizeof(PIXEL
));
580 DestY
= DestRect
->top
;
582 while (NumPixels
-- > 0) {
583 if (Source
!= PrevSource
) {
584 if (Source
== PrevSourceAhead
) {
585 /* the next scan line has already been scaled and stored in
586 * ScanLineAhead; swap the buffers that ScanLine and ScanLineAhead
589 PIXEL
*tmp
= ScanLine
;
590 ScanLine
= ScanLineAhead
;
593 ScaleLineAvg16(ScanLine
, Source
, SourceRect
->right
- SourceRect
->left
, DestRect
->right
- DestRect
->left
);
598 if (E
>= Mid
&& PrevSourceAhead
!= (PIXEL
*)((BYTE
*)Source
+ SourceSurf
->lDelta
)) {
600 ScaleLineAvg16(ScanLineAhead
, (PIXEL
*)((BYTE
*)Source
+ SourceSurf
->lDelta
), SourceRect
->right
- SourceRect
->left
, DestRect
->right
- DestRect
->left
);
601 for (x
= 0; x
< DestRect
->right
- DestRect
->left
; x
++)
602 ScanLine
[x
] = average16(ScanLine
[x
], ScanLineAhead
[x
]);
603 PrevSourceAhead
= (PIXEL
*)((BYTE
*)Source
+ SourceSurf
->lDelta
);
606 if (! FinalCopy16(Target
, ScanLine
, ClipSpans
, ClipSpansCount
, &SpanIndex
, DestY
, DestRect
))
608 /* No more spans, everything else is clipped away, we're done */
609 ExFreePool(ClipSpans
);
610 ExFreePool(ScanLine
);
611 ExFreePool(ScanLineAhead
);
615 Target
= (PIXEL
*)((BYTE
*)Target
+ DestSurf
->lDelta
);
618 if (E
>= DestRect
->bottom
- DestRect
->top
) {
619 E
-= DestRect
->bottom
- DestRect
->top
;
620 Source
= (PIXEL
*)((BYTE
*)Source
+ SourceSurf
->lDelta
);
624 if (skip
> 0 && Source
!= PrevSource
)
625 ScaleLineAvg16(ScanLine
, Source
, SourceRect
->right
- SourceRect
->left
, DestRect
->right
- DestRect
->left
);
627 if (! FinalCopy16(Target
, ScanLine
, ClipSpans
, ClipSpansCount
, &SpanIndex
, DestY
, DestRect
))
629 /* No more spans, everything else is clipped away, we're done */
630 ExFreePool(ClipSpans
);
631 ExFreePool(ScanLine
);
632 ExFreePool(ScanLineAhead
);
636 Target
= (PIXEL
*)((BYTE
*)Target
+ DestSurf
->lDelta
);
639 ExFreePool(ClipSpans
);
640 ExFreePool(ScanLine
);
641 ExFreePool(ScanLineAhead
);
646 //NOTE: If you change something here, please do the same in other dibXXbpp.c files!
647 BOOLEAN
DIB_16BPP_StretchBlt(SURFOBJ
*DestSurf
, SURFOBJ
*SourceSurf
,
648 RECTL
* DestRect
, RECTL
*SourceRect
,
649 POINTL
* MaskOrigin
, POINTL BrushOrigin
,
650 CLIPOBJ
*ClipRegion
, XLATEOBJ
*ColorTranslation
,
667 BOOLEAN DesIsBiggerY
=FALSE
;
669 DPRINT("DIB_16BPP_StretchBlt: Source BPP: %u, srcRect: (%d,%d)-(%d,%d), dstRect: (%d,%d)-(%d,%d)\n",
670 BitsPerFormat(SourceSurf
->iBitmapFormat
), SourceRect
->left
, SourceRect
->top
, SourceRect
->right
, SourceRect
->bottom
,
671 DestRect
->left
, DestRect
->top
, DestRect
->right
, DestRect
->bottom
);
673 SrcSizeY
= SourceRect
->bottom
;
674 SrcSizeX
= SourceRect
->right
;
676 DesSizeY
= DestRect
->bottom
;
677 DesSizeX
= DestRect
->right
;
679 zoomX
= DesSizeX
/ SrcSizeX
;
680 if (zoomX
==0) zoomX
=1;
682 zoomY
= DesSizeY
/ SrcSizeY
;
683 if (zoomY
==0) zoomY
=1;
685 if (DesSizeY
>SrcSizeY
)
690 switch(SourceSurf
->iBitmapFormat
)
695 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
696 /* This is a reference implementation, it hasn't been optimized for speed */
699 /* Draw one Hline on X - Led to the Des Zoom In*/
700 if (DesSizeX
>SrcSizeX
)
702 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
705 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
707 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
709 if (sy
> SourceRect
->bottom
) break;
713 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
715 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
717 if (sx
> SourceRect
->right
) break;
719 saveX
= DesX
+ zoomX
;
721 if (DIB_1BPP_GetPixel(SourceSurf
, sx
, sy
) == 0)
722 for (count
=DesY
;count
<saveY
;count
++)
723 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, 0);
725 for (count
=DesY
;count
<saveY
;count
++)
726 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, 1);
733 /* Draw one Hline on X - Led to the Des Zoom Out*/
735 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
738 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
740 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
742 if (sy
> SourceRect
->bottom
) break;
746 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
748 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
750 if (sx
> SourceRect
->right
) break;
752 saveX
= DesX
+ zoomX
;
754 if (DIB_1BPP_GetPixel(SourceSurf
, sx
, sy
) == 0)
755 for (count
=DesY
;count
<saveY
;count
++)
756 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, 0);
758 for (count
=DesY
;count
<saveY
;count
++)
759 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, 1);
768 if (DesSizeX
>SrcSizeX
)
770 /* Draw one pixel on X - Led to the Des Zoom In*/
771 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
774 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
776 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
778 if (sy
> SourceRect
->bottom
) break;
782 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
784 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
786 if (sx
> SourceRect
->right
) break;
788 if (DIB_1BPP_GetPixel(SourceSurf
, sx
, sy
) == 0)
789 for (count
=DesY
;count
<saveY
;count
++)
790 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, 0);
792 for (count
=DesY
;count
<saveY
;count
++)
793 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, 1);
801 /* Draw one pixel on X - Led to the Des Zoom Out*/
802 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
805 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
807 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
809 if (sy
> SourceRect
->bottom
) break;
813 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
815 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
817 if (sx
> SourceRect
->right
) break;
819 if (DIB_1BPP_GetPixel(SourceSurf
, sx
, sy
) == 0)
820 for (count
=DesY
;count
<saveY
;count
++)
821 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, 0);
823 for (count
=DesY
;count
<saveY
;count
++)
824 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, 1);
833 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
834 /* This is a reference implementation, it hasn't been optimized for speed */
837 /* Draw one Hline on X - Led to the Des Zoom In*/
838 if (DesSizeX
>SrcSizeX
)
840 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
843 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
845 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
847 if (sy
> SourceRect
->bottom
) break;
851 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
853 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
855 if (sx
> SourceRect
->right
) break;
857 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_4BPP_GetPixel(SourceSurf
, sx
, sy
));
859 saveX
= DesX
+ zoomX
;
860 for (count
=DesY
;count
<saveY
;count
++)
861 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
867 /* Draw one Hline on X - Led to the Des Zoom Out*/
869 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
872 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
874 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
876 if (sy
> SourceRect
->bottom
) break;
880 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
882 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
884 if (sx
> SourceRect
->right
) break;
886 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_4BPP_GetPixel(SourceSurf
, sx
, sy
));
888 saveX
= DesX
+ zoomX
;
889 for (count
=DesY
;count
<saveY
;count
++)
890 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
899 if (DesSizeX
>SrcSizeX
)
901 /* Draw one pixel on X - Led to the Des Zoom In*/
902 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
905 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
907 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
909 if (sy
> SourceRect
->bottom
) break;
913 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
915 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
917 if (sx
> SourceRect
->right
) break;
919 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_4BPP_GetPixel(SourceSurf
, sx
, sy
));
921 for (count
=DesY
;count
<saveY
;count
++)
922 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, color
);
928 /* Draw one pixel on X - Led to the Des Zoom Out*/
929 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
932 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
934 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
936 if (sy
> SourceRect
->bottom
) break;
940 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
942 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
944 if (sx
> SourceRect
->right
) break;
946 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_4BPP_GetPixel(SourceSurf
, sx
, sy
));
948 for (count
=DesY
;count
<saveY
;count
++)
949 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, color
);
957 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
958 /* This is a reference implementation, it hasn't been optimized for speed */
961 /* Draw one Hline on X - Led to the Des Zoom In*/
962 if (DesSizeX
>SrcSizeX
)
964 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
967 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
969 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
971 if (sy
> SourceRect
->bottom
) break;
975 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
977 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
979 if (sx
> SourceRect
->right
) break;
981 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_8BPP_GetPixel(SourceSurf
, sx
, sy
));
983 saveX
= DesX
+ zoomX
;
984 for (count
=DesY
;count
<saveY
;count
++)
985 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
991 /* Draw one Hline on X - Led to the Des Zoom Out*/
993 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
996 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
998 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1000 if (sy
> SourceRect
->bottom
) break;
1004 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1006 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1008 if (sx
> SourceRect
->right
) break;
1010 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_8BPP_GetPixel(SourceSurf
, sx
, sy
));
1012 saveX
= DesX
+ zoomX
;
1013 for (count
=DesY
;count
<saveY
;count
++)
1014 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1023 if (DesSizeX
>SrcSizeX
)
1025 /* Draw one pixel on X - Led to the Des Zoom In*/
1026 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1029 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1031 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1033 if (sy
> SourceRect
->bottom
) break;
1037 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1039 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1041 if (sx
> SourceRect
->right
) break;
1043 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_8BPP_GetPixel(SourceSurf
, sx
, sy
));
1045 for (count
=DesY
;count
<saveY
;count
++)
1046 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1052 /* Draw one pixel on X - Led to the Des Zoom Out*/
1053 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; 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
>=0; DesX
-=zoomX
)
1066 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1068 if (sx
> SourceRect
->right
) break;
1070 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_8BPP_GetPixel(SourceSurf
, sx
, sy
));
1072 for (count
=DesY
;count
<saveY
;count
++)
1073 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1081 return ScaleRectAvg16(DestSurf
, SourceSurf
, DestRect
, SourceRect
, MaskOrigin
, BrushOrigin
,
1082 ClipRegion
, ColorTranslation
, Mode
);
1086 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
1087 /* This is a reference implementation, it hasn't been optimized for speed */
1090 /* Draw one Hline on X - Led to the Des Zoom In*/
1091 if (DesSizeX
>SrcSizeX
)
1093 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1096 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1098 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1100 if (sy
> SourceRect
->bottom
) break;
1104 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1106 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1108 if (sx
> SourceRect
->right
) break;
1110 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_24BPP_GetPixel(SourceSurf
, sx
, sy
));
1112 saveX
= DesX
+ zoomX
;
1113 for (count
=DesY
;count
<saveY
;count
++)
1114 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1120 /* Draw one Hline on X - Led to the Des Zoom Out*/
1122 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1125 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1127 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1129 if (sy
> SourceRect
->bottom
) break;
1133 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1135 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1137 if (sx
> SourceRect
->right
) break;
1139 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_24BPP_GetPixel(SourceSurf
, sx
, sy
));
1141 saveX
= DesX
+ zoomX
;
1142 for (count
=DesY
;count
<saveY
;count
++)
1143 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1152 if (DesSizeX
>SrcSizeX
)
1154 /* Draw one pixel on X - Led to the Des Zoom In*/
1155 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1158 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1160 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1162 if (sy
> SourceRect
->bottom
) break;
1166 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1168 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1170 if (sx
> SourceRect
->right
) break;
1172 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_24BPP_GetPixel(SourceSurf
, sx
, sy
));
1174 for (count
=DesY
;count
<saveY
;count
++)
1175 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1181 /* Draw one pixel on X - Led to the Des Zoom Out*/
1182 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1185 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1187 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1189 if (sy
> SourceRect
->bottom
) break;
1193 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1195 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1197 if (sx
> SourceRect
->right
) break;
1199 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_24BPP_GetPixel(SourceSurf
, sx
, sy
));
1201 for (count
=DesY
;count
<saveY
;count
++)
1202 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1210 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
1211 /* This is a reference implementation, it hasn't been optimized for speed */
1214 /* Draw one Hline on X - Led to the Des Zoom In*/
1215 if (DesSizeX
>SrcSizeX
)
1217 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1220 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1222 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1224 if (sy
> SourceRect
->bottom
) break;
1228 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1230 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1232 if (sx
> SourceRect
->right
) break;
1234 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_32BPP_GetPixel(SourceSurf
, sx
, sy
));
1236 saveX
= DesX
+ zoomX
;
1237 for (count
=DesY
;count
<saveY
;count
++)
1238 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1244 /* Draw one Hline on X - Led to the Des Zoom Out*/
1246 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1249 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1251 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1253 if (sy
> SourceRect
->bottom
) break;
1257 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1259 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1261 if (sx
> SourceRect
->right
) break;
1263 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_32BPP_GetPixel(SourceSurf
, sx
, sy
));
1265 saveX
= DesX
+ zoomX
;
1266 for (count
=DesY
;count
<saveY
;count
++)
1267 DIB_16BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1276 if (DesSizeX
>SrcSizeX
)
1278 /* Draw one pixel on X - Led to the Des Zoom In*/
1279 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1282 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1284 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1286 if (sy
> SourceRect
->bottom
) break;
1290 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1292 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1294 if (sx
> SourceRect
->right
) break;
1296 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_32BPP_GetPixel(SourceSurf
, sx
, sy
));
1298 for (count
=DesY
;count
<saveY
;count
++)
1299 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1305 /* Draw one pixel on X - Led to the Des Zoom Out*/
1306 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1309 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1311 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1313 if (sy
> SourceRect
->bottom
) break;
1317 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1319 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1321 if (sx
> SourceRect
->right
) break;
1323 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_32BPP_GetPixel(SourceSurf
, sx
, sy
));
1325 for (count
=DesY
;count
<saveY
;count
++)
1326 DIB_16BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1336 DPRINT1("DIB_16BPP_StretchBlt: Unhandled Source BPP: %u\n", BitsPerFormat(SourceSurf
->iBitmapFormat
));
1346 DIB_16BPP_TransparentBlt(SURFOBJ
*DestSurf
, SURFOBJ
*SourceSurf
,
1347 RECTL
* DestRect
, POINTL
*SourcePoint
,
1348 XLATEOBJ
*ColorTranslation
, ULONG iTransColor
)
1350 ULONG RoundedRight
, X
, Y
, SourceX
, SourceY
, Source
, wd
, Dest
;
1353 RoundedRight
= DestRect
->right
- ((DestRect
->right
- DestRect
->left
) & 0x1);
1354 SourceY
= SourcePoint
->y
;
1355 DestBits
= (ULONG
*)(DestSurf
->pvScan0
+
1356 (DestRect
->left
<< 1) +
1357 DestRect
->top
* DestSurf
->lDelta
);
1358 wd
= DestSurf
->lDelta
- ((DestRect
->right
- DestRect
->left
) << 1);
1360 for(Y
= DestRect
->top
; Y
< DestRect
->bottom
; Y
++)
1362 SourceX
= SourcePoint
->x
;
1363 for(X
= DestRect
->left
; X
< RoundedRight
; X
+= 2, DestBits
++, SourceX
+= 2)
1367 Source
= DIB_GetSourceIndex(SourceSurf
, SourceX
, SourceY
);
1368 if(Source
!= iTransColor
)
1371 Dest
|= (XLATEOBJ_iXlate(ColorTranslation
, Source
) & 0xFFFF);
1374 Source
= DIB_GetSourceIndex(SourceSurf
, SourceX
+ 1, SourceY
);
1375 if(Source
!= iTransColor
)
1378 Dest
|= (XLATEOBJ_iXlate(ColorTranslation
, Source
) << 16);
1384 if(X
< DestRect
->right
)
1386 Source
= DIB_GetSourceIndex(SourceSurf
, SourceX
, SourceY
);
1387 if(Source
!= iTransColor
)
1389 *((USHORT
*)DestBits
) = (USHORT
)XLATEOBJ_iXlate(ColorTranslation
, Source
);
1392 DestBits
= (PULONG
)((ULONG_PTR
)DestBits
+ 2);
1395 DestBits
= (ULONG
*)((ULONG_PTR
)DestBits
+ wd
);