thought it might be something obvious like that but I'm still not quite there yet. drawing the bmp from the memfile works fine but saving it either to file or to a buffer doesn't seem to be working for me.
Ignoring writing to the buffer for now and trying to write to file it looks like it almost creates a valid tga file but irfanview can't read it but at least it thinks its a tga file instead of unrecognised now.
EDIT: well that was kindof dumb of me forgetting to close the file....
Lets try again and do the real problem of writing to the buffer
So the problem is that it never seems to write the right stuff to the buffer i think. I'm not sure on the difference with using a void* buffer opposed to a char* buffer but if I use a char* buffer it definitely comes out empty
It seems odd to me that the bytes written to the buffer is significantly bigger then the bytes written to the memfile. Something like 11000 compared to 4116 I expected a little bit more but not nearly that much.
I definitely know that it is in the memfile because I can al_load_bitmap_f() from it and draw it on the screen. But I've had no luck actually writing it to file and instead get an invalid TGA file.
fileBuffer = malloc(
2 ALLEGRO_FILE *
memfile = al_open_memfile(
fileBuffer, length, "rw");
pos = al_ftell(
result = al_save_bitmap_f(
, bmp); //temp as .tga
8 printf("save result = %i\n"
endpos = al_ftell(
11 printf("save endpos=%i\n"
graphicBuffer = malloc(
18 void *
buf = malloc(
bytes = al_fread(
memfile, buf, length);
z, graphicBuffer, bytes+1
Looks like I worked out and isn't it obvious what the problem is.
So playing around I checked that the buffer was being saved properly and that it was. The issue is that while the file is added to the zip archive its apparently not saved until zip_close() is called and I had already cleared the buffers before than and so it only saved garbage to the file.