SDL Color Key Can i get the color of an image background?
<p>Im using the code below so i can get the color of the back ground of an image an then make it transparent with the color key function, but it doesnt work, the background of my image is red, i change the parameters of sdl map rgb to red and it work, but my question, is if there is a way to get the color of the blackground of an image and why my code isnt working</p>

<pre><code>if( loadedImage != NULL )
    {
        //Create an optimized image
        optimizedImage = SDL_DisplayFormat( loadedImage );

        //Free the old image
        SDL_FreeSurface( loadedImage );

        //If the image was optimized just fine
        if( optimizedImage != NULL )
        {
            Uint32 colorkey = SDL_MapRGB( optimizedImage-&gt;format, 0xFF, 0xFF, 0xFF );

            SDL_SetColorKey( optimizedImage, SDL_SRCCOLORKEY | SDL_RLEACCEL, colorkey);
        }
    }
</code></pre>
