c++ - GDI Screenshot, results varying on different computer -


i try take screenshot gdi, use in ffmpeg. screenshot works , ffmpeg handle without problem.

but, on computer, image not want can see below.

enter image description here

here code use init bitmap :

//-- mimagebuffer = new unsigned char[mwxhxs]; memset(mimagebuffer, 0, mwxhxs); //-- hscreendc = getdc(0); hmemorydc = createcompatibledc(hscreendc); //-- bi.bmiheader.bisize = sizeof(bitmapinfoheader); bi.bmiheader.bibitcount = 24; bi.bmiheader.biwidth = mwidth; bi.bmiheader.biheight = mheight; bi.bmiheader.bicompression = bi_rgb; bi.bmiheader.biplanes = 1; bi.bmiheader.biclrused = 24; bi.bmiheader.biclrimportant = 256; hbitmap = createdibsection(hmemorydc, &bi, dib_rgb_colors, &mimagebuffer, 0, 0); selectobject(hmemorydc, hbitmap); 

and here each screenshot :

if(bitblt(     hmemorydc,     0,     0,     mwidth,     mheight,     hscreendc,     mpx,     mpy,     srccopy | captureblt )) 

i not have error running application ugly image , on computer. don't know difference causing on these computer (all win7, aero actived...). not understand because code follow example found...

please me !

you creating device-independent-bitmap (createdibsection) using device dependent context (createcompatibledc) work it. believe need create device dependent bitmap compatible bitblt, or use stretchdibits support device-independent image data. reason works on computers , not others because video driver determines format of device-dependent image, may or may not same windows definition of device-independent image.

here example of capturing image (yes, unnecessarily long, still seems contain info): https://msdn.microsoft.com/en-us/library/windows/desktop/dd183402(v=vs.85).aspx

and here documentation on stretchdibits, in case require dib: https://msdn.microsoft.com/en-us/library/windows/desktop/dd145121(v=vs.85).aspx


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -