winapi - CreateDIBSection to get uint8_t[] of Portion of Screen -


i trying uint8_t[] of portion of screen. xy coordinates of top left 2,3 , of bottom right 17,18.

this top 30x30 pixels of screen regular screenshot , photoshop crop:

and 2,3 17,18 screenshot should via regular screenshot , photoshop crop:

this getting result of code:

my code in js-ctypes there no ctypes errors. winapi thing. didn't tag ctypes confused. simplified code using, error checks etc have been removed:

c1 = {x:2, y:3} // top left corner c2 = {x:17, y:18} // bottom right corner  createdc('display', null, null, null); nbpp = getdevicecaps(hdcscreen, bitspixel);  w = c2.x - c1.x; // width = 15 h = c2.y - c1.y; // height = 15  hdcmemorydc = createcompatibledc(hdcscreen);  bmi = bitmapinfo(); bmi.bmiheader.bisize = bitmapinfoheader.size; bmi.bmiheader.biwidth = w; bmi.bmiheader.biheight = -1 * h; bmiheader.biplanes = 1; bmi.bmiheader.bibitcount = nbpp; // nbpp 32 bmi.bmiheader.bicompression = bi_rgb;  hbmp = createdibsection(hdcscreen, &bmi, dib_rgb_colors, (void**)&pixelbuffer, null, 0);  selectobject(hdcmemorydc, hbmp); bitblt(hdcmemorydc, 0, 0, w, h, hdcscreen, c1.x, c1.y, srccopy); 

can please understand why portion of screen bits come out wrong? if full screen shot works fine.

thanks!


Comments