Sending a memory bitmap over internet
pekka keke

I was wondering how this would be done?
Let's say i draw a new picture in game, so it is saved as a memory bitmap. Then i wanted to send it over internet to another computer who would load and show it.

Should the bitmap be serialized or how would you be able to send it just like any other information? The network commands are no problem, just the method of sending the bitmap.

Trent Gamblin

lock it with al_lock_bitmap, send it with the width and height byte by byte respecting the pitch then al_unlock_bitmap it.

Arthur Kalliokoski

Lossless = png file
Lossy = jpg file
Done

pekka keke

I tried a huge for loop to check the bitmap and send it that way, well it worked but i wonder how can you give process time for other actions also? Right now the game jams for a few seconds. I tried Sleep() but it just jammed it completely.

And i wonder what Arthur was trying to say.

Trent Gamblin

Arthur was saying, saving the bitmap with al_save_bitmap and send that file. If you want the process to not "jam" then use al_create_thread or al_run_detached_thread.

EDIT: Arthur's idea is good if you can possibly do that.

Thread #611084. Printed from Allegro.cc