7 HBITMAP ghbmp1
, ghbmp4
, ghbmp8
, ghbmp16
, ghbmp24
, ghbmp32
;
8 HBITMAP ghbmpDIB1
, ghbmpDIB4
, ghbmpDIB8
, ghbmpDIB16
, ghbmpDIB24
, ghbmpDIB32
;
9 HDC ghdcDIB1
, ghdcDIB4
, ghdcDIB8
, ghdcDIB16
, ghdcDIB24
, ghdcDIB32
;
10 PVOID gpvDIB1
, gpvDIB4
, gpvDIB8
, gpvDIB16
, gpvDIB24
, gpvDIB32
;
11 ULONG (*gpDIB32
)[8][8];
18 { 0x10, 0x20, 0x30, PC_NOCOLLAPSE
},
19 { 0x20, 0x30, 0x40, PC_NOCOLLAPSE
},
20 { 0x30, 0x40, 0x50, PC_NOCOLLAPSE
},
21 { 0x40, 0x50, 0x60, PC_NOCOLLAPSE
},
22 { 0x50, 0x60, 0x70, PC_NOCOLLAPSE
},
23 { 0x60, 0x70, 0x80, PC_NOCOLLAPSE
},
24 { 0x70, 0x80, 0x90, PC_NOCOLLAPSE
},
25 { 0x80, 0x90, 0xA0, PC_NOCOLLAPSE
},
31 _In_ ULONG cBitsPerPixel
,
36 _Out_ HBITMAP
*phbmpDIB
,
41 BITMAPINFOHEADER bmiHeader
;
44 LPBITMAPINFO pbmi
= (LPBITMAPINFO
)&bmiBuffer
;
47 *phbmp
= CreateBitmap(cx
, cy
, 1, cBitsPerPixel
, NULL
);
50 printf("CreateBitmap failed %lu\n", cBitsPerPixel
);
54 /* Setup bitmap info */
55 memset(&bmiBuffer
, 0, sizeof(bmiBuffer
));
56 pbmi
->bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
57 pbmi
->bmiHeader
.biWidth
= cx
;
58 pbmi
->bmiHeader
.biHeight
= -(LONG
)cy
;
59 pbmi
->bmiHeader
.biPlanes
= 1;
60 pbmi
->bmiHeader
.biBitCount
= cBitsPerPixel
;
61 pbmi
->bmiHeader
.biCompression
= BI_RGB
;
62 pbmi
->bmiHeader
.biSizeImage
= 0;
63 pbmi
->bmiHeader
.biXPelsPerMeter
= 0;
64 pbmi
->bmiHeader
.biYPelsPerMeter
= 0;
65 pbmi
->bmiHeader
.biClrUsed
= 0;
66 pbmi
->bmiHeader
.biClrImportant
= 0;
68 if (cBitsPerPixel
== 1)
70 bmiBuffer
.bmiColors
[0] = 0;
71 bmiBuffer
.bmiColors
[1] = 0xFFFFFF;
72 pbmi
->bmiHeader
.biClrUsed
= 2;
75 /* Create a compatible DC for the DIB */
76 *phdcDIB
= CreateCompatibleDC(0);
79 printf("CreateCompatibleDC failed %lu\n", cBitsPerPixel
);
83 /* Create the DIB section with the same values */
84 *phbmpDIB
= CreateDIBSection(*phdcDIB
, pbmi
, DIB_RGB_COLORS
, ppvBits
, 0, 0 );
85 if (*phbmpDIB
== NULL
)
87 printf("CreateDIBSection failed. %lu\n", cBitsPerPixel
);
91 SelectObject(*phdcDIB
, *phbmpDIB
);
99 /* Initialize a logical palette */
100 ghpal
= CreatePalette((LOGPALETTE
*)&gpal
);
103 printf("failed to create a palette \n");
107 if (!InitPerBitDepth(1, 9, 9, &ghbmp1
, &ghdcDIB1
, &ghbmpDIB1
, &gpvDIB1
) ||
108 !InitPerBitDepth(4, 5, 5, &ghbmp4
, &ghdcDIB4
, &ghbmpDIB4
, &gpvDIB4
) ||
109 !InitPerBitDepth(8, 5, 5, &ghbmp8
, &ghdcDIB8
, &ghbmpDIB8
, &gpvDIB8
) ||
110 !InitPerBitDepth(16, 8, 8, &ghbmp16
, &ghdcDIB16
, &ghbmpDIB16
, &gpvDIB16
) ||
111 !InitPerBitDepth(24, 8, 8, &ghbmp24
, &ghdcDIB24
, &ghbmpDIB24
, &gpvDIB24
) ||
112 !InitPerBitDepth(32, 8, 8, &ghbmp32
, &ghdcDIB32
, &ghbmpDIB32
, &gpvDIB32
))
114 printf("failed to create objects \n");