2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 DIB_1BPP_PutPixel(SURFOBJ
*SurfObj
, LONG x
, LONG y
, ULONG c
)
28 PBYTE addr
= SurfObj
->pvScan0
+ y
* SurfObj
->lDelta
+ (x
>> 3);
31 *addr
&= ~MASK1BPP(x
);
37 DIB_1BPP_GetPixel(SURFOBJ
*SurfObj
, LONG x
, LONG y
)
39 PBYTE addr
= SurfObj
->pvScan0
+ y
* SurfObj
->lDelta
+ (x
>> 3);
41 return (*addr
& MASK1BPP(x
) ? 1 : 0);
45 DIB_1BPP_HLine(SURFOBJ
*SurfObj
, LONG x1
, LONG x2
, LONG y
, ULONG c
)
48 DIB_1BPP_PutPixel(SurfObj
, x1
, y
, c
);
54 DIB_1BPP_VLine(SURFOBJ
*SurfObj
, LONG x
, LONG y1
, LONG y2
, ULONG c
)
57 DIB_1BPP_PutPixel(SurfObj
, x
, y1
, c
);
64 DIB_1BPP_BitBltSrcCopy_From1BPP (
65 SURFOBJ
* DestSurf
, SURFOBJ
* SourceSurf
,
66 PRECTL DestRect
, POINTL
*SourcePoint
)
68 // the 'window' in this sense is the x-position that corresponds
69 // to the left-edge of the 8-pixel byte we are currently working with.
70 // dwx is current x-window, dwx2 is the 'last' window we need to process
71 int dwx
, dwx2
; // destination window x-position
72 int swx
; // source window y-position
74 // left and right edges of source and dest rectangles
75 int dl
= DestRect
->left
; // dest left
76 int dr
= DestRect
->right
-1; // dest right (inclusive)
77 int sl
= SourcePoint
->x
; // source left
78 int sr
= sl
+ dr
- dl
; // source right (inclusive)
80 // which direction are we going?
83 int ySrcDelta
, yDstDelta
;
85 // following 4 variables are used for the y-sweep
87 int dy1
; // dest y start
88 int dy2
; // dest y end
89 int sy1
; // src y start
92 BYTE srcmask
, dstmask
;
94 // 'd' and 's' are the dest & src buffer pointers that I use on my x-sweep
95 // 'pd' and 'ps' are the dest & src buffer pointers used on the inner y-sweep
96 PBYTE d
, pd
; // dest ptrs
97 PBYTE s
, ps
; // src ptrs
101 if ( DestRect
->top
<= SourcePoint
->y
)
103 // moving up ( scan top -> bottom )
105 dy2
= DestRect
->bottom
- 1;
106 sy1
= SourcePoint
->y
;
108 ySrcDelta
= SourceSurf
->lDelta
;
109 yDstDelta
= DestSurf
->lDelta
;
113 // moving down ( scan bottom -> top )
114 dy1
= DestRect
->bottom
- 1;
116 sy1
= SourcePoint
->y
+ dy1
- dy2
;
118 ySrcDelta
= -SourceSurf
->lDelta
;
119 yDstDelta
= -DestSurf
->lDelta
;
121 if ( DestRect
->left
<= SourcePoint
->x
)
123 // moving left ( scan left->right )
125 swx
= (sl
-(dl
&7))&~7;
131 // moving right ( scan right->left )
133 swx
= (sr
-(dr
&7))&~7; //(sr-7)&~7; // we need the left edge of this block... thus the -7
137 d
= &(((PBYTE
)DestSurf
->pvScan0
)[dy1
*DestSurf
->lDelta
+ (dwx
>>3)]);
138 s
= &(((PBYTE
)SourceSurf
->pvScan0
)[sy1
*SourceSurf
->lDelta
+ (swx
>>3)]);
145 int dx
= dwx
; /* dest x for this pass */
149 srcmask
&= (1<<(8-diff
))-1;
155 srcmask
&= ~((1<<(8-diff
))-1);
159 // we unfortunately *must* have 5 different versions of the inner
160 // loop to be certain we don't try to read from memory that is not
161 // needed and may in fact be invalid
166 *pd
= (BYTE
)((*pd
& dstmask
) | (*ps
& srcmask
));
168 // this *must* be here, because we could be going up *or* down...
176 else if ( !(0xFF00 & (srcmask
<<shift
) ) ) // check if ps[0] not needed...
180 *pd
= (BYTE
)((*pd
& dstmask
)
181 | ( ( ps
[1] >> shift
) & srcmask
));
183 // this *must* be here, because we could be going up *or* down...
191 else if ( !(0xFF & (srcmask
<<shift
) ) ) // check if ps[1] not needed...
195 *pd
= (*pd
& dstmask
)
196 | ( ( ps
[0] << ( 8 - shift
) ) & srcmask
);
198 // this *must* be here, because we could be going up *or* down...
206 else // both ps[0] and ps[1] are needed
210 *pd
= (*pd
& dstmask
)
211 | ( ( ( (ps
[1])|(ps
[0]<<8) ) >> shift
) & srcmask
);
213 // this *must* be here, because we could be going up *or* down...
222 // this *must* be here, because we could be going right *or* left...
233 DIB_1BPP_BitBltSrcCopy(PBLTINFO BltInfo
)
235 LONG i
, j
, sx
, sy
= BltInfo
->SourcePoint
.y
;
237 switch ( BltInfo
->SourceSurface
->iBitmapFormat
)
240 DIB_1BPP_BitBltSrcCopy_From1BPP ( BltInfo
->DestSurface
, BltInfo
->SourceSurface
, &BltInfo
->DestRect
, &BltInfo
->SourcePoint
);
244 for (j
=BltInfo
->DestRect
.top
; j
<BltInfo
->DestRect
.bottom
; j
++)
246 sx
= BltInfo
->SourcePoint
.x
;
247 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
249 if(XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, DIB_4BPP_GetPixel(BltInfo
->SourceSurface
, sx
, sy
)) == 0)
251 DIB_1BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, 0);
253 DIB_1BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, 1);
262 for (j
=BltInfo
->DestRect
.top
; j
<BltInfo
->DestRect
.bottom
; j
++)
264 sx
= BltInfo
->SourcePoint
.x
;
265 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
267 if(XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, DIB_8BPP_GetPixel(BltInfo
->SourceSurface
, sx
, sy
)) == 0)
269 DIB_1BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, 0);
271 DIB_1BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, 1);
280 for (j
=BltInfo
->DestRect
.top
; j
<BltInfo
->DestRect
.bottom
; j
++)
282 sx
= BltInfo
->SourcePoint
.x
;
283 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
285 if(XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, DIB_16BPP_GetPixel(BltInfo
->SourceSurface
, sx
, sy
)) == 0)
287 DIB_1BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, 0);
289 DIB_1BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, 1);
298 for (j
=BltInfo
->DestRect
.top
; j
<BltInfo
->DestRect
.bottom
; j
++)
300 sx
= BltInfo
->SourcePoint
.x
;
301 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
303 if(XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, DIB_24BPP_GetPixel(BltInfo
->SourceSurface
, sx
, sy
)) == 0)
305 DIB_1BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, 0);
307 DIB_1BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, 1);
316 for (j
=BltInfo
->DestRect
.top
; j
<BltInfo
->DestRect
.bottom
; j
++)
318 sx
= BltInfo
->SourcePoint
.x
;
319 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
321 if(XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, DIB_32BPP_GetPixel(BltInfo
->SourceSurface
, sx
, sy
)) == 0)
323 DIB_1BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, 0);
325 DIB_1BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, 1);
334 DbgPrint("DIB_1BPP_BitBlt: Unhandled Source BPP: %u\n", BitsPerFormat(BltInfo
->SourceSurface
->iBitmapFormat
));
342 DIB_1BPP_BitBlt(PBLTINFO BltInfo
)
345 ULONG SourceX
, SourceY
;
347 ULONG Dest
, Source
= 0, Pattern
= 0;
355 UsesSource
= ROP4_USES_SOURCE(BltInfo
->Rop4
);
356 UsesPattern
= ROP4_USES_PATTERN(BltInfo
->Rop4
);
358 RoundedRight
= BltInfo
->DestRect
.right
-
359 ((BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
) & 31);
360 SourceY
= BltInfo
->SourcePoint
.y
;
364 if (BltInfo
->PatternSurface
)
366 PatternY
= (BltInfo
->DestRect
.top
+ BltInfo
->BrushOrigin
.y
) %
367 BltInfo
->PatternSurface
->sizlBitmap
.cy
;
371 /* FIXME: Shouldn't it be expanded? */
372 Pattern
= BltInfo
->Brush
->iSolidColor
;
376 for (DestY
= BltInfo
->DestRect
.top
; DestY
< BltInfo
->DestRect
.bottom
; DestY
++)
378 DestX
= BltInfo
->DestRect
.left
;
379 SourceX
= BltInfo
->SourcePoint
.x
;
381 BltInfo
->DestSurface
->pvScan0
+
382 (BltInfo
->DestRect
.left
>> 3) +
383 DestY
* BltInfo
->DestSurface
->lDelta
);
388 /* FIXME: This case is completely untested!!! */
390 Dest
= *((PBYTE
)DestBits
);
391 NoBits
= 31 - (DestX
& 31);
396 /* FIXME: This is incorrect! */
397 for (Index
= 31 - NoBits
; Index
>= 0; Index
++)
398 Source
|= (DIB_GetSource(SourceSurf
, SourceX
+ Index
, SourceY
, ColorTranslation
) << (31 - Index
));
401 if (BltInfo
->PatternSurface
)
404 for (k
= 31 - NoBits
; k
>= 0; k
++)
405 Pattern
|= (DIB_GetSource(PatternObj
, (X
+ BrushOrigin
.x
+ k
) % PatternWidth
, PatternY
, BltInfo
->XlatePatternToDest
) << (31 - k
));
408 Dest
= DIB_DoRop(Rop4
, Dest
, Source
, Pattern
);
409 Dest
&= ~((1 << (31 - NoBits
)) - 1);
410 Dest
|= *((PBYTE
)DestBits
) & ((1 << (31 - NoBits
)) - 1);
419 for (; DestX
< RoundedRight
; DestX
+= 32, DestBits
++, SourceX
++)
426 for (Index
= 0; Index
< 8; Index
++)
428 Source
|= DIB_GetSource(BltInfo
->SourceSurface
, SourceX
+ Index
, SourceY
, BltInfo
->XlateSourceToDest
) << (7 - Index
);
429 Source
|= DIB_GetSource(BltInfo
->SourceSurface
, SourceX
+ Index
+ 8, SourceY
, BltInfo
->XlateSourceToDest
) << (8 + (7 - Index
));
430 Source
|= DIB_GetSource(BltInfo
->SourceSurface
, SourceX
+ Index
+ 16, SourceY
, BltInfo
->XlateSourceToDest
) << (16 + (7 - Index
));
431 Source
|= DIB_GetSource(BltInfo
->SourceSurface
, SourceX
+ Index
+ 24, SourceY
, BltInfo
->XlateSourceToDest
) << (24 + (7 - Index
));
435 if (BltInfo
->PatternSurface
)
438 for (Index
= 0; Index
< 8; Index
++)
440 Pattern
|= DIB_GetSource(BltInfo
->PatternSurface
, (DestX
+ BltInfo
->BrushOrigin
.x
+ Index
) % BltInfo
->PatternSurface
->sizlBitmap
.cx
, PatternY
, BltInfo
->XlatePatternToDest
) << (7 - Index
);
441 Pattern
|= DIB_GetSource(BltInfo
->PatternSurface
, (DestX
+ BltInfo
->BrushOrigin
.x
+ Index
+ 8) % BltInfo
->PatternSurface
->sizlBitmap
.cx
, PatternY
, BltInfo
->XlatePatternToDest
) << (8 + (7 - Index
));
442 Pattern
|= DIB_GetSource(BltInfo
->PatternSurface
, (DestX
+ BltInfo
->BrushOrigin
.x
+ Index
+ 16) % BltInfo
->PatternSurface
->sizlBitmap
.cx
, PatternY
, BltInfo
->XlatePatternToDest
) << (16 + (7 - Index
));
443 Pattern
|= DIB_GetSource(BltInfo
->PatternSurface
, (DestX
+ BltInfo
->BrushOrigin
.x
+ Index
+ 24) % BltInfo
->PatternSurface
->sizlBitmap
.cx
, PatternY
, BltInfo
->XlatePatternToDest
) << (24 + (7 - Index
));
447 *DestBits
= DIB_DoRop(BltInfo
->Rop4
, Dest
, Source
, Pattern
);
450 if (DestX
< BltInfo
->DestRect
.right
)
453 for (; DestX
< BltInfo
->DestRect
.right
; DestX
++, SourceX
++)
456 Dest
= DIB_1BPP_GetPixel(BltInfo
->DestSurface
, DestX
, DestY
);
460 Source
= DIB_GetSource(BltInfo
->SourceSurface
, SourceX
, SourceY
, BltInfo
->XlateSourceToDest
);
463 if (BltInfo
->PatternSurface
)
465 Pattern
= DIB_GetSource(BltInfo
->PatternSurface
, (DestX
+ BltInfo
->BrushOrigin
.x
) % BltInfo
->PatternSurface
->sizlBitmap
.cx
, PatternY
, BltInfo
->XlatePatternToDest
);
468 DIB_1BPP_PutPixel(BltInfo
->DestSurface
, DestX
, DestY
, DIB_DoRop(BltInfo
->Rop4
, Dest
, Source
, Pattern
) & 0xF);
474 if (BltInfo
->PatternSurface
)
477 PatternY
%= BltInfo
->PatternSurface
->sizlBitmap
.cy
;
484 /* BitBlt Optimize */
486 DIB_1BPP_ColorFill(SURFOBJ
* DestSurface
, RECTL
* DestRect
, ULONG color
)
490 for (DestY
= DestRect
->top
; DestY
< DestRect
->bottom
; DestY
++)
492 DIB_1BPP_HLine(DestSurface
, DestRect
->left
, DestRect
->right
, DestY
, color
);
498 //NOTE: If you change something here, please do the same in other dibXXbpp.c files!
499 BOOLEAN
DIB_1BPP_StretchBlt(SURFOBJ
*DestSurf
, SURFOBJ
*SourceSurf
,
500 RECTL
* DestRect
, RECTL
*SourceRect
,
501 POINTL
* MaskOrigin
, POINTL BrushOrigin
,
502 CLIPOBJ
*ClipRegion
, XLATEOBJ
*ColorTranslation
,
519 BOOLEAN DesIsBiggerY
=FALSE
;
521 SrcSizeY
= SourceRect
->bottom
;
522 SrcSizeX
= SourceRect
->right
;
524 DesSizeY
= DestRect
->bottom
;
525 DesSizeX
= DestRect
->right
;
527 zoomX
= DesSizeX
/ SrcSizeX
;
528 if (zoomX
==0) zoomX
=1;
530 zoomY
= DesSizeY
/ SrcSizeY
;
531 if (zoomY
==0) zoomY
=1;
533 if (DesSizeY
>SrcSizeY
)
537 switch(SourceSurf
->iBitmapFormat
)
540 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
541 /* This is a reference implementation, it hasn't been optimized for speed */
544 /* Draw one Hline on X - Led to the Des Zoom In*/
545 if (DesSizeX
>SrcSizeX
)
547 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
550 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
552 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
554 if (sy
> SourceRect
->bottom
) break;
558 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
560 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
562 if (sx
> SourceRect
->right
) break;
564 saveX
= DesX
+ zoomX
;
566 color
= DIB_1BPP_GetPixel(SourceSurf
, sx
, sy
);
568 for (count
=DesY
;count
<saveY
;count
++)
569 DIB_1BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
577 /* Draw one Hline on X - Led to the Des Zoom Out*/
579 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
582 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
584 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
586 if (sy
> SourceRect
->bottom
) break;
590 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
592 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
594 if (sx
> SourceRect
->right
) break;
596 saveX
= DesX
+ zoomX
;
598 color
= DIB_1BPP_GetPixel(SourceSurf
, sx
, sy
);
600 for (count
=DesY
;count
<saveY
;count
++)
601 DIB_1BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
611 if (DesSizeX
>SrcSizeX
)
613 /* Draw one pixel on X - Led to the Des Zoom In*/
614 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
617 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
619 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
621 if (sy
> SourceRect
->bottom
) break;
625 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
627 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
629 if (sx
> SourceRect
->right
) break;
631 color
= DIB_1BPP_GetPixel(SourceSurf
, sx
, sy
);
633 for (count
=DesY
;count
<saveY
;count
++)
634 DIB_1BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
641 /* Draw one pixel on X - Led to the Des Zoom Out*/
642 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
645 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
647 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
649 if (sy
> SourceRect
->bottom
) break;
653 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
655 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
657 if (sx
> SourceRect
->right
) break;
659 color
= DIB_1BPP_GetPixel(SourceSurf
, sx
, sy
);
661 for (count
=DesY
;count
<saveY
;count
++)
662 DIB_1BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
671 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
672 /* This is a reference implementation, it hasn't been optimized for speed */
675 /* Draw one Hline on X - Led to the Des Zoom In*/
676 if (DesSizeX
>SrcSizeX
)
678 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
681 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
683 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
685 if (sy
> SourceRect
->bottom
) break;
689 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
691 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
693 if (sx
> SourceRect
->right
) break;
695 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_4BPP_GetPixel(SourceSurf
, sx
, sy
));
697 saveX
= DesX
+ zoomX
;
698 for (count
=DesY
;count
<saveY
;count
++)
699 DIB_1BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
705 /* Draw one Hline on X - Led to the Des Zoom Out*/
707 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
710 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
712 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
714 if (sy
> SourceRect
->bottom
) break;
718 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
720 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
722 if (sx
> SourceRect
->right
) break;
724 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_4BPP_GetPixel(SourceSurf
, sx
, sy
));
726 saveX
= DesX
+ zoomX
;
727 for (count
=DesY
;count
<saveY
;count
++)
728 DIB_1BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
737 if (DesSizeX
>SrcSizeX
)
739 /* Draw one pixel on X - Led to the Des Zoom In*/
740 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
743 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
745 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
747 if (sy
> SourceRect
->bottom
) break;
751 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
753 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
755 if (sx
> SourceRect
->right
) break;
757 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_4BPP_GetPixel(SourceSurf
, sx
, sy
));
759 for (count
=DesY
;count
<saveY
;count
++)
760 DIB_1BPP_PutPixel(DestSurf
, DesX
, count
, color
);
766 /* Draw one pixel on X - Led to the Des Zoom Out*/
767 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
770 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
772 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
774 if (sy
> SourceRect
->bottom
) break;
778 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
780 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
782 if (sx
> SourceRect
->right
) break;
784 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_4BPP_GetPixel(SourceSurf
, sx
, sy
));
786 for (count
=DesY
;count
<saveY
;count
++)
787 DIB_1BPP_PutPixel(DestSurf
, DesX
, count
, color
);
795 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
796 /* This is a reference implementation, it hasn't been optimized for speed */
799 /* Draw one Hline on X - Led to the Des Zoom In*/
800 if (DesSizeX
>SrcSizeX
)
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
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
817 if (sx
> SourceRect
->right
) break;
819 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_8BPP_GetPixel(SourceSurf
, sx
, sy
));
821 saveX
= DesX
+ zoomX
;
822 for (count
=DesY
;count
<saveY
;count
++)
823 DIB_1BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
829 /* Draw one Hline on X - Led to the Des Zoom Out*/
831 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
834 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
836 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
838 if (sy
> SourceRect
->bottom
) break;
842 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
844 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
846 if (sx
> SourceRect
->right
) break;
848 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_8BPP_GetPixel(SourceSurf
, sx
, sy
));
850 saveX
= DesX
+ zoomX
;
851 for (count
=DesY
;count
<saveY
;count
++)
852 DIB_1BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
861 if (DesSizeX
>SrcSizeX
)
863 /* Draw one pixel on X - Led to the Des Zoom In*/
864 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
867 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
869 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
871 if (sy
> SourceRect
->bottom
) break;
875 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
877 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
879 if (sx
> SourceRect
->right
) break;
881 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_8BPP_GetPixel(SourceSurf
, sx
, sy
));
883 for (count
=DesY
;count
<saveY
;count
++)
884 DIB_1BPP_PutPixel(DestSurf
, DesX
, count
, color
);
890 /* Draw one pixel on X - Led to the Des Zoom Out*/
891 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
894 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
896 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
898 if (sy
> SourceRect
->bottom
) break;
902 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
904 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
906 if (sx
> SourceRect
->right
) break;
908 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_8BPP_GetPixel(SourceSurf
, sx
, sy
));
910 for (count
=DesY
;count
<saveY
;count
++)
911 DIB_1BPP_PutPixel(DestSurf
, DesX
, count
, color
);
919 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
920 /* This is a reference implementation, it hasn't been optimized for speed */
923 /* Draw one Hline on X - Led to the Des Zoom In*/
924 if (DesSizeX
>SrcSizeX
)
926 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
929 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
931 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
933 if (sy
> SourceRect
->bottom
) break;
937 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
939 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
941 if (sx
> SourceRect
->right
) break;
943 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_16BPP_GetPixel(SourceSurf
, sx
, sy
));
945 saveX
= DesX
+ zoomX
;
946 for (count
=DesY
;count
<saveY
;count
++)
947 DIB_1BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
953 /* Draw one Hline on X - Led to the Des Zoom Out*/
955 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
958 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
960 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
962 if (sy
> SourceRect
->bottom
) break;
966 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
968 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
970 if (sx
> SourceRect
->right
) break;
972 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_16BPP_GetPixel(SourceSurf
, sx
, sy
));
974 saveX
= DesX
+ zoomX
;
975 for (count
=DesY
;count
<saveY
;count
++)
976 DIB_1BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
985 if (DesSizeX
>SrcSizeX
)
987 /* Draw one pixel on X - Led to the Des Zoom In*/
988 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
991 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
993 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
995 if (sy
> SourceRect
->bottom
) break;
999 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1001 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1003 if (sx
> SourceRect
->right
) break;
1005 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_16BPP_GetPixel(SourceSurf
, sx
, sy
));
1007 for (count
=DesY
;count
<saveY
;count
++)
1008 DIB_1BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1014 /* Draw one pixel on X - Led to the Des Zoom Out*/
1015 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1018 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1020 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1022 if (sy
> SourceRect
->bottom
) break;
1026 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1028 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1030 if (sx
> SourceRect
->right
) break;
1032 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_16BPP_GetPixel(SourceSurf
, sx
, sy
));
1034 for (count
=DesY
;count
<saveY
;count
++)
1035 DIB_1BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1043 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
1044 /* This is a reference implementation, it hasn't been optimized for speed */
1047 /* Draw one Hline on X - Led to the Des Zoom In*/
1048 if (DesSizeX
>SrcSizeX
)
1050 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1053 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1055 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1057 if (sy
> SourceRect
->bottom
) break;
1061 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1063 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1065 if (sx
> SourceRect
->right
) break;
1067 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_24BPP_GetPixel(SourceSurf
, sx
, sy
));
1069 saveX
= DesX
+ zoomX
;
1070 for (count
=DesY
;count
<saveY
;count
++)
1071 DIB_1BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1077 /* Draw one Hline on X - Led to the Des Zoom Out*/
1079 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1082 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1084 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1086 if (sy
> SourceRect
->bottom
) break;
1090 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1092 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1094 if (sx
> SourceRect
->right
) break;
1096 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_24BPP_GetPixel(SourceSurf
, sx
, sy
));
1098 saveX
= DesX
+ zoomX
;
1099 for (count
=DesY
;count
<saveY
;count
++)
1100 DIB_1BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1109 if (DesSizeX
>SrcSizeX
)
1111 /* Draw one pixel on X - Led to the Des Zoom In*/
1112 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1115 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1117 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1119 if (sy
> SourceRect
->bottom
) break;
1123 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1125 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1127 if (sx
> SourceRect
->right
) break;
1129 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_24BPP_GetPixel(SourceSurf
, sx
, sy
));
1131 for (count
=DesY
;count
<saveY
;count
++)
1132 DIB_1BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1138 /* Draw one pixel on X - Led to the Des Zoom Out*/
1139 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1142 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1144 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1146 if (sy
> SourceRect
->bottom
) break;
1150 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1152 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1154 if (sx
> SourceRect
->right
) break;
1156 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_24BPP_GetPixel(SourceSurf
, sx
, sy
));
1158 for (count
=DesY
;count
<saveY
;count
++)
1159 DIB_1BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1167 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
1168 /* This is a reference implementation, it hasn't been optimized for speed */
1171 /* Draw one Hline on X - Led to the Des Zoom In*/
1172 if (DesSizeX
>SrcSizeX
)
1174 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1177 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1179 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1181 if (sy
> SourceRect
->bottom
) break;
1185 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1187 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1189 if (sx
> SourceRect
->right
) break;
1191 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_32BPP_GetPixel(SourceSurf
, sx
, sy
));
1193 saveX
= DesX
+ zoomX
;
1194 for (count
=DesY
;count
<saveY
;count
++)
1195 DIB_1BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1201 /* Draw one Hline on X - Led to the Des Zoom Out*/
1203 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1206 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1208 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1210 if (sy
> SourceRect
->bottom
) break;
1214 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1216 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1218 if (sx
> SourceRect
->right
) break;
1220 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_32BPP_GetPixel(SourceSurf
, sx
, sy
));
1222 saveX
= DesX
+ zoomX
;
1223 for (count
=DesY
;count
<saveY
;count
++)
1224 DIB_1BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1233 if (DesSizeX
>SrcSizeX
)
1235 /* Draw one pixel on X - Led to the Des Zoom In*/
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
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1251 if (sx
> SourceRect
->right
) break;
1253 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_32BPP_GetPixel(SourceSurf
, sx
, sy
));
1255 for (count
=DesY
;count
<saveY
;count
++)
1256 DIB_1BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1262 /* Draw one pixel on X - Led to the Des Zoom Out*/
1263 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1266 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1268 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1270 if (sy
> SourceRect
->bottom
) break;
1274 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1276 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1278 if (sx
> SourceRect
->right
) break;
1280 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_32BPP_GetPixel(SourceSurf
, sx
, sy
));
1282 for (count
=DesY
;count
<saveY
;count
++)
1283 DIB_1BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1291 //DPRINT1("DIB_4BPP_StretchBlt: Unhandled Source BPP: %u\n", BitsPerFormat(SourceSurf->iBitmapFormat));
1299 DIB_1BPP_TransparentBlt(SURFOBJ
*DestSurf
, SURFOBJ
*SourceSurf
,
1300 RECTL
* DestRect
, POINTL
*SourcePoint
,
1301 XLATEOBJ
*ColorTranslation
, ULONG iTransColor
)