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_1BPP_PutPixel(SURFOBJ
*SurfObj
, LONG x
, LONG y
, ULONG c
)
25 PBYTE addr
= SurfObj
->pvScan0
+ y
* SurfObj
->lDelta
+ (x
>> 3);
28 *addr
&= ~MASK1BPP(x
);
34 DIB_1BPP_GetPixel(SURFOBJ
*SurfObj
, LONG x
, LONG y
)
36 PBYTE addr
= SurfObj
->pvScan0
+ y
* SurfObj
->lDelta
+ (x
>> 3);
38 return (*addr
& MASK1BPP(x
) ? 1 : 0);
42 DIB_1BPP_HLine(SURFOBJ
*SurfObj
, LONG x1
, LONG x2
, LONG y
, ULONG c
)
45 DIB_1BPP_PutPixel(SurfObj
, x1
, y
, c
);
51 DIB_1BPP_VLine(SURFOBJ
*SurfObj
, LONG x
, LONG y1
, LONG y2
, ULONG c
)
54 DIB_1BPP_PutPixel(SurfObj
, x
, y1
, c
);
61 DIB_1BPP_BitBltSrcCopy_From1BPP (
62 SURFOBJ
* DestSurf
, SURFOBJ
* SourceSurf
,
63 PRECTL DestRect
, POINTL
*SourcePoint
)
65 // the 'window' in this sense is the x-position that corresponds
66 // to the left-edge of the 8-pixel byte we are currently working with.
67 // dwx is current x-window, dwx2 is the 'last' window we need to process
68 int dwx
, dwx2
; // destination window x-position
69 int swx
; // source window y-position
71 // left and right edges of source and dest rectangles
72 int dl
= DestRect
->left
; // dest left
73 int dr
= DestRect
->right
-1; // dest right (inclusive)
74 int sl
= SourcePoint
->x
; // source left
75 int sr
= sl
+ dr
- dl
; // source right (inclusive)
77 // which direction are we going?
80 int ySrcDelta
, yDstDelta
;
82 // following 4 variables are used for the y-sweep
84 int dy1
; // dest y start
85 int dy2
; // dest y end
86 int sy1
; // src y start
89 BYTE srcmask
, dstmask
;
91 // 'd' and 's' are the dest & src buffer pointers that I use on my x-sweep
92 // 'pd' and 'ps' are the dest & src buffer pointers used on the inner y-sweep
93 PBYTE d
, pd
; // dest ptrs
94 PBYTE s
, ps
; // src ptrs
98 if ( DestRect
->top
<= SourcePoint
->y
)
100 // moving up ( scan top -> bottom )
102 dy2
= DestRect
->bottom
- 1;
103 sy1
= SourcePoint
->y
;
105 ySrcDelta
= SourceSurf
->lDelta
;
106 yDstDelta
= DestSurf
->lDelta
;
110 // moving down ( scan bottom -> top )
111 dy1
= DestRect
->bottom
- 1;
113 sy1
= SourcePoint
->y
+ dy1
- dy2
;
115 ySrcDelta
= -SourceSurf
->lDelta
;
116 yDstDelta
= -DestSurf
->lDelta
;
118 if ( DestRect
->left
<= SourcePoint
->x
)
120 // moving left ( scan left->right )
122 swx
= (sl
-(dl
&7))&~7;
128 // moving right ( scan right->left )
130 swx
= (sr
-(dr
&7))&~7; //(sr-7)&~7; // we need the left edge of this block... thus the -7
134 d
= &(((PBYTE
)DestSurf
->pvScan0
)[dy1
*DestSurf
->lDelta
+ (dwx
>>3)]);
135 s
= &(((PBYTE
)SourceSurf
->pvScan0
)[sy1
*SourceSurf
->lDelta
+ (swx
>>3)]);
142 int dx
= dwx
; /* dest x for this pass */
146 srcmask
&= (1<<(8-diff
))-1;
152 srcmask
&= ~((1<<(8-diff
))-1);
156 // we unfortunately *must* have 5 different versions of the inner
157 // loop to be certain we don't try to read from memory that is not
158 // needed and may in fact be invalid
163 *pd
= (BYTE
)((*pd
& dstmask
) | (*ps
& srcmask
));
165 // this *must* be here, because we could be going up *or* down...
173 else if ( !(0xFF00 & (srcmask
<<shift
) ) ) // check if ps[0] not needed...
177 *pd
= (BYTE
)((*pd
& dstmask
)
178 | ( ( ps
[1] >> shift
) & srcmask
));
180 // this *must* be here, because we could be going up *or* down...
188 else if ( !(0xFF & (srcmask
<<shift
) ) ) // check if ps[1] not needed...
192 *pd
= (*pd
& dstmask
)
193 | ( ( ps
[0] << ( 8 - shift
) ) & srcmask
);
195 // this *must* be here, because we could be going up *or* down...
203 else // both ps[0] and ps[1] are needed
207 *pd
= (*pd
& dstmask
)
208 | ( ( ( (ps
[1])|(ps
[0]<<8) ) >> shift
) & srcmask
);
210 // this *must* be here, because we could be going up *or* down...
219 // this *must* be here, because we could be going right *or* left...
230 DIB_1BPP_BitBltSrcCopy(PBLTINFO BltInfo
)
232 LONG i
, j
, sx
, sy
= BltInfo
->SourcePoint
.y
;
234 switch ( BltInfo
->SourceSurface
->iBitmapFormat
)
237 DIB_1BPP_BitBltSrcCopy_From1BPP ( BltInfo
->DestSurface
, BltInfo
->SourceSurface
, &BltInfo
->DestRect
, &BltInfo
->SourcePoint
);
241 for (j
=BltInfo
->DestRect
.top
; j
<BltInfo
->DestRect
.bottom
; j
++)
243 sx
= BltInfo
->SourcePoint
.x
;
244 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
246 if(XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, DIB_4BPP_GetPixel(BltInfo
->SourceSurface
, sx
, sy
)) == 0)
248 DIB_1BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, 0);
250 DIB_1BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, 1);
259 for (j
=BltInfo
->DestRect
.top
; j
<BltInfo
->DestRect
.bottom
; j
++)
261 sx
= BltInfo
->SourcePoint
.x
;
262 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
264 if(XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, DIB_8BPP_GetPixel(BltInfo
->SourceSurface
, sx
, sy
)) == 0)
266 DIB_1BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, 0);
268 DIB_1BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, 1);
277 for (j
=BltInfo
->DestRect
.top
; j
<BltInfo
->DestRect
.bottom
; j
++)
279 sx
= BltInfo
->SourcePoint
.x
;
280 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
282 if(XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, DIB_16BPP_GetPixel(BltInfo
->SourceSurface
, sx
, sy
)) == 0)
284 DIB_1BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, 0);
286 DIB_1BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, 1);
295 for (j
=BltInfo
->DestRect
.top
; j
<BltInfo
->DestRect
.bottom
; j
++)
297 sx
= BltInfo
->SourcePoint
.x
;
298 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
300 if(XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, DIB_24BPP_GetPixel(BltInfo
->SourceSurface
, sx
, sy
)) == 0)
302 DIB_1BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, 0);
304 DIB_1BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, 1);
313 for (j
=BltInfo
->DestRect
.top
; j
<BltInfo
->DestRect
.bottom
; j
++)
315 sx
= BltInfo
->SourcePoint
.x
;
316 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
318 if(XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, DIB_32BPP_GetPixel(BltInfo
->SourceSurface
, sx
, sy
)) == 0)
320 DIB_1BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, 0);
322 DIB_1BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, 1);
331 DbgPrint("DIB_1BPP_BitBlt: Unhandled Source BPP: %u\n", BitsPerFormat(BltInfo
->SourceSurface
->iBitmapFormat
));
339 DIB_1BPP_BitBlt(PBLTINFO BltInfo
)
342 ULONG SourceX
, SourceY
;
344 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
) & 31);
357 SourceY
= BltInfo
->SourcePoint
.y
;
361 if (BltInfo
->PatternSurface
)
363 PatternY
= (BltInfo
->DestRect
.top
+ BltInfo
->BrushOrigin
.y
) %
364 BltInfo
->PatternSurface
->sizlBitmap
.cy
;
368 /* FIXME: Shouldn't it be expanded? */
369 Pattern
= BltInfo
->Brush
->iSolidColor
;
373 for (DestY
= BltInfo
->DestRect
.top
; DestY
< BltInfo
->DestRect
.bottom
; DestY
++)
375 DestX
= BltInfo
->DestRect
.left
;
376 SourceX
= BltInfo
->SourcePoint
.x
;
378 BltInfo
->DestSurface
->pvScan0
+
379 (BltInfo
->DestRect
.left
>> 3) +
380 DestY
* BltInfo
->DestSurface
->lDelta
);
385 /* FIXME: This case is completely untested!!! */
387 Dest
= *((PBYTE
)DestBits
);
388 NoBits
= 31 - (DestX
& 31);
393 /* FIXME: This is incorrect! */
394 for (Index
= 31 - NoBits
; Index
>= 0; Index
++)
395 Source
|= (DIB_GetSource(SourceSurf
, SourceX
+ Index
, SourceY
, ColorTranslation
) << (31 - Index
));
398 if (BltInfo
->PatternSurface
)
401 for (k
= 31 - NoBits
; k
>= 0; k
++)
402 Pattern
|= (DIB_GetSource(PatternObj
, (X
+ BrushOrigin
.x
+ k
) % PatternWidth
, PatternY
, BltInfo
->XlatePatternToDest
) << (31 - k
));
405 Dest
= DIB_DoRop(Rop4
, Dest
, Source
, Pattern
);
406 Dest
&= ~((1 << (31 - NoBits
)) - 1);
407 Dest
|= *((PBYTE
)DestBits
) & ((1 << (31 - NoBits
)) - 1);
416 for (; DestX
< RoundedRight
; DestX
+= 32, DestBits
++, SourceX
++)
423 for (Index
= 0; Index
< 8; Index
++)
425 Source
|= DIB_GetSource(BltInfo
->SourceSurface
, SourceX
+ Index
, SourceY
, BltInfo
->XlateSourceToDest
) << (7 - Index
);
426 Source
|= DIB_GetSource(BltInfo
->SourceSurface
, SourceX
+ Index
+ 8, SourceY
, BltInfo
->XlateSourceToDest
) << (8 + (7 - Index
));
427 Source
|= DIB_GetSource(BltInfo
->SourceSurface
, SourceX
+ Index
+ 16, SourceY
, BltInfo
->XlateSourceToDest
) << (16 + (7 - Index
));
428 Source
|= DIB_GetSource(BltInfo
->SourceSurface
, SourceX
+ Index
+ 24, SourceY
, BltInfo
->XlateSourceToDest
) << (24 + (7 - Index
));
432 if (BltInfo
->PatternSurface
)
435 for (Index
= 0; Index
< 8; Index
++)
437 Pattern
|= DIB_GetSource(BltInfo
->PatternSurface
, (DestX
+ BltInfo
->BrushOrigin
.x
+ Index
) % BltInfo
->PatternSurface
->sizlBitmap
.cx
, PatternY
, BltInfo
->XlatePatternToDest
) << (7 - Index
);
438 Pattern
|= DIB_GetSource(BltInfo
->PatternSurface
, (DestX
+ BltInfo
->BrushOrigin
.x
+ Index
+ 8) % BltInfo
->PatternSurface
->sizlBitmap
.cx
, PatternY
, BltInfo
->XlatePatternToDest
) << (8 + (7 - Index
));
439 Pattern
|= DIB_GetSource(BltInfo
->PatternSurface
, (DestX
+ BltInfo
->BrushOrigin
.x
+ Index
+ 16) % BltInfo
->PatternSurface
->sizlBitmap
.cx
, PatternY
, BltInfo
->XlatePatternToDest
) << (16 + (7 - Index
));
440 Pattern
|= DIB_GetSource(BltInfo
->PatternSurface
, (DestX
+ BltInfo
->BrushOrigin
.x
+ Index
+ 24) % BltInfo
->PatternSurface
->sizlBitmap
.cx
, PatternY
, BltInfo
->XlatePatternToDest
) << (24 + (7 - Index
));
444 *DestBits
= DIB_DoRop(BltInfo
->Rop4
, Dest
, Source
, Pattern
);
447 if (DestX
< BltInfo
->DestRect
.right
)
450 for (; DestX
< BltInfo
->DestRect
.right
; DestX
++, SourceX
++)
453 Dest
= DIB_1BPP_GetPixel(BltInfo
->DestSurface
, DestX
, DestY
);
457 Source
= DIB_GetSource(BltInfo
->SourceSurface
, SourceX
, SourceY
, BltInfo
->XlateSourceToDest
);
460 if (BltInfo
->PatternSurface
)
462 Pattern
= DIB_GetSource(BltInfo
->PatternSurface
, (DestX
+ BltInfo
->BrushOrigin
.x
) % BltInfo
->PatternSurface
->sizlBitmap
.cx
, PatternY
, BltInfo
->XlatePatternToDest
);
465 DIB_1BPP_PutPixel(BltInfo
->DestSurface
, DestX
, DestY
, DIB_DoRop(BltInfo
->Rop4
, Dest
, Source
, Pattern
) & 0xF);
471 if (BltInfo
->PatternSurface
)
474 PatternY
%= BltInfo
->PatternSurface
->sizlBitmap
.cy
;
481 /* Optimze for bitBlt */
483 DIB_1BPP_ColorFill(SURFOBJ
* DestSurface
, RECTL
* DestRect
, ULONG color
)
487 for (DestY
= DestRect
->top
; DestY
< DestRect
->bottom
; DestY
++)
489 DIB_1BPP_HLine(DestSurface
, DestRect
->left
, DestRect
->right
, DestY
, color
);
495 //NOTE: If you change something here, please do the same in other dibXXbpp.c files!
496 BOOLEAN
DIB_1BPP_StretchBlt(SURFOBJ
*DestSurf
, SURFOBJ
*SourceSurf
,
497 RECTL
* DestRect
, RECTL
*SourceRect
,
498 POINTL
* MaskOrigin
, POINTL BrushOrigin
,
499 CLIPOBJ
*ClipRegion
, XLATEOBJ
*ColorTranslation
,
516 BOOLEAN DesIsBiggerY
=FALSE
;
518 SrcSizeY
= SourceRect
->bottom
;
519 SrcSizeX
= SourceRect
->right
;
521 DesSizeY
= DestRect
->bottom
;
522 DesSizeX
= DestRect
->right
;
524 zoomX
= DesSizeX
/ SrcSizeX
;
525 if (zoomX
==0) zoomX
=1;
527 zoomY
= DesSizeY
/ SrcSizeY
;
528 if (zoomY
==0) zoomY
=1;
530 if (DesSizeY
>SrcSizeY
)
534 switch(SourceSurf
->iBitmapFormat
)
537 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
538 /* This is a reference implementation, it hasn't been optimized for speed */
541 /* Draw one Hline on X - Led to the Des Zoom In*/
542 if (DesSizeX
>SrcSizeX
)
544 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
547 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
549 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
551 if (sy
> SourceRect
->bottom
) break;
555 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
557 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
559 if (sx
> SourceRect
->right
) break;
561 saveX
= DesX
+ zoomX
;
563 color
= DIB_1BPP_GetPixel(SourceSurf
, sx
, sy
);
565 for (count
=DesY
;count
<saveY
;count
++)
566 DIB_1BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
574 /* Draw one Hline on X - Led to the Des Zoom Out*/
576 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
579 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
581 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
583 if (sy
> SourceRect
->bottom
) break;
587 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
589 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
591 if (sx
> SourceRect
->right
) break;
593 saveX
= DesX
+ zoomX
;
595 color
= DIB_1BPP_GetPixel(SourceSurf
, sx
, sy
);
597 for (count
=DesY
;count
<saveY
;count
++)
598 DIB_1BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
608 if (DesSizeX
>SrcSizeX
)
610 /* Draw one pixel on X - Led to the Des Zoom In*/
611 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
614 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
616 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
618 if (sy
> SourceRect
->bottom
) break;
622 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
624 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
626 if (sx
> SourceRect
->right
) break;
628 color
= DIB_1BPP_GetPixel(SourceSurf
, sx
, sy
);
630 for (count
=DesY
;count
<saveY
;count
++)
631 DIB_1BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
638 /* Draw one pixel on X - Led to the Des Zoom Out*/
639 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
642 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
644 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
646 if (sy
> SourceRect
->bottom
) break;
650 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
652 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
654 if (sx
> SourceRect
->right
) break;
656 color
= DIB_1BPP_GetPixel(SourceSurf
, sx
, sy
);
658 for (count
=DesY
;count
<saveY
;count
++)
659 DIB_1BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
668 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
669 /* This is a reference implementation, it hasn't been optimized for speed */
672 /* Draw one Hline on X - Led to the Des Zoom In*/
673 if (DesSizeX
>SrcSizeX
)
675 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
678 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
680 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
682 if (sy
> SourceRect
->bottom
) break;
686 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
688 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
690 if (sx
> SourceRect
->right
) break;
692 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_4BPP_GetPixel(SourceSurf
, sx
, sy
));
694 saveX
= DesX
+ zoomX
;
695 for (count
=DesY
;count
<saveY
;count
++)
696 DIB_1BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
702 /* Draw one Hline on X - Led to the Des Zoom Out*/
704 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
707 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
709 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
711 if (sy
> SourceRect
->bottom
) break;
715 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
717 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
719 if (sx
> SourceRect
->right
) break;
721 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_4BPP_GetPixel(SourceSurf
, sx
, sy
));
723 saveX
= DesX
+ zoomX
;
724 for (count
=DesY
;count
<saveY
;count
++)
725 DIB_1BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
734 if (DesSizeX
>SrcSizeX
)
736 /* Draw one pixel on X - Led to the Des Zoom In*/
737 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
740 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
742 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
744 if (sy
> SourceRect
->bottom
) break;
748 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
750 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
752 if (sx
> SourceRect
->right
) break;
754 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_4BPP_GetPixel(SourceSurf
, sx
, sy
));
756 for (count
=DesY
;count
<saveY
;count
++)
757 DIB_1BPP_PutPixel(DestSurf
, DesX
, count
, color
);
763 /* Draw one pixel on X - Led to the Des Zoom Out*/
764 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
767 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
769 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
771 if (sy
> SourceRect
->bottom
) break;
775 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
777 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
779 if (sx
> SourceRect
->right
) break;
781 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_4BPP_GetPixel(SourceSurf
, sx
, sy
));
783 for (count
=DesY
;count
<saveY
;count
++)
784 DIB_1BPP_PutPixel(DestSurf
, DesX
, count
, color
);
792 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
793 /* This is a reference implementation, it hasn't been optimized for speed */
796 /* Draw one Hline on X - Led to the Des Zoom In*/
797 if (DesSizeX
>SrcSizeX
)
799 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
802 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
804 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
806 if (sy
> SourceRect
->bottom
) break;
810 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
812 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
814 if (sx
> SourceRect
->right
) break;
816 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_8BPP_GetPixel(SourceSurf
, sx
, sy
));
818 saveX
= DesX
+ zoomX
;
819 for (count
=DesY
;count
<saveY
;count
++)
820 DIB_1BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
826 /* Draw one Hline on X - Led to the Des Zoom Out*/
828 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
831 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
833 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
835 if (sy
> SourceRect
->bottom
) break;
839 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
841 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
843 if (sx
> SourceRect
->right
) break;
845 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_8BPP_GetPixel(SourceSurf
, sx
, sy
));
847 saveX
= DesX
+ zoomX
;
848 for (count
=DesY
;count
<saveY
;count
++)
849 DIB_1BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
858 if (DesSizeX
>SrcSizeX
)
860 /* Draw one pixel on X - Led to the Des Zoom In*/
861 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
864 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
866 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
868 if (sy
> SourceRect
->bottom
) break;
872 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
874 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
876 if (sx
> SourceRect
->right
) break;
878 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_8BPP_GetPixel(SourceSurf
, sx
, sy
));
880 for (count
=DesY
;count
<saveY
;count
++)
881 DIB_1BPP_PutPixel(DestSurf
, DesX
, count
, color
);
887 /* Draw one pixel on X - Led to the Des Zoom Out*/
888 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
891 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
893 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
895 if (sy
> SourceRect
->bottom
) break;
899 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
901 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
903 if (sx
> SourceRect
->right
) break;
905 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_8BPP_GetPixel(SourceSurf
, sx
, sy
));
907 for (count
=DesY
;count
<saveY
;count
++)
908 DIB_1BPP_PutPixel(DestSurf
, DesX
, count
, color
);
916 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
917 /* This is a reference implementation, it hasn't been optimized for speed */
920 /* Draw one Hline on X - Led to the Des Zoom In*/
921 if (DesSizeX
>SrcSizeX
)
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
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
938 if (sx
> SourceRect
->right
) break;
940 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_16BPP_GetPixel(SourceSurf
, sx
, sy
));
942 saveX
= DesX
+ zoomX
;
943 for (count
=DesY
;count
<saveY
;count
++)
944 DIB_1BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
950 /* Draw one Hline on X - Led to the Des Zoom Out*/
952 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
955 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
957 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
959 if (sy
> SourceRect
->bottom
) break;
963 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
965 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
967 if (sx
> SourceRect
->right
) break;
969 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_16BPP_GetPixel(SourceSurf
, sx
, sy
));
971 saveX
= DesX
+ zoomX
;
972 for (count
=DesY
;count
<saveY
;count
++)
973 DIB_1BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
982 if (DesSizeX
>SrcSizeX
)
984 /* Draw one pixel on X - Led to the Des Zoom In*/
985 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
988 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
990 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
992 if (sy
> SourceRect
->bottom
) break;
996 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
998 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1000 if (sx
> SourceRect
->right
) break;
1002 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_16BPP_GetPixel(SourceSurf
, sx
, sy
));
1004 for (count
=DesY
;count
<saveY
;count
++)
1005 DIB_1BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1011 /* Draw one pixel on X - Led to the Des Zoom Out*/
1012 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1015 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1017 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1019 if (sy
> SourceRect
->bottom
) break;
1023 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1025 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1027 if (sx
> SourceRect
->right
) break;
1029 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_16BPP_GetPixel(SourceSurf
, sx
, sy
));
1031 for (count
=DesY
;count
<saveY
;count
++)
1032 DIB_1BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1040 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
1041 /* This is a reference implementation, it hasn't been optimized for speed */
1044 /* Draw one Hline on X - Led to the Des Zoom In*/
1045 if (DesSizeX
>SrcSizeX
)
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
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1062 if (sx
> SourceRect
->right
) break;
1064 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_24BPP_GetPixel(SourceSurf
, sx
, sy
));
1066 saveX
= DesX
+ zoomX
;
1067 for (count
=DesY
;count
<saveY
;count
++)
1068 DIB_1BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1074 /* Draw one Hline on X - Led to the Des Zoom Out*/
1076 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1079 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1081 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1083 if (sy
> SourceRect
->bottom
) break;
1087 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1089 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1091 if (sx
> SourceRect
->right
) break;
1093 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_24BPP_GetPixel(SourceSurf
, sx
, sy
));
1095 saveX
= DesX
+ zoomX
;
1096 for (count
=DesY
;count
<saveY
;count
++)
1097 DIB_1BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1106 if (DesSizeX
>SrcSizeX
)
1108 /* Draw one pixel on X - Led to the Des Zoom In*/
1109 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1112 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1114 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1116 if (sy
> SourceRect
->bottom
) break;
1120 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1122 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1124 if (sx
> SourceRect
->right
) break;
1126 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_24BPP_GetPixel(SourceSurf
, sx
, sy
));
1128 for (count
=DesY
;count
<saveY
;count
++)
1129 DIB_1BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1135 /* Draw one pixel on X - Led to the Des Zoom Out*/
1136 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1139 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1141 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1143 if (sy
> SourceRect
->bottom
) break;
1147 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1149 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1151 if (sx
> SourceRect
->right
) break;
1153 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_24BPP_GetPixel(SourceSurf
, sx
, sy
));
1155 for (count
=DesY
;count
<saveY
;count
++)
1156 DIB_1BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1164 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
1165 /* This is a reference implementation, it hasn't been optimized for speed */
1168 /* Draw one Hline on X - Led to the Des Zoom In*/
1169 if (DesSizeX
>SrcSizeX
)
1171 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1174 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1176 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1178 if (sy
> SourceRect
->bottom
) break;
1182 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1184 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1186 if (sx
> SourceRect
->right
) break;
1188 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_32BPP_GetPixel(SourceSurf
, sx
, sy
));
1190 saveX
= DesX
+ zoomX
;
1191 for (count
=DesY
;count
<saveY
;count
++)
1192 DIB_1BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1198 /* Draw one Hline on X - Led to the Des Zoom Out*/
1200 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1203 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1205 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1207 if (sy
> SourceRect
->bottom
) break;
1211 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1213 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1215 if (sx
> SourceRect
->right
) break;
1217 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_32BPP_GetPixel(SourceSurf
, sx
, sy
));
1219 saveX
= DesX
+ zoomX
;
1220 for (count
=DesY
;count
<saveY
;count
++)
1221 DIB_1BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1230 if (DesSizeX
>SrcSizeX
)
1232 /* Draw one pixel on X - Led to the Des Zoom In*/
1233 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1236 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1238 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1240 if (sy
> SourceRect
->bottom
) break;
1244 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1246 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1248 if (sx
> SourceRect
->right
) break;
1250 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_32BPP_GetPixel(SourceSurf
, sx
, sy
));
1252 for (count
=DesY
;count
<saveY
;count
++)
1253 DIB_1BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1259 /* Draw one pixel on X - Led to the Des Zoom Out*/
1260 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1263 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1265 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1267 if (sy
> SourceRect
->bottom
) break;
1271 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1273 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1275 if (sx
> SourceRect
->right
) break;
1277 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_32BPP_GetPixel(SourceSurf
, sx
, sy
));
1279 for (count
=DesY
;count
<saveY
;count
++)
1280 DIB_1BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1288 //DPRINT1("DIB_4BPP_StretchBlt: Unhandled Source BPP: %u\n", BitsPerFormat(SourceSurf->iBitmapFormat));
1296 DIB_1BPP_TransparentBlt(SURFOBJ
*DestSurf
, SURFOBJ
*SourceSurf
,
1297 RECTL
* DestRect
, POINTL
*SourcePoint
,
1298 XLATEOBJ
*ColorTranslation
, ULONG iTransColor
)