Hi! I want to get an unsigned char array of bytes (and if possible, width and height)from a Bitmap image using "Windows.h" functions, like FindResource, LoadResource, etc.
I have successfully managed to load text files from these functions, they give me the bytes of the file. But I am having difficulty with Bitmaps, I have search and went to many forums but was unsuccessful. This is what I am trying to accomplish:
unsigned char* data = nullptr;
auto bitmap = LoadBitmap(...) //I have no idea what each of the arguments are..
data = //some function to get the bytes of the bitmap.
What kind of BMP? How many bits per pixel? 1, 4, 8, or 24? With colortable?
Maybe you first apply https://www.irfanview.com as batch converter to transform your BMPs to a known, easy to handle format. Otherwise your routine has to be prepared for all ifs and buts.
I do have an actual bitmap which is 2 x 2 pixels. What kind of BMP? I have no idea, I just made a simple texture in paint.net and exported it as a BMP file.
Your 2x2 BMP of 24 bit colour depth has the size of 70 bytes? The pixel take 2x2 * 24/8 = 12 bytes. Look at it with a hex editor of your choice and find out what the rest could be, the legend you find here: https://en.wikipedia.org/wiki/BMP_file_format
One more word. I just had a look to the source of Emu42, https://hp.giesselink.com/emu42.htm -- file FILES.C in E42S122.zip there, it is C not C++ but may give an impression of all the ifs and buts to respect when using an image as faceplate for an emulator. Even without optional GIF and PNG the different BMP formats are some kind of drudgery.
So I would suggest to use a lib you trust like the one Ganado mentioned or copy what is free to use before you code&debug home-made denouements.