Skip to content

Commit 9932008

Browse files
committed
[GDITOOLS] Add inverted and red-blue mono DIB sections
1 parent 69cb5bc commit 9932008

File tree

2 files changed

+36
-17
lines changed

2 files changed

+36
-17
lines changed

modules/rostests/apitests/gditools/gditools.c

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818

1919
#include "gditools.h"
2020

21-
HBITMAP ghbmp1, ghbmp4, ghbmp8, ghbmp16, ghbmp24, ghbmp32;
22-
HBITMAP ghbmpDIB1, ghbmpDIB4, ghbmpDIB8, ghbmpDIB16, ghbmpDIB24, ghbmpDIB32;
23-
HDC ghdcDIB1, ghdcDIB4, ghdcDIB8, ghdcDIB16, ghdcDIB24, ghdcDIB32;
24-
PVOID gpvDIB1, gpvDIB4, gpvDIB8, gpvDIB16, gpvDIB24, gpvDIB32;
21+
HBITMAP ghbmp1, ghbmp1_InvCol, ghbmp1_RB, ghbmp4, ghbmp8, ghbmp16, ghbmp24, ghbmp32;
22+
HBITMAP ghbmpDIB1, ghbmpDIB1_InvCol, ghbmpDIB1_RB, ghbmpDIB4, ghbmpDIB8, ghbmpDIB16, ghbmpDIB24, ghbmpDIB32;
23+
HDC ghdcDIB1, ghdcDIB1_InvCol, ghdcDIB1_RB, ghdcDIB4, ghdcDIB8, ghdcDIB16, ghdcDIB24, ghdcDIB32;
24+
PVOID gpvDIB1, gpvDIB1_InvCol, gpvDIB1_RB, gpvDIB4, gpvDIB8, gpvDIB16, gpvDIB24, gpvDIB32;
2525
ULONG (*gpDIB32)[8][8];
2626
HPALETTE ghpal;
2727
HDC ghdcInfo;
@@ -105,6 +105,9 @@ GdiGetHandleUserData(
105105
return pentry->pUser;
106106
}
107107

108+
#define FL_INVERT_COLORS 0x01
109+
#define FL_RED_BLUE 0x02
110+
108111
BOOL
109112
InitPerBitDepth(
110113
_In_ ULONG cBitsPerPixel,
@@ -113,7 +116,8 @@ InitPerBitDepth(
113116
_Out_ HBITMAP *phbmp,
114117
_Out_ HDC *phdcDIB,
115118
_Out_ HBITMAP *phbmpDIB,
116-
_Out_ PVOID *ppvBits)
119+
_Out_ PVOID *ppvBits,
120+
_In_ ULONG flags)
117121
{
118122
struct
119123
{
@@ -146,8 +150,21 @@ InitPerBitDepth(
146150

147151
if (cBitsPerPixel == 1)
148152
{
149-
bmiBuffer.bmiColors[0] = 0;
150-
bmiBuffer.bmiColors[1] = 0xFFFFFF;
153+
if (flags & FL_RED_BLUE)
154+
{
155+
bmiBuffer.bmiColors[0] = RGB(0xFF, 0x00, 0x00);
156+
bmiBuffer.bmiColors[1] = RGB(0x00, 0x00, 0xFF);
157+
}
158+
else if (flags & FL_INVERT_COLORS)
159+
{
160+
bmiBuffer.bmiColors[0] = 0xFFFFFF;
161+
bmiBuffer.bmiColors[1] = 0;
162+
}
163+
else
164+
{
165+
bmiBuffer.bmiColors[0] = 0;
166+
bmiBuffer.bmiColors[1] = 0xFFFFFF;
167+
}
151168
pbmi->bmiHeader.biClrUsed = 2;
152169
}
153170

@@ -183,12 +200,14 @@ BOOL GdiToolsInit(void)
183200
return FALSE;
184201
}
185202

186-
if (!InitPerBitDepth(1, 9, 9, &ghbmp1, &ghdcDIB1, &ghbmpDIB1, &gpvDIB1) ||
187-
!InitPerBitDepth(4, 5, 5, &ghbmp4, &ghdcDIB4, &ghbmpDIB4, &gpvDIB4) ||
188-
!InitPerBitDepth(8, 5, 5, &ghbmp8, &ghdcDIB8, &ghbmpDIB8, &gpvDIB8) ||
189-
!InitPerBitDepth(16, 8, 8, &ghbmp16, &ghdcDIB16, &ghbmpDIB16, &gpvDIB16) ||
190-
!InitPerBitDepth(24, 8, 8, &ghbmp24, &ghdcDIB24, &ghbmpDIB24, &gpvDIB24) ||
191-
!InitPerBitDepth(32, 8, 8, &ghbmp32, &ghdcDIB32, &ghbmpDIB32, &gpvDIB32))
203+
if (!InitPerBitDepth(1, 9, 9, &ghbmp1, &ghdcDIB1, &ghbmpDIB1, &gpvDIB1, 0) ||
204+
!InitPerBitDepth(1, 9, 9, &ghbmp1_InvCol, &ghdcDIB1_InvCol, &ghbmpDIB1_InvCol, &gpvDIB1_InvCol, FL_INVERT_COLORS) ||
205+
!InitPerBitDepth(1, 9, 9, &ghbmp1_RB, &ghdcDIB1_RB, &ghbmpDIB1_RB, &gpvDIB1_RB, FL_RED_BLUE) ||
206+
!InitPerBitDepth(4, 5, 5, &ghbmp4, &ghdcDIB4, &ghbmpDIB4, &gpvDIB4, 0) ||
207+
!InitPerBitDepth(8, 5, 5, &ghbmp8, &ghdcDIB8, &ghbmpDIB8, &gpvDIB8, 0) ||
208+
!InitPerBitDepth(16, 8, 8, &ghbmp16, &ghdcDIB16, &ghbmpDIB16, &gpvDIB16, 0) ||
209+
!InitPerBitDepth(24, 8, 8, &ghbmp24, &ghdcDIB24, &ghbmpDIB24, &gpvDIB24, 0) ||
210+
!InitPerBitDepth(32, 8, 8, &ghbmp32, &ghdcDIB32, &ghbmpDIB32, &gpvDIB32, 0))
192211
{
193212
printf("failed to create objects\n");
194213
return FALSE;

modules/rostests/apitests/gditools/gditools.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11

22
#pragma once
33

4-
extern HBITMAP ghbmp1, ghbmp4, ghbmp8, ghbmp16, ghbmp24, ghbmp32;
5-
extern HBITMAP ghbmpDIB1, ghbmpDIB4, ghbmpDIB8, ghbmpDIB16, ghbmpDIB24, ghbmpDIB32;
6-
extern HDC ghdcDIB1, ghdcDIB4, ghdcDIB8, ghdcDIB16, ghdcDIB24, ghdcDIB32;
7-
extern PVOID gpvDIB1, gpvDIB4, gpvDIB8, gpvDIB16, gpvDIB24, gpvDIB32;
4+
extern HBITMAP ghbmp1, ghbmp1_InvCol, ghbmp1_RB, ghbmp4, ghbmp8, ghbmp16, ghbmp24, ghbmp32;
5+
extern HBITMAP ghbmpDIB1, ghbmpDIB1_InvCol, ghbmpDIB1_RB, ghbmpDIB4, ghbmpDIB8, ghbmpDIB16, ghbmpDIB24, ghbmpDIB32;
6+
extern HDC ghdcDIB1, ghdcDIB1_InvCol, ghdcDIB1_RB, ghdcDIB4, ghdcDIB8, ghdcDIB16, ghdcDIB24, ghdcDIB32;
7+
extern PVOID gpvDIB1, gpvDIB1_InvCol, gpvDIB1_RB, gpvDIB4, gpvDIB8, gpvDIB16, gpvDIB24, gpvDIB32;
88
extern HDC ghdcInfo;
99

1010
extern HBITMAP ghbmpDIB32;

0 commit comments

Comments
 (0)