Loading a PNG from a DATAFILE
I'm trying to load a PNG image that I saved as "Other" data in the Allegro datafile to a OpenLayer Bitmap. I'm definately not doing it right since it's giving a runtime error in the Bitmap constructor.
Here is how I'm trying to do it.
DATAFILE *dataFile = load_datafile("test data.dat");
BITMAP *bitmap = load_memory_png(dataFile.dat, sizeof(dataFile.dat), 0); //loadpng library function
Bitmap *newBitmap = Bitmap(bitmap, HAS_ALPHA_CHANNEL);
I'm sure someone knows the right to do this.
EDIT: Well I fixed it, didn't realize loadpng had functions to help with that.
Thread #589915. Printed from Allegro.cc
FYI, the problem was the .dat pointer is only four bytes, so you're basically telling loadpng that the png data is only 4 bytes long. That fails and returns NULL, which means the Bitmap doesn't get made. For the size of the data, you want to use the .len field.