Taking a screenshot in allegro?
sadelbrid

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

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

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

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.

Thread #613006. Printed from Allegro.cc