Take screenshot with allegro
Bingocat

Is there any way to take a screenshot and then save it as an allegro bitmap to be able to display it?

SiegeLord

al_save_bitmap("screenshot.bmp", al_get_backbuffer(display)) might work.

Bingocat

I don't mean take a screenshot of the program and save it. I mean take a screenshot of the whole screen and have it as a bitmap. Something like this.

ALLEGRO_BITMAP *screenshot = al_take_screenshot();

SiegeLord

Ah... that can't be done with Allegro.

Edgar Reynaldo

You have to get the HDC of the desktop on Windows and then blit the screenDC into a compatible memoryDC and then you should be able to access the specific pixels and write to a bitmap.

http://stackoverflow.com/questions/18858638/how-to-get-a-screen-image-into-a-memory-buffer

Gideon Weems

Users can do that with screenshot utilities, which run by default in pretty much every OS. Why would you want redundant functionality in your program, when it's as easy as pressing Print Screen?

jmasterx

How about

al_save_bitmap("screenshot.bmp", al_get_backbuffer(display));
ALLEGRO_BITMAP* screen = al_load_bitmap("screenshot.bmp");

:P

But really what you probably should do is triple buffer. https://wiki.allegro.cc/index.php?title=Triple_buffering

Keep a bitmap the size of the screen and draw into that, https://www.allegro.cc/manual/5/al_set_target_bitmap then draw that to the screen. You now have a copy of what is on the screen and you can redraw that at a later time.

Bingocat

Ok I figured out how to do it from here http://www.cplusplus.com/forum/windows/105644/ . I saved it as a jpg and loaded it with allegro.

Thread #614998. Printed from Allegro.cc