I'm using the latest SDL/GFX libs on Fedora 10 and I'm trying to render a PNG or GIF image onto the screen surface. I could not get transparent PNG's to display at all so I replaced the transparent parts or my sprite with all white (and tried Magenta 255,0,255). The white-transparent PNG displays fine using this code:
SDL_Surface *image = load_image("sprite-white.png");
SDL_Surface *roto = SDL_DisplayFormat(image);
SDL_SetColorKey(roto, SDL_SRCCOLORKEY, SDL_MapRGB( roto->format, 255,255,255 ));
SDL_BlitSurface( roto, NULL, surface, &offset );
But when I try to rotate the sprite it does not drop all the white pixels. I replace the above code with this to rotate:
SDL_Surface *image = load_image("sprite-white.png");
SDL_Surface *roto = rotozoomSurface(image, rotation_degrees, 1, 1);
SDL_Surface *roto2 = SDL_DisplayFormat(roto);
SDL_SetColorKey(roto2, SDL_SRCCOLORKEY, SDL_MapRGB( roto2->format, 255,255,255 ));
SDL_BlitSurface( roto2, NULL, surface, &offset );
I end up with a white outline around some of the good pixels. GIF images give the same results.
When trying with transparent PNG/GIF files the code was the same except I did not call SDL_SetColorKey. Then the PNG did not display properly at all. One strange thing I found was the transparent PNG looked the same in MS Paint as it did in SDL, but GIMP/Photoshop programs opened it correctly.
Is there something I'm missing setting up the destination surface?
Google did not turn up much, a working example would be great.