Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is the proper way to use GFX rotozoomSurface with SDL for drawing transparent sprites?
    primarykey
    data
    text
    <p>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:</p> <pre><code>SDL_Surface *image = load_image("sprite-white.png"); SDL_Surface *roto = SDL_DisplayFormat(image); SDL_SetColorKey(roto, SDL_SRCCOLORKEY, SDL_MapRGB( roto-&gt;format, 255,255,255 )); SDL_BlitSurface( roto, NULL, surface, &amp;offset ); </code></pre> <p>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:</p> <pre><code>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-&gt;format, 255,255,255 )); SDL_BlitSurface( roto2, NULL, surface, &amp;offset ); </code></pre> <p>I end up with a white outline around some of the good pixels. GIF images give the same results. </p> <p>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. </p> <p>Is there something I'm missing setting up the destination surface?</p> <p>Google did not turn up much, a working example would be great. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload