Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Take screenshot with allegro

This thread is locked; no one can reply to it. rss feed Print
Take screenshot with allegro
Bingocat
Member #15,424
December 2013

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

SiegeLord
Member #7,827
October 2006
avatar

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

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Bingocat
Member #15,424
December 2013

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
Member #7,827
October 2006
avatar

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

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Edgar Reynaldo
Member #8,592
May 2007
avatar

Gideon Weems
Member #3,925
October 2003

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
Member #11,410
October 2009

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
Member #15,424
December 2013

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.

Go to: