1 #undef WIN32_LEAN_AND_MEAN
4 #include <win32k/bitmaps.h>
5 #include <win32k/debug.h>
7 #include <ddk/winddi.h>
8 #include "../eng/objects.h"
11 unsigned char notmask
[2] = { 0x0f, 0xf0 };
12 unsigned char altnotmask
[2] = { 0xf0, 0x0f };
14 PFN_DIB_PutPixel
DIB_4BPP_PutPixel(SURFOBJ
* SurfObj
, LONG x
, LONG y
, ULONG c
)
18 PBYTE addr
= SurfObj
->pvBits
;
20 addr
+= (x
>>1) + y
* SurfObj
->lDelta
;
21 *addr
= (*addr
& notmask
[x
&1]) | (c
<< ((1-(x
&1))<<2));
24 PFN_DIB_GetPixel
DIB_4BPP_GetPixel(SURFOBJ
* SurfObj
, LONG x
, LONG y
)
26 PBYTE addr
= SurfObj
->pvBits
;
28 return (PFN_DIB_GetPixel
)((addr
[(x
>>1) + y
* SurfObj
->lDelta
] >> ((1-(x
&1))<<2) ) & 0x0f);
31 PFN_DIB_HLine
DIB_4BPP_HLine(SURFOBJ
* SurfObj
, LONG x1
, LONG x2
, LONG y
, ULONG c
)
33 PBYTE addr
= SurfObj
->pvBits
+ (x1
>>1) + y
* SurfObj
->lDelta
;
37 *addr
= (*addr
& notmask
[x1
&1]) | (c
<< ((1-(x1
&1))<<2));
44 PFN_DIB_VLine
DIB_4BPP_VLine(SURFOBJ
* SurfObj
, LONG x
, LONG y1
, LONG y2
, ULONG c
)
46 PBYTE addr
= SurfObj
->pvBits
;
47 int lDelta
= SurfObj
->lDelta
;
49 addr
+= (x
>>1) + y1
* lDelta
;
51 *addr
= (*addr
& notmask
[x
&1]) | (c
<< ((1-(x
&1))<<2));
56 BOOLEAN
DIB_To_4BPP_Bitblt( SURFOBJ
*DestSurf
, SURFOBJ
*SourceSurf
,
57 SURFGDI
*DestGDI
, SURFGDI
*SourceGDI
,
58 PRECTL DestRect
, POINTL
*SourcePoint
,
59 ULONG Delta
, XLATEOBJ
*ColorTranslation
)
61 ULONG i
, j
, sx
, f1
, f2
, xColor
;
62 PBYTE SourceBits_24BPP
, SourceLine_24BPP
;
63 PBYTE DestBits
, DestLine
, SourceBits_4BPP
, SourceBits_8BPP
, SourceLine_4BPP
, SourceLine_8BPP
;
64 PWORD SourceBits_16BPP
, SourceLine_16BPP
;
65 PDWORD SourceBits_32BPP
, SourceLine_32BPP
;
67 DestBits
= DestSurf
->pvBits
+ (DestRect
->left
>>1) + DestRect
->top
* DestSurf
->lDelta
;
69 switch(SourceGDI
->BitsPerPixel
)
72 SourceBits_4BPP
= SourceSurf
->pvBits
+ (SourcePoint
->y
* SourceSurf
->lDelta
) + SourcePoint
->x
;
74 for (j
=DestRect
->top
; j
<DestRect
->bottom
; j
++)
76 SourceLine_4BPP
= SourceBits_4BPP
;
80 f2
= DestRect
->left
& 1;
82 // FIXME: handle odd begin pixel
84 for (i
=DestRect
->left
; i
<DestRect
->right
; i
++)
86 if(f1
== 1) { SourceLine_4BPP
++; f1
= 0; } else { f1
= 1; }
87 if(f2
== 1) { DestLine
++; f2
= 0; } else { f2
= 1; *DestLine
= *SourceLine_4BPP
; }
91 // FIXME: handle odd end pixel
93 SourceBits_4BPP
+= SourceSurf
->lDelta
;
94 DestBits
+= DestSurf
->lDelta
;
99 SourceBits_8BPP
= SourceSurf
->pvBits
+ (SourcePoint
->y
* SourceSurf
->lDelta
) + SourcePoint
->x
;
101 for (j
=DestRect
->top
; j
<DestRect
->bottom
; j
++)
103 SourceLine_8BPP
= SourceBits_8BPP
;
107 f2
= DestRect
->left
& 1;
109 for (i
=DestRect
->left
; i
<DestRect
->right
; i
++)
111 *DestLine
= (*DestLine
& notmask
[i
&1]) |
112 ((XLATEOBJ_iXlate(ColorTranslation
, *SourceLine_8BPP
)) << ((4 * (1-(sx
& 1)))));
113 if(f2
== 1) { DestLine
++; f2
= 0; } else { f2
= 1; }
118 SourceBits_8BPP
+= SourceSurf
->lDelta
;
119 DestBits
+= DestSurf
->lDelta
;
124 SourceBits_24BPP
= SourceSurf
->pvBits
+ (SourcePoint
->y
* SourceSurf
->lDelta
) + SourcePoint
->x
* 3;
126 for (j
=DestRect
->top
; j
<DestRect
->bottom
; j
++)
128 SourceLine_24BPP
= SourceBits_24BPP
;
132 f2
= DestRect
->left
& 1;
134 for (i
=DestRect
->left
; i
<DestRect
->right
; i
++)
136 xColor
= (*(SourceLine_24BPP
+ 2) << 0x10) +
137 (*(SourceLine_24BPP
+ 1) << 0x08) +
138 (*(SourceLine_24BPP
));
139 *DestLine
= (*DestLine
& notmask
[i
&1]) |
140 ((XLATEOBJ_iXlate(ColorTranslation
, xColor
)) << ((4 * (1-(sx
& 1)))));
141 if(f2
== 1) { DestLine
++; f2
= 0; } else { f2
= 1; }
146 SourceBits_24BPP
+= SourceSurf
->lDelta
;
147 DestBits
+= DestSurf
->lDelta
;
152 DbgPrint("DIB_4BPP_Bitblt: Unhandled Source BPP: %u\n", SourceGDI
->BitsPerPixel
);