Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » You're such a disappointment.

This thread is locked; no one can reply to it. rss feed Print
You're such a disappointment.
Chris Katko
Member #1,881
January 2002
avatar

You, the Allegro developers have let me down.

j/k

Okay, so oddly enough right after talking about rarely finding bugs. I've got a curiosity that may be Allegro 5 related.

Saving a bitmap of the screen seems to change the brightness in Linux. It might not be respecting gamma or something.

{"name":"screen.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/a\/ca53749d909c08577ef83569638f5bcc.png","w":1360,"h":720,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/c\/a\/ca53749d909c08577ef83569638f5bcc"}screen.png

The "space" background in that picture, on my screen, is black or almost black. But the screenshot I see uploaded to github is very very bright

http://www.allegro.cc/files/attachment/613209
https://www.allegro.cc/files/attachment/613209

al_save_bitmap("screen.png", al_get_backbuffer(al_display));

[edit] It's dumping the ALPHA CHANNEL of the screen. git issue now here:

https://github.com/liballeg/allegro5/issues/1337

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Peter Hull
Member #1,136
March 2001

Interesting. al_get_backbuffer returns the actual backbuffer so if there is an alpha channel then the bitmap will have it. And al_save_bitmap should save an alpha channel if there is one. So it's undesirable but I can't see how it could be otherwise. I suppose the solution is to make yourself a bitmap with an opaque black rectangle and blit the backbuffer onto it? Also this may even be quicker - the docs say that operations on the backbuffer may be unaccelerated, so blitting in one go to a memory bitmap may be better.

ps that's a groovy looking screenshot, what is it?

Chris Katko
Member #1,881
January 2002
avatar

Still very prototype stage. But it's exploring a game akin to Asteroids and/or Gravity Well.

Public repo for the time, because there's nothing really proprietary in there yet. Just lots of sweet D code.

https://github.com/katastic/dgravity

I have Allegro dump a screenshot every time I load the game, so that github stores it. Then, I could, theoretically, span through hundreds of old commits, and get a history of screenshots as the game progresses.

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Samuel Henderson
Member #3,757
August 2003
avatar

I have Allegro dump a screenshot every time I load the game, so that github stores it. Then, I could, theoretically, span through hundreds of old commits, and get a history of screenshots as the game progresses.

That is actually really smart! I may wind up doing something similar in future projects.

=================================================
Paul whoknows: Why is this thread still open?
Onewing: Because it is a pthread: a thread for me to pee on.

André Silva
Member #11,991
May 2010
avatar

I can confirm I have this behavior as well. For some reason I struggle with understanding how blending works in general in Allegro, but it looks to me like I'm doing everything right, like I have for years. Sure enough, screenshot dumping never had this problem on my old laptop, but now that I'm on a new one, it does. I have no idea if this is a graphics card thing, OS thing, or Allegro version thing, and I'm not quite sure how I'd even start to debug this.

Chris Katko
Member #1,881
January 2002
avatar

You can work around it, I've got a D language version in my github repo in file main.d above.

I mostly converted it to C/C++. (took all of like 30 seconds) Use whatever string (or c-string) you want for the path:

#SelectExpand
1void al_save_screen(string path) 2 { 3 ALLEGRO_BITMAP* disp = al_get_backbuffer(al_display); 4 int w = al_get_bitmap_width(disp); 5 int h = al_get_bitmap_height(disp); 6 ALLEGRO_BITMAP* temp = al_create_bitmap(w, h); 7 al_lock_bitmap(temp, al_get_bitmap_format(temp), ALLEGRO_LOCK_WRITEONLY); 8 al_lock_bitmap(disp, al_get_bitmap_format(temp), ALLEGRO_LOCK_READONLY); // makes HUGE difference (6.4 seconds vs 270 milliseconds) 9 al_set_target_bitmap(temp); 10 for(int j = 0; j < h; j++) 11 for(int i = 0; i < w; i++) 12 { 13 ALLEGRO_COLOR pixel = al_get_pixel(disp, i, j); 14 pixel.a = 1.0; // remove alpha 15 al_put_pixel(i, j, pixel); 16 } 17 al_unlock_bitmap(disp); 18 al_unlock_bitmap(temp); 19 al_save_bitmap(path, temp); 20 al_set_target_bitmap(al_get_backbuffer(al_display)); //set back to normal screen target 21 al_destroy_bitmap(temp); 22 }

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Go to: