SFML community forums

Help => Graphics => Topic started by: fruitMaster on August 24, 2011, 11:19:24 am

Title: 32bit png image saving
Post by: fruitMaster on August 24, 2011, 11:19:24 am
Ok, example code:

Code: [Select]
sf::Image img ;
img.Create( 256 , 256 ) ;
for( int x = 0 ; x < 256 ; ++x )
for( int y = 0 ; y < 256 ; ++y )
img.SetPixel( x , y , sf::Color( x , y , 255 , (256+x-y)%256 ) ) ;

img.SaveToFile( "C:/test.png" ) ;


This code produces a 24bpp png file, and not a 32bpp one. I've been looking at the code, and I don't see a way to specify this.
I'm even wondering if stb_image supports writing the alpha channel at all...

Any ideas?

Thanks in advance!
Title: 32bit png image saving
Post by: Laurent on August 24, 2011, 01:33:18 pm
Works for me with SFML 2.
Title: 32bit png image saving
Post by: fruitMaster on August 24, 2011, 01:34:54 pm
Damned, the bug is not in SFML, but in the bloody image viewer. Irfanview was reporting 24bpp and not showing the alpha channel at all.

Sorry for this stupid mistake.