The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
SDL_image PNG surfaces showing up as black
Blaze


Joined: 05 Jul 2015
Posts: 11
I have a strange bug with my program, where x ( a green x ) and o ( a red o ), both solid color PNG images with a transparent background, get drawn to the screen completely black. The non-transparent shape remains the same.

The code where the images are loaded:

x = IMG_Load( "x.png" );
o = IMG_Load( "o.png" );

The code where the images are drawn to the main window surface:

case SQUARE_X:
SDL_BlitSurface( x, NULL, surface, &board[i][j] );
break;
case SQUARE_O:
SDL_BlitSurface( o, NULL, surface, &board[i][j] );

I don't have a good idea what might be causing this.
Update
Blaze


Joined: 05 Jul 2015
Posts: 11
After I edited my background image (adding yellow text) the O's now get drawn with the same color as the text. The X's remain black.
Blaze


Joined: 05 Jul 2015
Posts: 11
SOLVED: my background image was an 8-bit PNG instead of a 32-bit one.