Is there something along the lines of load_image(void * data, int length) that would allow me to send the data from a support image filetype without having to first save the image to the hdd?
When sending these images over a network, it seems somewhat painful to first have to save them to the disk, and then load them from there.
In Allegro4 you can create a packfile out of memory and use the load_XX_pf routines. Here is my in-memory packfile you can use and a usage of loading PCX files.
BITMAP * memoryPCX(unsigned char * const data, const int length){ PACKFILE_VTABLE table = Memory::makeTable(); Memory::memory memory(data, length); PACKFILE * pack = pack_fopen_vtable(&table, &memory); /* need to supply a proper palette at some point */ RGB * palette = NULL; BITMAP * pcx = load_pcx_pf(pack, palette); pack_fclose(pack); return pcx; }
They really decided not to make it easy, huh. Thanks for the response.
There's a simpler way if you can already extract the pixel data from memory. kazzmir's method is great if you have a file loaded in memory, especially one with a non-trivial format.