I want to read the bytes from a BMP file, and allocate them into an unsigned char array to use it as a texture in an Open GL application.
So far, this is how I define my array:
unsigned char* data = new unsigned char [imageSize];
being imageSize an unsigned int that defines the size of the bitmap, in bytes.
The problem is that when I run the application, data has a length of 4 bytes, instead of the value of imageSize. I made a log to track what the program does, and this is what it gives to me:
LOG: imageSize : 786434
LOG: image width : 512
LOG: image height : 512
ERROR: Failed to allocate Data Buffer (bytes) : 4
ERROR: Required bytes for the buffer : 786434
In other words, data should be a 786434 bytes long array. Instead, I get a 4 bytes long array.
I also tried doing many things like
unsigned char* data;
data = new unsigned char [imageSize];
Also defining it as
data = (unsigned char*)malloc(imageSize);
But none of them work for some reason. Even if I assign to it the length manually, it won't work.
I'm programming this in Visual Studio 2010, for Windows, and it's a 32 bit application.