Yes...
GetDIBits()
Which language are you using that can access some of the WIN32 API (in a DLL) but not all of it?
Printable View
Yes...
GetDIBits()
Which language are you using that can access some of the WIN32 API (in a DLL) but not all of it?
You do realize that you do not need either GetPixel or SetPixel calls. Both can be accomplished by the use of bit shifting to get or set the appropriate RGB values.
Good luck!Code:HDC hdcc = CreateCompatibleDC(hdc);
//hdc - is your dc which you copy from
HBITMAP hBm = CreateCompatibleBitmap(hdc, iSrcW, iSrcH);
//iSrcW, iSrcH - size of you sourse hdc
HBITMAP hOldBm = (HBITMAP)SelectObject(hdcc, hBm);
BitBlt(hdcc, 0, 0, iSrcW, iSrcH, hdc, iX, iY, SRCCOPY);
// now, get info from copied bitmap
BITMAP bm;
memset(&bm, 0, sizeof BITMAP);
int iErr = GetObject(hBm, sizeof(BITMAP), &bm);
iErr = GetLastError();
iBPP = bm.bmBitsPixel;
DIBSECTION dis;
iErr = GetObject(hBm, sizeof(DIBSECTION), &dis);
int length = (bm.bmWidth * bm.bmHeight) * (bm.bmBitsPixel>>3);
if(0 == length)
return NULL;// nothing to do
// Ok, bitmap info now
BITMAPINFO bi;
memset(&bi, 0, sizeof BITMAPINFO);
BYTE *pBits = new BYTE[length];
bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bi.bmiHeader.biWidth = bm.bmWidth;
bi.bmiHeader.biHeight = bm.bmHeight;
bi.bmiHeader.biPlanes = 1;
bi.bmiHeader.biBitCount = bm.bmPlanes * bm.bmBitsPixel;
bi.bmiHeader.biCompression = 0;
bi.bmiHeader.biSizeImage = 0;
bi.bmiHeader.biXPelsPerMeter = 0;
bi.bmiHeader.biYPelsPerMeter = 0;
bi.bmiHeader.biClrUsed = 0;
bi.bmiHeader.biClrImportant = 0;
LPBYTE lpBits = (LPBYTE) GlobalAlloc(GMEM_FIXED, length);
int iBits = GetDIBits(hdc, hBm, 0, bm.bmHeight, lpBits, &bi, DIB_RGB_COLORS);
//....... now you got bits of your pixels in lpBits
// remember, that y-axis begun from bottom of screen
// and don't forget:
GlobalFree(lpBits);
SelectObject(hdcc, hOldBm);
DeleteObject(hBm);
DeleteDC(hdcc);
Seriously, forget that SetPixel and GetPixel exist. They are completely useless. Using them is like walking down the road to the store to buy a single paperclip every time you need one, even though you go through about 200+ per day.
Bitblt on the other hand would be like buying a bag full of them.