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.
19 /* $Id: dib8bpp.c,v 1.2 2003/05/18 17:16:17 ea Exp $ */
20 #undef WIN32_LEAN_AND_MEAN
23 #include <win32k/bitmaps.h>
24 #include <win32k/debug.h>
26 #include <ddk/winddi.h>
27 #include "../eng/objects.h"
31 DIB_8BPP_PutPixel(PSURFOBJ SurfObj
, LONG x
, LONG y
, ULONG c
)
33 PBYTE byteaddr
= SurfObj
->pvScan0
+ y
* SurfObj
->lDelta
+ x
;
39 DIB_8BPP_GetPixel(PSURFOBJ SurfObj
, LONG x
, LONG y
)
41 PBYTE byteaddr
= SurfObj
->pvScan0
+ y
* SurfObj
->lDelta
+ x
;
43 return (ULONG
)(*byteaddr
);
47 DIB_8BPP_HLine(PSURFOBJ SurfObj
, LONG x1
, LONG x2
, LONG y
, ULONG c
)
49 PBYTE byteaddr
= SurfObj
->pvScan0
+ y
* SurfObj
->lDelta
;
50 PBYTE addr
= byteaddr
+ x1
;
61 DIB_8BPP_VLine(PSURFOBJ SurfObj
, LONG x
, LONG y1
, LONG y2
, ULONG c
)
63 PBYTE byteaddr
= SurfObj
->pvScan0
+ y1
* SurfObj
->lDelta
;
64 PBYTE addr
= byteaddr
+ x
;
65 LONG lDelta
= SurfObj
->lDelta
;
76 DIB_8BPP_BitBlt(SURFOBJ
*DestSurf
, SURFOBJ
*SourceSurf
,
77 SURFGDI
*DestGDI
, SURFGDI
*SourceGDI
,
78 PRECTL DestRect
, POINTL
*SourcePoint
,
79 XLATEOBJ
*ColorTranslation
)
81 ULONG i
, j
, sx
, sy
, xColor
, f1
;
82 PBYTE SourceBits
, DestBits
, SourceLine
, DestLine
;
83 PBYTE SourceBits_4BPP
, SourceLine_4BPP
;
85 DestBits
= DestSurf
->pvScan0
+ (DestRect
->top
* DestSurf
->lDelta
) + DestRect
->left
;
87 switch(SourceGDI
->BitsPerPixel
)
93 for (j
=DestRect
->top
; j
<DestRect
->bottom
; j
++)
96 for (i
=DestRect
->left
; i
<DestRect
->right
; i
++)
98 if(DIB_1BPP_GetPixel(SourceSurf
, sx
, sy
) == 0)
100 DIB_8BPP_PutPixel(DestSurf
, i
, j
, XLATEOBJ_iXlate(ColorTranslation
, 0));
102 DIB_8BPP_PutPixel(DestSurf
, i
, j
, XLATEOBJ_iXlate(ColorTranslation
, 1));
111 SourceBits_4BPP
= SourceSurf
->pvScan0
+ (SourcePoint
->y
* SourceSurf
->lDelta
) + (SourcePoint
->x
>> 1);
113 for (j
=DestRect
->top
; j
<DestRect
->bottom
; j
++)
115 SourceLine_4BPP
= SourceBits_4BPP
;
119 for (i
=DestRect
->left
; i
<DestRect
->right
; i
++)
121 xColor
= XLATEOBJ_iXlate(ColorTranslation
,
122 (*SourceLine_4BPP
& altnotmask
[sx
&1]) >> (4 * (1-(sx
& 1))));
123 DIB_8BPP_PutPixel(DestSurf
, i
, j
, xColor
);
124 if(f1
== 1) { SourceLine_4BPP
++; f1
= 0; } else { f1
= 1; }
128 SourceBits_4BPP
+= SourceSurf
->lDelta
;
133 if (NULL
== ColorTranslation
|| 0 != (ColorTranslation
->flXlate
& XO_TRIVIAL
))
135 SourceBits
= SourceSurf
->pvScan0
+ (SourcePoint
->y
* SourceSurf
->lDelta
) + SourcePoint
->x
;
136 for (j
= DestRect
->top
; j
< DestRect
->bottom
; j
++)
138 RtlCopyMemory(DestBits
, SourceBits
, DestRect
->right
- DestRect
->left
);
139 SourceBits
+= SourceSurf
->lDelta
;
140 DestBits
+= DestSurf
->lDelta
;
146 DPRINT1("DIB_8BPP_Bitblt: Unhandled ColorTranslation for 32 -> 32 copy");
152 SourceLine
= SourceSurf
->pvScan0
+ (SourcePoint
->y
* SourceSurf
->lDelta
) + 2 * SourcePoint
->x
;
155 for (j
= DestRect
->top
; j
< DestRect
->bottom
; j
++)
157 SourceBits
= SourceLine
;
160 for (i
= DestRect
->left
; i
< DestRect
->right
; i
++)
162 xColor
= *((PWORD
) SourceBits
);
163 *DestBits
= XLATEOBJ_iXlate(ColorTranslation
, xColor
);
168 SourceLine
+= SourceSurf
->lDelta
;
169 DestLine
+= DestSurf
->lDelta
;
174 SourceLine
= SourceSurf
->pvScan0
+ (SourcePoint
->y
* SourceSurf
->lDelta
) + 3 * SourcePoint
->x
;
177 for (j
= DestRect
->top
; j
< DestRect
->bottom
; j
++)
179 SourceBits
= SourceLine
;
182 for (i
= DestRect
->left
; i
< DestRect
->right
; i
++)
184 xColor
= (*(SourceBits
+ 2) << 0x10) +
185 (*(SourceBits
+ 1) << 0x08) +
187 *DestBits
= XLATEOBJ_iXlate(ColorTranslation
, xColor
);
192 SourceLine
+= SourceSurf
->lDelta
;
193 DestLine
+= DestSurf
->lDelta
;
198 SourceLine
= SourceSurf
->pvScan0
+ (SourcePoint
->y
* SourceSurf
->lDelta
) + 4 * SourcePoint
->x
;
201 for (j
= DestRect
->top
; j
< DestRect
->bottom
; j
++)
203 SourceBits
= SourceLine
;
206 for (i
= DestRect
->left
; i
< DestRect
->right
; i
++)
208 xColor
= *((PDWORD
) SourceBits
);
209 *DestBits
= XLATEOBJ_iXlate(ColorTranslation
, xColor
);
214 SourceLine
+= SourceSurf
->lDelta
;
215 DestLine
+= DestSurf
->lDelta
;
220 DbgPrint("DIB_8BPP_Bitblt: Unhandled Source BPP: %u\n", SourceGDI
->BitsPerPixel
);