In my program I download a image from a server into memory now I want to take a pointer and turn it into an ALLEGRO_BITMAP. Is there special way to do that or does allegro have something that I can use to do that? I tried casting it but it didn't work.
You can make a memfile (using the memfile addon) from the data, and use al_load_bitmap_f.
Or save it to disk and al_load_bitmap it.
Thanks I'll give it a shot. I can't save it to the disk for performance issues but I think the first one will work. I'm getting a crash when I try to draw it. Does this look valid?
selectedCard.Load(al_load_bitmap_f(al_open_memfile(chunk.memory, chunk.size, "w"), ""));
The Load function takes a parameter of ALLEGRO_BITMAP.
You should check for failure in both al_open_memfile and al_load_bitmap_f.
Plus that's a memory leak (leaking from al_open_memfile).
How do you know it's a memory leak?
al_open_memfile (click for docs) returns an ALLEGRO_FILE that has to be closed with al_fclose, which frees up the memory used.
So I have to use memfile open close it then use load bitmap f?
You'd close the memfile after using load_bitmap_f. Also free up the memory buffer you have the image in.