- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
HIMAGELIST ImageList_LoadImageV(PVOID ImageBase, PCWSTR a[], int level)
{
PIMAGE_RESOURCE_DATA_ENTRY pirde;
PBITMAPINFOHEADER pbih;
DWORD cx, cy, cb, n, ofs;
if (
0 <= LdrFindResource_U(ImageBase, a, level, &pirde) &&
0 <= LdrAccessResource(ImageBase, pirde, (void**)&pbih, &cb) &&
cb > sizeof(BITMAPINFOHEADER) &&
pbih->biSize >= sizeof(BITMAPINFOHEADER) &&
(cx = pbih->biWidth) <= (cy = pbih->biHeight) &&
!(cy % cx) &&
pbih->biBitCount == 32 &&
(ofs = pbih->biSize) + (cx * cy << 2) == cb
)
{
n = cy / cx, cb = cx * cx << 2;
if (HIMAGELIST himl = ImageList_Create(cx, cy, ILC_COLOR32, n, 0))
{
BITMAPINFO bi = { {sizeof(BITMAPINFOHEADER), cx, cx, 1, 32 } };
if (HDC hdc = GetDC(0))
{
if (HBITMAP hbmp = CreateCompatibleBitmap(hdc, cx, cx))
{
do ; while (
SetDIBits(hdc, hbmp, 0, cx, RtlOffsetToPointer(pbih, ofs), &bi, DIB_RGB_COLORS) &&
0 <= ImageList_Add(himl, hbmp, 0) &&
(ofs += cb, --n)
);
DeleteObject(hbmp);
}
ReleaseDC(0, hdc);
}
if (!n) return himl;
ImageList_Destroy(himl);
}
}
return 0;
}