Click here to Skip to main content
15,905,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am developing an image capture application,I am trying to fetch BITMAPINFO using GetDIBits call,before sending the BITMAPINFO structure address to the function I am memset ing the structure memory to zero.
If lpvbits parameter of the GetDIBits is 0 then I suppose it should fill in the BITMAPINFO structure and return,but the function returns 0.
this is how the code looks:
C++
ZeroMemory(&infobm.bmiHeader,sizeof(BITMAPINFOHEADER));
                    infobm.bmiHeader.biBitCount = 24;
                    infobm.bmiHeader.biSize = sizeof(infobm);
                    infobm.bmiHeader.biHeight = 0;
                    infobm.bmiHeader.biWidth = 0;
                    infobm.bmiHeader.biPlanes = 1;
                    r = GetDIBits(dc,hbitmapHandle,0,infobm.bmiHeader.biHeight,0,&infobm,DIB_RGB_COLORS);
                    if(r == 0){
                        AfxMessageBox("Error Processing bitmap1");
                        return 1;
                    }

Please help,
thanks in advance
Posted
Updated 27-Jun-11 23:59pm
v2

1 solution

You called GetDIBits with cScanLines parameter (4th one) set to zero. That's a mistake.
 
Share this answer
 
v2
Comments
hakz.code 28-Jun-11 6:05am    
Hi,
Thanks for the help,I changed the 4th param to height of the image,but still i get the return val as 0,when I did GetLastError the errorcode is 87-ERROR_INVALID_PARAMETER,any clues?!
CPallini 28-Jun-11 6:39am    
I guess the info you pèrovide inside the infobm is not enough. Why don't you have a look at the following MSDN code sample:
http://msdn.microsoft.com/en-us/library/dd183402(VS.85).aspx
?
hakz.code 28-Jun-11 6:37am    
Hi I figured it out,the problem was the dc I passed was NULL

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900