• 13
• 18
• 19
• 27
• 9

# WinAPI - LoadImage sometimes crashes

This topic is 4064 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello! I use the LoadImage function from the WinAPI to load images. Most of the time LoadImage works correct but sometimes the bits per pixels are wrong it is said that the image only consits of 1 bit per pixel although it consists of 24. The weired thing is that I always load the same image so there shouldnt be the error sometimes. Where could go wrong?
HBITMAP hImage = (HBITMAP) LoadImage(NULL,
filename,
IMAGE_BITMAP,
0,
0,

if (!hImage)
return;

DIBSECTION dibSection;
GetObject(hImage,sizeof(DIBSECTION),&dibSection);
if (dibSection.dsBm.bmBitsPixel == 1) cout << "only consits of one pixe"<<endl;

Thanks a lot!!!