Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Taking a screenshot in allegro?

Credits go to Trent Gamblin for helping out!
This thread is locked; no one can reply to it. rss feed Print
Taking a screenshot in allegro?
sadelbrid
Member #15,200
June 2013

Is there a function that will allow me to save a bitmap as whatever the display is currently showing?... possibly something like ALLEGRO_BITMAP *screenshot = "al_get_display_bitmap(display)") I've looked through the manual and nothing is catching my eye. I figured someone would know. Basically I want to copy the pixels currently being displayed to a bitmap.

Thanks

Trent Gamblin
Member #261
April 2000
avatar

You can use al_save_bitmap("something.png", al_get_display_backbuffer(display));. It will be slow though but no avoiding that. It also might not work on some OpenGL ES (mobile) devices.

EDIT: Make sure you do it after drawing and BEFORE flipping.

sadelbrid
Member #15,200
June 2013

Oh okay thanks. If it is too slow, I will just make a buffer instead. I've been using the display's backbuffer by default.

Trent Gamblin
Member #261
April 2000
avatar

A buffer won't be any faster. It probably won't be too slow anyway. Just not as fast as when not using hardware acceleration.

Go to: