![]() |
|
You're such a disappointment. |
Chris Katko
Member #1,881
January 2002
![]() |
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"} 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 al_save_bitmap("screen.png", al_get_backbuffer(al_display)); [edit] It's dumping the ALPHA CHANNEL of the screen. git issue now here: -----sig: |
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
![]() |
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: |
Samuel Henderson
Member #3,757
August 2003
![]() |
Chris Katko said: 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. ================================================= |
André Silva
Member #11,991
May 2010
![]() |
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
![]() |
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: 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: |
|