2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 DIB_8BPP_PutPixel(SURFOBJ
*SurfObj
, LONG x
, LONG y
, ULONG c
)
29 PBYTE byteaddr
= (PBYTE
)SurfObj
->pvScan0
+ y
* SurfObj
->lDelta
+ x
;
35 DIB_8BPP_GetPixel(SURFOBJ
*SurfObj
, LONG x
, LONG y
)
37 PBYTE byteaddr
= (PBYTE
)SurfObj
->pvScan0
+ y
* SurfObj
->lDelta
+ x
;
39 return (ULONG
)(*byteaddr
);
43 DIB_8BPP_HLine(SURFOBJ
*SurfObj
, LONG x1
, LONG x2
, LONG y
, ULONG c
)
45 memset((PBYTE
)SurfObj
->pvScan0
+ y
* SurfObj
->lDelta
+ x1
, (BYTE
) c
, x2
- x1
);
49 DIB_8BPP_VLine(SURFOBJ
*SurfObj
, LONG x
, LONG y1
, LONG y2
, ULONG c
)
51 PBYTE byteaddr
= (PBYTE
)SurfObj
->pvScan0
+ y1
* SurfObj
->lDelta
;
52 PBYTE addr
= byteaddr
+ x
;
53 LONG lDelta
= SurfObj
->lDelta
;
64 DIB_8BPP_BitBltSrcCopy(PBLTINFO BltInfo
)
66 LONG i
, j
, sx
, sy
, xColor
, f1
;
67 PBYTE SourceBits
, DestBits
, SourceLine
, DestLine
;
68 PBYTE SourceBits_4BPP
, SourceLine_4BPP
;
70 DestBits
= (PBYTE
)BltInfo
->DestSurface
->pvScan0
+ (BltInfo
->DestRect
.top
* BltInfo
->DestSurface
->lDelta
) + BltInfo
->DestRect
.left
;
72 switch(BltInfo
->SourceSurface
->iBitmapFormat
)
75 sx
= BltInfo
->SourcePoint
.x
;
76 sy
= BltInfo
->SourcePoint
.y
;
78 for (j
=BltInfo
->DestRect
.top
; j
<BltInfo
->DestRect
.bottom
; j
++)
80 sx
= BltInfo
->SourcePoint
.x
;
81 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
83 if(DIB_1BPP_GetPixel(BltInfo
->SourceSurface
, sx
, sy
) == 0)
85 DIB_8BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, 0));
87 DIB_8BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, 1));
96 SourceBits_4BPP
= (PBYTE
)BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + (BltInfo
->SourcePoint
.x
>> 1);
98 for (j
=BltInfo
->DestRect
.top
; j
<BltInfo
->DestRect
.bottom
; j
++)
100 SourceLine_4BPP
= SourceBits_4BPP
;
101 sx
= BltInfo
->SourcePoint
.x
;
104 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
106 xColor
= XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
,
107 (*SourceLine_4BPP
& altnotmask
[f1
]) >> (4 * (1 - f1
)));
108 DIB_8BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, xColor
);
109 if(f1
== 1) { SourceLine_4BPP
++; f1
= 0; } else { f1
= 1; }
113 SourceBits_4BPP
+= BltInfo
->SourceSurface
->lDelta
;
118 if (NULL
== BltInfo
->XlateSourceToDest
|| 0 != (BltInfo
->XlateSourceToDest
->flXlate
& XO_TRIVIAL
))
120 if (BltInfo
->DestRect
.top
< BltInfo
->SourcePoint
.y
)
122 SourceBits
= (PBYTE
)BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + BltInfo
->SourcePoint
.x
;
123 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
125 RtlMoveMemory(DestBits
, SourceBits
, BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
);
126 SourceBits
+= BltInfo
->SourceSurface
->lDelta
;
127 DestBits
+= BltInfo
->DestSurface
->lDelta
;
132 SourceBits
= (PBYTE
)BltInfo
->SourceSurface
->pvScan0
+ ((BltInfo
->SourcePoint
.y
+ BltInfo
->DestRect
.bottom
- BltInfo
->DestRect
.top
- 1) * BltInfo
->SourceSurface
->lDelta
) + BltInfo
->SourcePoint
.x
;
133 DestBits
= (PBYTE
)BltInfo
->DestSurface
->pvScan0
+ ((BltInfo
->DestRect
.bottom
- 1) * BltInfo
->DestSurface
->lDelta
) + BltInfo
->DestRect
.left
;
134 for (j
= BltInfo
->DestRect
.bottom
- 1; BltInfo
->DestRect
.top
<= j
; j
--)
136 RtlMoveMemory(DestBits
, SourceBits
, BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
);
137 SourceBits
-= BltInfo
->SourceSurface
->lDelta
;
138 DestBits
-= BltInfo
->DestSurface
->lDelta
;
144 if (BltInfo
->DestRect
.top
< BltInfo
->SourcePoint
.y
)
146 SourceLine
= (PBYTE
)BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + BltInfo
->SourcePoint
.x
;
148 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
150 SourceBits
= SourceLine
;
152 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
154 *DestBits
++ = XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, *SourceBits
++);
156 SourceLine
+= BltInfo
->SourceSurface
->lDelta
;
157 DestLine
+= BltInfo
->DestSurface
->lDelta
;
162 SourceLine
= (PBYTE
)BltInfo
->SourceSurface
->pvScan0
+ ((BltInfo
->SourcePoint
.y
+ BltInfo
->DestRect
.bottom
- BltInfo
->DestRect
.top
- 1) * BltInfo
->SourceSurface
->lDelta
) + BltInfo
->SourcePoint
.x
;
163 DestLine
= (PBYTE
)BltInfo
->DestSurface
->pvScan0
+ ((BltInfo
->DestRect
.bottom
- 1) * BltInfo
->DestSurface
->lDelta
) + BltInfo
->DestRect
.left
;
164 for (j
= BltInfo
->DestRect
.bottom
- 1; BltInfo
->DestRect
.top
<= j
; j
--)
166 SourceBits
= SourceLine
;
168 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
170 *DestBits
++ = XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, *SourceBits
++);
172 SourceLine
-= BltInfo
->SourceSurface
->lDelta
;
173 DestLine
-= BltInfo
->DestSurface
->lDelta
;
180 SourceLine
= (PBYTE
)BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + 2 * BltInfo
->SourcePoint
.x
;
183 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
185 SourceBits
= SourceLine
;
188 for (i
= BltInfo
->DestRect
.left
; i
< BltInfo
->DestRect
.right
; i
++)
190 xColor
= *((PWORD
) SourceBits
);
191 *DestBits
= XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, xColor
);
196 SourceLine
+= BltInfo
->SourceSurface
->lDelta
;
197 DestLine
+= BltInfo
->DestSurface
->lDelta
;
202 SourceLine
= (PBYTE
)BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + 3 * BltInfo
->SourcePoint
.x
;
205 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
207 SourceBits
= SourceLine
;
210 for (i
= BltInfo
->DestRect
.left
; i
< BltInfo
->DestRect
.right
; i
++)
212 xColor
= (*(SourceBits
+ 2) << 0x10) +
213 (*(SourceBits
+ 1) << 0x08) +
215 *DestBits
= XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, xColor
);
220 SourceLine
+= BltInfo
->SourceSurface
->lDelta
;
221 DestLine
+= BltInfo
->DestSurface
->lDelta
;
226 SourceLine
= (PBYTE
)BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + 4 * BltInfo
->SourcePoint
.x
;
229 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
231 SourceBits
= SourceLine
;
234 for (i
= BltInfo
->DestRect
.left
; i
< BltInfo
->DestRect
.right
; i
++)
236 xColor
= *((PDWORD
) SourceBits
);
237 *DestBits
= XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, xColor
);
242 SourceLine
+= BltInfo
->SourceSurface
->lDelta
;
243 DestLine
+= BltInfo
->DestSurface
->lDelta
;
248 DPRINT1("DIB_8BPP_Bitblt: Unhandled Source BPP: %u\n", BitsPerFormat(BltInfo
->SourceSurface
->iBitmapFormat
));
255 /* BitBlt Optimize */
257 DIB_8BPP_ColorFill(SURFOBJ
* DestSurface
, RECTL
* DestRect
, ULONG color
)
260 for (DestY
= DestRect
->top
; DestY
< DestRect
->bottom
; DestY
++)
262 DIB_8BPP_HLine(DestSurface
, DestRect
->left
, DestRect
->right
, DestY
, color
);
268 =======================================
269 Stretching functions goes below
270 Some parts of code are based on an
271 article "Bresenhame image scaling"
272 Dr. Dobb Journal, May 2002
273 =======================================
276 typedef unsigned char PIXEL
;
278 /* 16-bit HiColor (565 format) */
279 inline PIXEL
average8(PIXEL a
, PIXEL b
)
281 return a
; // FIXME: Depend on SetStretchMode
284 //NOTE: If you change something here, please do the same in other dibXXbpp.c files!
285 void ScaleLineAvg8(PIXEL
*Target
, PIXEL
*Source
, int SrcWidth
, int TgtWidth
)
287 int NumPixels
= TgtWidth
;
288 int IntPart
= SrcWidth
/ TgtWidth
;
289 int FractPart
= SrcWidth
% TgtWidth
;
290 int Mid
= TgtWidth
>> 1;
295 skip
= (TgtWidth
< SrcWidth
) ? 0 : (TgtWidth
/ (2*SrcWidth
) + 1);
298 while (NumPixels
-- > 0) {
301 p
= average8(p
, *(Source
+1));
315 FinalCopy8(PIXEL
*Target
, PIXEL
*Source
, PSPAN ClipSpans
, UINT ClipSpansCount
, UINT
*SpanIndex
,
316 UINT DestY
, RECTL
*DestRect
)
320 while (ClipSpans
[*SpanIndex
].Y
< DestY
321 || (ClipSpans
[*SpanIndex
].Y
== DestY
322 && ClipSpans
[*SpanIndex
].X
+ ClipSpans
[*SpanIndex
].Width
< DestRect
->left
))
325 if (ClipSpansCount
<= *SpanIndex
)
327 /* No more spans, everything else is clipped away, we're done */
331 while (ClipSpans
[*SpanIndex
].Y
== DestY
)
333 if (ClipSpans
[*SpanIndex
].X
< DestRect
->right
)
335 Left
= max(ClipSpans
[*SpanIndex
].X
, DestRect
->left
);
336 Right
= min(ClipSpans
[*SpanIndex
].X
+ ClipSpans
[*SpanIndex
].Width
, DestRect
->right
);
337 memcpy(Target
+ Left
- DestRect
->left
, Source
+ Left
- DestRect
->left
,
338 (Right
- Left
) * sizeof(PIXEL
));
341 if (ClipSpansCount
<= *SpanIndex
)
343 /* No more spans, everything else is clipped away, we're done */
351 //NOTE: If you change something here, please do the same in other dibXXbpp.c files!
352 BOOLEAN
ScaleRectAvg8(SURFOBJ
*DestSurf
, SURFOBJ
*SourceSurf
,
353 RECTL
* DestRect
, RECTL
*SourceRect
,
354 POINTL
* MaskOrigin
, POINTL BrushOrigin
,
355 CLIPOBJ
*ClipRegion
, XLATEOBJ
*ColorTranslation
,
358 int NumPixels
= DestRect
->bottom
- DestRect
->top
;
359 int IntPart
= (((SourceRect
->bottom
- SourceRect
->top
) / (DestRect
->bottom
- DestRect
->top
)) * SourceSurf
->lDelta
); //((SourceRect->bottom - SourceRect->top) / (DestRect->bottom - DestRect->top)) * (SourceRect->right - SourceRect->left);
360 int FractPart
= (SourceRect
->bottom
- SourceRect
->top
) % (DestRect
->bottom
- DestRect
->top
);
361 int Mid
= (DestRect
->bottom
- DestRect
->top
) >> 1;
364 PIXEL
*ScanLine
, *ScanLineAhead
;
365 PIXEL
*PrevSource
= NULL
;
366 PIXEL
*PrevSourceAhead
= NULL
;
367 PIXEL
*Target
= (PIXEL
*) ((PBYTE
)DestSurf
->pvScan0
+ (DestRect
->top
* DestSurf
->lDelta
) + DestRect
->left
);
368 PIXEL
*Source
= (PIXEL
*) ((PBYTE
)SourceSurf
->pvScan0
+ (SourceRect
->top
* SourceSurf
->lDelta
) + SourceRect
->left
);
374 if (! ClipobjToSpans(&ClipSpans
, &ClipSpansCount
, ClipRegion
, DestRect
))
378 if (0 == ClipSpansCount
)
380 /* No clip spans == empty clipping region, everything clipped away */
381 ASSERT(NULL
== ClipSpans
);
384 skip
= (DestRect
->bottom
- DestRect
->top
< SourceRect
->bottom
- SourceRect
->top
) ? 0 : ((DestRect
->bottom
- DestRect
->top
) / (2 * (SourceRect
->bottom
- SourceRect
->top
)) + 1);
387 ScanLine
= (PIXEL
*)ExAllocatePool(PagedPool
, (DestRect
->right
- DestRect
->left
) * sizeof(PIXEL
));
388 ScanLineAhead
= (PIXEL
*)ExAllocatePool(PagedPool
, (DestRect
->right
- DestRect
->left
) * sizeof(PIXEL
));
390 DestY
= DestRect
->top
;
392 while (NumPixels
-- > 0) {
393 if (Source
!= PrevSource
) {
394 if (Source
== PrevSourceAhead
) {
395 /* the next scan line has already been scaled and stored in
396 * ScanLineAhead; swap the buffers that ScanLine and ScanLineAhead
399 PIXEL
*tmp
= ScanLine
;
400 ScanLine
= ScanLineAhead
;
403 ScaleLineAvg8(ScanLine
, Source
, SourceRect
->right
- SourceRect
->left
, DestRect
->right
- DestRect
->left
);
408 if (E
>= Mid
&& PrevSourceAhead
!= (PIXEL
*)((BYTE
*)Source
+ SourceSurf
->lDelta
)) {
410 ScaleLineAvg8(ScanLineAhead
, (PIXEL
*)((BYTE
*)Source
+ SourceSurf
->lDelta
), SourceRect
->right
- SourceRect
->left
, DestRect
->right
- DestRect
->left
);
411 for (x
= 0; x
< DestRect
->right
- DestRect
->left
; x
++)
412 ScanLine
[x
] = average8(ScanLine
[x
], ScanLineAhead
[x
]);
413 PrevSourceAhead
= (PIXEL
*)((BYTE
*)Source
+ SourceSurf
->lDelta
);
416 if (! FinalCopy8(Target
, ScanLine
, ClipSpans
, ClipSpansCount
, &SpanIndex
, DestY
, DestRect
))
418 /* No more spans, everything else is clipped away, we're done */
419 ExFreePool(ClipSpans
);
420 ExFreePool(ScanLine
);
421 ExFreePool(ScanLineAhead
);
425 Target
= (PIXEL
*)((BYTE
*)Target
+ DestSurf
->lDelta
);
428 if (E
>= DestRect
->bottom
- DestRect
->top
) {
429 E
-= DestRect
->bottom
- DestRect
->top
;
430 Source
= (PIXEL
*)((BYTE
*)Source
+ SourceSurf
->lDelta
);
434 if (skip
> 0 && Source
!= PrevSource
)
435 ScaleLineAvg8(ScanLine
, Source
, SourceRect
->right
- SourceRect
->left
, DestRect
->right
- DestRect
->left
);
437 if (! FinalCopy8(Target
, ScanLine
, ClipSpans
, ClipSpansCount
, &SpanIndex
, DestY
, DestRect
))
439 /* No more spans, everything else is clipped away, we're done */
440 ExFreePool(ClipSpans
);
441 ExFreePool(ScanLine
);
442 ExFreePool(ScanLineAhead
);
446 Target
= (PIXEL
*)((BYTE
*)Target
+ DestSurf
->lDelta
);
449 ExFreePool(ClipSpans
);
450 ExFreePool(ScanLine
);
451 ExFreePool(ScanLineAhead
);
456 //NOTE: If you change something here, please do the same in other dibXXbpp.c files!
457 BOOLEAN
DIB_8BPP_StretchBlt(SURFOBJ
*DestSurf
, SURFOBJ
*SourceSurf
,
458 RECTL
* DestRect
, RECTL
*SourceRect
,
459 POINTL
* MaskOrigin
, POINTL BrushOrigin
,
460 CLIPOBJ
*ClipRegion
, XLATEOBJ
*ColorTranslation
,
477 BOOLEAN DesIsBiggerY
=FALSE
;
479 DPRINT("DIB_8BPP_StretchBlt: Source BPP: %u, srcRect: (%d,%d)-(%d,%d), dstRect: (%d,%d)-(%d,%d)\n",
480 BitsPerFormat(SourceSurf
->iBitmapFormat
), SourceRect
->left
, SourceRect
->top
, SourceRect
->right
, SourceRect
->bottom
,
481 DestRect
->left
, DestRect
->top
, DestRect
->right
, DestRect
->bottom
);
483 SrcSizeY
= SourceRect
->bottom
- SourceRect
->top
;
484 SrcSizeX
= SourceRect
->right
- SourceRect
->left
;
486 DesSizeY
= DestRect
->bottom
- DestRect
->top
;
487 DesSizeX
= DestRect
->right
- DestRect
->left
;
489 zoomX
= DesSizeX
/ SrcSizeX
;
490 if (zoomX
==0) zoomX
=1;
492 zoomY
= DesSizeY
/ SrcSizeY
;
493 if (zoomY
==0) zoomY
=1;
495 if (DesSizeY
>SrcSizeY
)
498 switch(SourceSurf
->iBitmapFormat
)
501 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
502 /* This is a reference implementation, it hasn't been optimized for speed */
505 /* Draw one Hline on X - Led to the Des Zoom In*/
506 if (DesSizeX
>SrcSizeX
)
508 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
511 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
513 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
515 if (sy
> SourceRect
->bottom
) break;
519 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
521 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
523 if (sx
> SourceRect
->right
) break;
525 saveX
= DesX
+ zoomX
;
527 if (DIB_1BPP_GetPixel(SourceSurf
, sx
, sy
) == 0)
528 for (count
=DesY
;count
<saveY
;count
++)
529 DIB_8BPP_HLine(DestSurf
, DesX
, saveX
, count
, 0);
531 for (count
=DesY
;count
<saveY
;count
++)
532 DIB_8BPP_HLine(DestSurf
, DesX
, saveX
, count
, 1);
539 /* Draw one Hline on X - Led to the Des Zoom Out*/
541 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
544 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
546 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
548 if (sy
> SourceRect
->bottom
) break;
552 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
554 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
556 if (sx
> SourceRect
->right
) break;
558 saveX
= DesX
+ zoomX
;
560 if (DIB_1BPP_GetPixel(SourceSurf
, sx
, sy
) == 0)
561 for (count
=DesY
;count
<saveY
;count
++)
562 DIB_8BPP_HLine(DestSurf
, DesX
, saveX
, count
, 0);
564 for (count
=DesY
;count
<saveY
;count
++)
565 DIB_8BPP_HLine(DestSurf
, DesX
, saveX
, count
, 1);
574 if (DesSizeX
>SrcSizeX
)
576 /* Draw one pixel on X - Led to the Des Zoom In*/
577 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
580 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
582 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
584 if (sy
> SourceRect
->bottom
) break;
588 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
590 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
592 if (sx
> SourceRect
->right
) break;
594 if (DIB_1BPP_GetPixel(SourceSurf
, sx
, sy
) == 0)
595 for (count
=DesY
;count
<saveY
;count
++)
596 DIB_8BPP_PutPixel(DestSurf
, DesX
, count
, 0);
598 for (count
=DesY
;count
<saveY
;count
++)
599 DIB_8BPP_PutPixel(DestSurf
, DesX
, count
, 1);
607 /* Draw one pixel on X - Led to the Des Zoom Out*/
608 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
611 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
613 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
615 if (sy
> SourceRect
->bottom
) break;
619 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
621 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
623 if (sx
> SourceRect
->right
) break;
625 if (DIB_1BPP_GetPixel(SourceSurf
, sx
, sy
) == 0)
626 for (count
=DesY
;count
<saveY
;count
++)
627 DIB_8BPP_PutPixel(DestSurf
, DesX
, count
, 0);
629 for (count
=DesY
;count
<saveY
;count
++)
630 DIB_8BPP_PutPixel(DestSurf
, DesX
, count
, 1);
639 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
640 /* This is a reference implementation, it hasn't been optimized for speed */
643 /* Draw one Hline on X - Led to the Des Zoom In*/
644 if (DesSizeX
>SrcSizeX
)
646 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
649 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
651 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
653 if (sy
> SourceRect
->bottom
) break;
657 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
659 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
661 if (sx
> SourceRect
->right
) break;
663 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_4BPP_GetPixel(SourceSurf
, sx
, sy
));
665 saveX
= DesX
+ zoomX
;
666 for (count
=DesY
;count
<saveY
;count
++)
667 DIB_8BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
673 /* Draw one Hline on X - Led to the Des Zoom Out*/
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
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
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_8BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
705 if (DesSizeX
>SrcSizeX
)
707 /* Draw one pixel on X - Led to the Des Zoom In*/
708 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
711 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
713 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
715 if (sy
> SourceRect
->bottom
) break;
719 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
721 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
723 if (sx
> SourceRect
->right
) break;
725 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_4BPP_GetPixel(SourceSurf
, sx
, sy
));
727 for (count
=DesY
;count
<saveY
;count
++)
728 DIB_8BPP_PutPixel(DestSurf
, DesX
, count
, color
);
734 /* Draw one pixel 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 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_4BPP_GetPixel(SourceSurf
, sx
, sy
));
754 for (count
=DesY
;count
<saveY
;count
++)
755 DIB_8BPP_PutPixel(DestSurf
, DesX
, count
, color
);
763 return ScaleRectAvg8(DestSurf
, SourceSurf
, DestRect
, SourceRect
, MaskOrigin
, BrushOrigin
,
764 ClipRegion
, ColorTranslation
, Mode
);
768 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
769 /* This is a reference implementation, it hasn't been optimized for speed */
772 /* Draw one Hline on X - Led to the Des Zoom In*/
773 if (DesSizeX
>SrcSizeX
)
775 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
778 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
780 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
782 if (sy
> SourceRect
->bottom
) break;
786 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
788 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
790 if (sx
> SourceRect
->right
) break;
792 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_16BPP_GetPixel(SourceSurf
, sx
, sy
));
794 saveX
= DesX
+ zoomX
;
795 for (count
=DesY
;count
<saveY
;count
++)
796 DIB_8BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
802 /* Draw one Hline on X - Led to the Des Zoom Out*/
804 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
807 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
809 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
811 if (sy
> SourceRect
->bottom
) break;
815 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
817 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
819 if (sx
> SourceRect
->right
) break;
821 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_16BPP_GetPixel(SourceSurf
, sx
, sy
));
823 saveX
= DesX
+ zoomX
;
824 for (count
=DesY
;count
<saveY
;count
++)
825 DIB_8BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
834 if (DesSizeX
>SrcSizeX
)
836 /* Draw one pixel on X - Led to the Des Zoom In*/
837 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
840 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
842 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
844 if (sy
> SourceRect
->bottom
) break;
848 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
850 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
852 if (sx
> SourceRect
->right
) break;
854 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_16BPP_GetPixel(SourceSurf
, sx
, sy
));
856 for (count
=DesY
;count
<saveY
;count
++)
857 DIB_8BPP_PutPixel(DestSurf
, DesX
, count
, color
);
863 /* Draw one pixel on X - Led to the Des Zoom Out*/
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
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
879 if (sx
> SourceRect
->right
) break;
881 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_16BPP_GetPixel(SourceSurf
, sx
, sy
));
883 for (count
=DesY
;count
<saveY
;count
++)
884 DIB_8BPP_PutPixel(DestSurf
, DesX
, count
, color
);
892 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
893 /* This is a reference implementation, it hasn't been optimized for speed */
896 /* Draw one Hline on X - Led to the Des Zoom In*/
897 if (DesSizeX
>SrcSizeX
)
899 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
902 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
904 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
906 if (sy
> SourceRect
->bottom
) break;
910 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
912 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
914 if (sx
> SourceRect
->right
) break;
916 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_24BPP_GetPixel(SourceSurf
, sx
, sy
));
918 saveX
= DesX
+ zoomX
;
919 for (count
=DesY
;count
<saveY
;count
++)
920 DIB_8BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
926 /* Draw one Hline on X - Led to the Des Zoom Out*/
928 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
931 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
933 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
935 if (sy
> SourceRect
->bottom
) break;
939 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
941 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
943 if (sx
> SourceRect
->right
) break;
945 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_24BPP_GetPixel(SourceSurf
, sx
, sy
));
947 saveX
= DesX
+ zoomX
;
948 for (count
=DesY
;count
<saveY
;count
++)
949 DIB_8BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
958 if (DesSizeX
>SrcSizeX
)
960 /* Draw one pixel on X - Led to the Des Zoom In*/
961 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
964 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
966 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
968 if (sy
> SourceRect
->bottom
) break;
972 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
974 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
976 if (sx
> SourceRect
->right
) break;
978 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_24BPP_GetPixel(SourceSurf
, sx
, sy
));
980 for (count
=DesY
;count
<saveY
;count
++)
981 DIB_8BPP_PutPixel(DestSurf
, DesX
, count
, color
);
987 /* Draw one pixel on X - Led to the Des Zoom Out*/
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
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1003 if (sx
> SourceRect
->right
) break;
1005 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_24BPP_GetPixel(SourceSurf
, sx
, sy
));
1007 for (count
=DesY
;count
<saveY
;count
++)
1008 DIB_8BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1016 /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
1017 /* This is a reference implementation, it hasn't been optimized for speed */
1020 /* Draw one Hline on X - Led to the Des Zoom In*/
1021 if (DesSizeX
>SrcSizeX
)
1023 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1026 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1028 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1030 if (sy
> SourceRect
->bottom
) break;
1034 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1036 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1038 if (sx
> SourceRect
->right
) break;
1040 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_32BPP_GetPixel(SourceSurf
, sx
, sy
));
1042 saveX
= DesX
+ zoomX
;
1043 for (count
=DesY
;count
<saveY
;count
++)
1044 DIB_8BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1050 /* Draw one Hline on X - Led to the Des Zoom Out*/
1052 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1055 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1057 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1059 if (sy
> SourceRect
->bottom
) break;
1063 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1065 sx
= (int) ((ULONG
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1067 if (sx
> SourceRect
->right
) break;
1069 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_32BPP_GetPixel(SourceSurf
, sx
, sy
));
1071 saveX
= DesX
+ zoomX
;
1072 for (count
=DesY
;count
<saveY
;count
++)
1073 DIB_8BPP_HLine(DestSurf
, DesX
, saveX
, count
, color
);
1082 if (DesSizeX
>SrcSizeX
)
1084 /* Draw one pixel on X - Led to the Des Zoom In*/
1085 for (DesY
=DestRect
->bottom
-zoomY
; DesY
>=0; DesY
-=zoomY
)
1088 sy
= (int) ((ULONG
) SrcSizeY
* (ULONG
) DesY
) / ((ULONG
) DesSizeY
);
1090 sy
= (int) ((ULONG
) DesSizeY
* (ULONG
) DesY
) / ((ULONG
) SrcSizeY
);
1092 if (sy
> SourceRect
->bottom
) break;
1096 for (DesX
=DestRect
->right
-zoomX
; DesX
>=0; DesX
-=zoomX
)
1098 sx
= (int) ((ULONG
) SrcSizeX
* (ULONG
) DesX
) / ((ULONG
) DesSizeX
);
1100 if (sx
> SourceRect
->right
) break;
1102 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_32BPP_GetPixel(SourceSurf
, sx
, sy
));
1104 for (count
=DesY
;count
<saveY
;count
++)
1105 DIB_8BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1111 /* Draw one pixel on X - Led to the Des Zoom Out*/
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
) DesSizeX
* (ULONG
) DesX
) / ((ULONG
) SrcSizeX
);
1127 if (sx
> SourceRect
->right
) break;
1129 color
= XLATEOBJ_iXlate(ColorTranslation
, DIB_32BPP_GetPixel(SourceSurf
, sx
, sy
));
1131 for (count
=DesY
;count
<saveY
;count
++)
1132 DIB_8BPP_PutPixel(DestSurf
, DesX
, count
, color
);
1141 DPRINT1("DIB_8BPP_StretchBlt: Unhandled Source BPP: %u\n", BitsPerFormat(SourceSurf
->iBitmapFormat
));
1149 DIB_8BPP_TransparentBlt(SURFOBJ
*DestSurf
, SURFOBJ
*SourceSurf
,
1150 RECTL
* DestRect
, POINTL
*SourcePoint
,
1151 XLATEOBJ
*ColorTranslation
, ULONG iTransColor
)
1153 ULONG RoundedRight
, X
, Y
, SourceX
, SourceY
, Source
, wd
, Dest
;
1156 RoundedRight
= DestRect
->right
- ((DestRect
->right
- DestRect
->left
) & 0x3);
1157 SourceY
= SourcePoint
->y
;
1158 DestBits
= (ULONG
*)((PBYTE
)DestSurf
->pvScan0
+ DestRect
->left
+
1159 (DestRect
->top
* DestSurf
->lDelta
));
1160 wd
= DestSurf
->lDelta
- (DestRect
->right
- DestRect
->left
);
1162 for(Y
= DestRect
->top
; Y
< DestRect
->bottom
; Y
++)
1164 DestBits
= (ULONG
*)((PBYTE
)DestSurf
->pvScan0
+ DestRect
->left
+
1165 (Y
* DestSurf
->lDelta
));
1166 SourceX
= SourcePoint
->x
;
1167 for (X
= DestRect
->left
; X
< RoundedRight
; X
+= 4, DestBits
++)
1171 Source
= DIB_GetSourceIndex(SourceSurf
, SourceX
++, SourceY
);
1172 if(Source
!= iTransColor
)
1175 Dest
|= (XLATEOBJ_iXlate(ColorTranslation
, Source
) & 0xFF);
1178 Source
= DIB_GetSourceIndex(SourceSurf
, SourceX
++, SourceY
);
1179 if(Source
!= iTransColor
)
1182 Dest
|= ((XLATEOBJ_iXlate(ColorTranslation
, Source
) << 8) & 0xFF00);
1185 Source
= DIB_GetSourceIndex(SourceSurf
, SourceX
++, SourceY
);
1186 if(Source
!= iTransColor
)
1189 Dest
|= ((XLATEOBJ_iXlate(ColorTranslation
, Source
) << 16) & 0xFF0000);
1192 Source
= DIB_GetSourceIndex(SourceSurf
, SourceX
++, SourceY
);
1193 if(Source
!= iTransColor
)
1196 Dest
|= ((XLATEOBJ_iXlate(ColorTranslation
, Source
) << 24) & 0xFF000000);
1202 if(X
< DestRect
->right
)
1204 for (; X
< DestRect
->right
; X
++)
1206 Source
= DIB_GetSourceIndex(SourceSurf
, SourceX
++, SourceY
);
1207 if(Source
!= iTransColor
)
1209 *((BYTE
*)DestBits
) = (BYTE
)(XLATEOBJ_iXlate(ColorTranslation
, Source
) & 0xFF);
1211 DestBits
= (PULONG
)((ULONG_PTR
)DestBits
+ 1);