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_24BPP_PutPixel(SURFOBJ
*SurfObj
, LONG x
, LONG y
, ULONG c
)
25 PBYTE addr
= SurfObj
->pvScan0
+ (y
* SurfObj
->lDelta
) + (x
<< 1) + x
;
26 *(PUSHORT
)(addr
) = c
& 0xFFFF;
27 *(addr
+ 2) = (c
>> 16) & 0xFF;
31 DIB_24BPP_GetPixel(SURFOBJ
*SurfObj
, LONG x
, LONG y
)
33 PBYTE addr
= SurfObj
->pvScan0
+ y
* SurfObj
->lDelta
+ (x
<< 1) + x
;
34 return *(PUSHORT
)(addr
) + (*(addr
+ 2) << 16);
38 DIB_24BPP_HLine(SURFOBJ
*SurfObj
, LONG x1
, LONG x2
, LONG y
, ULONG c
)
40 PBYTE addr
= SurfObj
->pvScan0
+ y
* SurfObj
->lDelta
+ (x1
<< 1) + x1
;
45 *(PUSHORT
)(addr
) = c
& 0xFFFF;
54 DIB_24BPP_VLine(SURFOBJ
*SurfObj
, LONG x
, LONG y1
, LONG y2
, ULONG c
)
56 PBYTE addr
= SurfObj
->pvScan0
+ y1
* SurfObj
->lDelta
+ (x
<< 1) + x
;
57 LONG lDelta
= SurfObj
->lDelta
;
61 *(PUSHORT
)(addr
) = c
& 0xFFFF;
62 *(addr
+ 2) = c
>> 16;
69 DIB_24BPP_BitBltSrcCopy(PBLTINFO BltInfo
)
71 LONG i
, j
, sx
, sy
, xColor
, f1
;
72 PBYTE SourceBits
, DestBits
, SourceLine
, DestLine
;
73 PBYTE SourceBits_4BPP
, SourceLine_4BPP
;
74 PWORD SourceBits_16BPP
, SourceLine_16BPP
;
76 DestBits
= BltInfo
->DestSurface
->pvScan0
+ (BltInfo
->DestRect
.top
* BltInfo
->DestSurface
->lDelta
) + BltInfo
->DestRect
.left
* 3;
78 switch(BltInfo
->SourceSurface
->iBitmapFormat
)
81 sx
= BltInfo
->SourcePoint
.x
;
82 sy
= BltInfo
->SourcePoint
.y
;
84 for (j
=BltInfo
->DestRect
.top
; j
<BltInfo
->DestRect
.bottom
; j
++)
86 sx
= BltInfo
->SourcePoint
.x
;
87 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
89 if(DIB_1BPP_GetPixel(BltInfo
->SourceSurface
, sx
, sy
) == 0)
91 DIB_24BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, 0));
93 DIB_24BPP_PutPixel(BltInfo
->DestSurface
, i
, j
, XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, 1));
102 SourceBits_4BPP
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + (BltInfo
->SourcePoint
.x
>> 1);
104 for (j
=BltInfo
->DestRect
.top
; j
<BltInfo
->DestRect
.bottom
; j
++)
106 SourceLine_4BPP
= SourceBits_4BPP
;
108 sx
= BltInfo
->SourcePoint
.x
;
111 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
113 xColor
= XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
,
114 (*SourceLine_4BPP
& altnotmask
[f1
]) >> (4 * (1 - f1
)));
115 *DestLine
++ = xColor
& 0xff;
116 *(PWORD
)DestLine
= xColor
>> 8;
118 if(f1
== 1) { SourceLine_4BPP
++; f1
= 0; } else { f1
= 1; }
122 SourceBits_4BPP
+= BltInfo
->SourceSurface
->lDelta
;
123 DestBits
+= BltInfo
->DestSurface
->lDelta
;
128 SourceLine
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + BltInfo
->SourcePoint
.x
;
131 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
133 SourceBits
= SourceLine
;
136 for (i
= BltInfo
->DestRect
.left
; i
< BltInfo
->DestRect
.right
; i
++)
138 xColor
= XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, *SourceBits
);
139 *DestBits
= xColor
& 0xff;
140 *(PWORD
)(DestBits
+ 1) = xColor
>> 8;
145 SourceLine
+= BltInfo
->SourceSurface
->lDelta
;
146 DestLine
+= BltInfo
->DestSurface
->lDelta
;
151 SourceBits_16BPP
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + 2 * BltInfo
->SourcePoint
.x
;
153 for (j
=BltInfo
->DestRect
.top
; j
<BltInfo
->DestRect
.bottom
; j
++)
155 SourceLine_16BPP
= SourceBits_16BPP
;
158 for (i
=BltInfo
->DestRect
.left
; i
<BltInfo
->DestRect
.right
; i
++)
160 xColor
= XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, *SourceLine_16BPP
);
161 *DestLine
++ = xColor
& 0xff;
162 *(PWORD
)DestLine
= xColor
>> 8;
167 SourceBits_16BPP
= (PWORD
)((PBYTE
)SourceBits_16BPP
+ BltInfo
->SourceSurface
->lDelta
);
168 DestBits
+= BltInfo
->DestSurface
->lDelta
;
173 if (NULL
== BltInfo
->XlateSourceToDest
|| 0 != (BltInfo
->XlateSourceToDest
->flXlate
& XO_TRIVIAL
))
175 if (BltInfo
->DestRect
.top
< BltInfo
->SourcePoint
.y
)
177 SourceBits
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + 3 * BltInfo
->SourcePoint
.x
;
178 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
180 RtlMoveMemory(DestBits
, SourceBits
, 3 * (BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
));
181 SourceBits
+= BltInfo
->SourceSurface
->lDelta
;
182 DestBits
+= BltInfo
->DestSurface
->lDelta
;
187 SourceBits
= BltInfo
->SourceSurface
->pvScan0
+ ((BltInfo
->SourcePoint
.y
+ BltInfo
->DestRect
.bottom
- BltInfo
->DestRect
.top
- 1) * BltInfo
->SourceSurface
->lDelta
) + 3 * BltInfo
->SourcePoint
.x
;
188 DestBits
= BltInfo
->DestSurface
->pvScan0
+ ((BltInfo
->DestRect
.bottom
- 1) * BltInfo
->DestSurface
->lDelta
) + 3 * BltInfo
->DestRect
.left
;
189 for (j
= BltInfo
->DestRect
.bottom
- 1; BltInfo
->DestRect
.top
<= j
; j
--)
191 RtlMoveMemory(DestBits
, SourceBits
, 3 * (BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
));
192 SourceBits
-= BltInfo
->SourceSurface
->lDelta
;
193 DestBits
-= BltInfo
->DestSurface
->lDelta
;
200 DPRINT1("DIB_24BPP_Bitblt: Unhandled BltInfo->XlateSourceToDest for 16 -> 16 copy\n");
206 SourceLine
= BltInfo
->SourceSurface
->pvScan0
+ (BltInfo
->SourcePoint
.y
* BltInfo
->SourceSurface
->lDelta
) + 4 * BltInfo
->SourcePoint
.x
;
209 for (j
= BltInfo
->DestRect
.top
; j
< BltInfo
->DestRect
.bottom
; j
++)
211 SourceBits
= SourceLine
;
214 for (i
= BltInfo
->DestRect
.left
; i
< BltInfo
->DestRect
.right
; i
++)
216 xColor
= XLATEOBJ_iXlate(BltInfo
->XlateSourceToDest
, *((PDWORD
) SourceBits
));
217 *DestBits
= xColor
& 0xff;
218 *(PWORD
)(DestBits
+ 1) = xColor
>> 8;
223 SourceLine
+= BltInfo
->SourceSurface
->lDelta
;
224 DestLine
+= BltInfo
->DestSurface
->lDelta
;
229 DbgPrint("DIB_24BPP_Bitblt: Unhandled Source BPP: %u\n", BitsPerFormat(BltInfo
->SourceSurface
->iBitmapFormat
));
237 DIB_24BPP_BitBlt(PBLTINFO BltInfo
)
240 ULONG SourceX
, SourceY
;
242 ULONG Dest
, Source
= 0, Pattern
= 0;
247 UsesSource
= ROP_USES_SOURCE(BltInfo
->Rop4
);
248 UsesPattern
= ROP_USES_PATTERN(BltInfo
->Rop4
);
250 SourceY
= BltInfo
->SourcePoint
.y
;
252 BltInfo
->DestSurface
->pvScan0
+
253 (BltInfo
->DestRect
.left
<< 1) + BltInfo
->DestRect
.left
+
254 BltInfo
->DestRect
.top
* BltInfo
->DestSurface
->lDelta
);
258 if (BltInfo
->PatternSurface
)
260 PatternY
= (BltInfo
->DestRect
.top
+ BltInfo
->BrushOrigin
.y
) %
261 BltInfo
->PatternSurface
->sizlBitmap
.cy
;
265 Pattern
= BltInfo
->Brush
->iSolidColor
;
269 for (DestY
= BltInfo
->DestRect
.top
; DestY
< BltInfo
->DestRect
.bottom
; DestY
++)
271 SourceX
= BltInfo
->SourcePoint
.x
;
273 for (DestX
= BltInfo
->DestRect
.left
; DestX
< BltInfo
->DestRect
.right
; DestX
++, DestBits
+= 3, SourceX
++)
275 Dest
= *((PUSHORT
)DestBits
) + (*(DestBits
+ 2) << 16);
279 Source
= DIB_GetSource(BltInfo
->SourceSurface
, SourceX
, SourceY
, BltInfo
->XlateSourceToDest
);
282 if (BltInfo
->PatternSurface
)
284 Pattern
= DIB_GetSource(BltInfo
->PatternSurface
, (DestX
+ BltInfo
->BrushOrigin
.x
) % BltInfo
->PatternSurface
->sizlBitmap
.cx
, PatternY
, BltInfo
->XlatePatternToDest
);
287 Dest
= DIB_DoRop(BltInfo
->Rop4
, Dest
, Source
, Pattern
) & 0xFFFFFF;
288 *(PUSHORT
)(DestBits
) = Dest
& 0xFFFF;
289 *(DestBits
+ 2) = Dest
>> 16;
293 if (BltInfo
->PatternSurface
)
296 PatternY
%= BltInfo
->PatternSurface
->sizlBitmap
.cy
;
298 DestBits
-= (BltInfo
->DestRect
.right
- BltInfo
->DestRect
.left
) * 3;
299 DestBits
+= BltInfo
->DestSurface
->lDelta
;
305 BOOLEAN
DIB_24BPP_StretchBlt(SURFOBJ
*DestSurf
, SURFOBJ
*SourceSurf
,
306 RECTL
* DestRect
, RECTL
*SourceRect
,
307 POINTL
* MaskOrigin
, POINTL BrushOrigin
,
308 CLIPOBJ
*ClipRegion
, XLATEOBJ
*ColorTranslation
,
311 DbgPrint("DIB_24BPP_StretchBlt: Source BPP: %u\n", BitsPerFormat(SourceSurf
->iBitmapFormat
));
316 DIB_24BPP_TransparentBlt(SURFOBJ
*DestSurf
, SURFOBJ
*SourceSurf
,
317 RECTL
* DestRect
, POINTL
*SourcePoint
,
318 XLATEOBJ
*ColorTranslation
, ULONG iTransColor
)
320 ULONG X
, Y
, SourceX
, SourceY
, Source
, wd
, Dest
;
323 SourceY
= SourcePoint
->y
;
324 DestBits
= (BYTE
*)(DestSurf
->pvScan0
+
325 (DestRect
->left
<< 2) +
326 DestRect
->top
* DestSurf
->lDelta
);
327 wd
= DestSurf
->lDelta
- ((DestRect
->right
- DestRect
->left
) << 2);
329 for(Y
= DestRect
->top
; Y
< DestRect
->bottom
; Y
++)
331 SourceX
= SourcePoint
->x
;
332 for(X
= DestRect
->left
; X
< DestRect
->right
; X
++, DestBits
+= 3, SourceX
++)
334 Source
= DIB_GetSourceIndex(SourceSurf
, SourceX
, SourceY
);
335 if(Source
!= iTransColor
)
337 Dest
= XLATEOBJ_iXlate(ColorTranslation
, Source
) & 0xFFFFFF;
338 *(PUSHORT
)(DestBits
) = Dest
& 0xFFFF;
339 *(DestBits
+ 2) = Dest
>> 16;
344 DestBits
= (BYTE
*)((ULONG_PTR
)DestBits
+ wd
);