Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Sending a memory bitmap over internet

This thread is locked; no one can reply to it. rss feed Print
Sending a memory bitmap over internet
pekka keke
Member #14,559
September 2012

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
Member #261
April 2000
avatar

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
Second in Command
February 2005
avatar

Lossless = png file
Lossy = jpg file
Done

“Throughout history, poverty is the normal condition of man. Advances which permit this norm to be exceeded — here and there, now and then — are the work of an extremely small minority, frequently despised, often condemned, and almost always opposed by all right-thinking people. Whenever this tiny minority is kept from creating, or (as sometimes happens) is driven out of a society, the people then slip back into abject poverty. This is known as "bad luck.”

― Robert A. Heinlein

pekka keke
Member #14,559
September 2012

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
Member #261
April 2000
avatar

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.

Go to: