Here it isLONG_PTR zBitmapToImage (IN HDC hDC) { // dllexport AS LONG
BITMAPINFO bi = {0};
BITMAP bm = {0};
LONG_PTR lpImg = NULL;
long MaxBound;
HBITMAP hBitmap = ZI_GetBitmapFromDC(hDC);
if (hBitmap) {
GetObject(hBitmap, sizeof(bm), &bm);
bi.bmiHeader.biSize = sizeof(bi.bmiHeader);
bi.bmiHeader.biWidth = bm.bmWidth;
bi.bmiHeader.biHeight = -bm.bmHeight; // Put top in TOP instead on bottom!
bi.bmiHeader.biPlanes = 1;
bi.bmiHeader.biBitCount = 32;
bi.bmiHeader.biCompression = BI_RGB;
MaxBound = bm.bmWidth * bm.bmHeight * 4;
if ((long)g_ByteArray.max_size() < MaxBound) { g_ByteArray.resize(MaxBound); }
//vector<BYTE>::pointer ptr = &g_ByteArray[0];
if (GetDIBits(hDC, hBitmap, 0, bm.bmHeight, &g_ByteArray[0], &bi, DIB_RGB_COLORS)) {
if (GdipCreateBitmapFromScan0(bm.bmWidth, bm.bmHeight, bm.bmWidth * 4, PixelFormat32bppARGB, &g_ByteArray[0], lpImg) != 0) {
lpImg = NULL;
}
}
}
return lpImg;
}
BTW, did you see what happen to the GDI count each time we enable/disable mipmap textures...