SDL - IMG_Load() question

This is a discussion on SDL - IMG_Load() question within the Game Programming forums, part of the General Programming Boards category; Hi, I'm using IMG_Load() to load a PNG image with a transparent background, but when I apply the surface to ...

  1. #1
    Registered User Stonehambey's Avatar
    Join Date
    Jan 2008
    Location
    Kent, UK
    Posts
    118

    SDL - IMG_Load() question

    Hi,

    I'm using IMG_Load() to load a PNG image with a transparent background, but when I apply the surface to the screen I get a coloured background. Sometimes green and sometimes white.

    I can give it a background and the colourkey the background out, but IMG_Load() should be able to do this itself according to lazy foo.

    I'm pretty new to SDL so perhaps I'm missing something obvious, thanks

  2. #2
    Registered User Stonehambey's Avatar
    Join Date
    Jan 2008
    Location
    Kent, UK
    Posts
    118
    Quote Originally Posted by guest View Post
    Never use transparent backgrounds...set a color you wont use then just set the pixel to transparent.


    Check here...you will see how it works. http://lazyfoo.net/SDL_tutorials/lesson05/index.php






    Uint32 colorkey = SDL_MapRGB( optimizedImage->format, 0, 0xFF, 0xFF );
    SDL_SetColorKey( optimizedImage, SDL_SRCCOLORKEY, colorkey );

    this will remove 00ffff

    0 RED = 0
    255: Blue = 0xFF
    255: Green = 0xFF
    That's exactly what I've been doing, and it works fine. I was just wondering why transparent backgrounds haven't been working properly

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. another do while question
    By kbpsu in forum C++ Programming
    Replies: 3
    Last Post: 03-23-2009, 01:14 PM
  2. SDL questions
    By Cpro in forum C++ Programming
    Replies: 1
    Last Post: 08-09-2008, 01:26 PM
  3. SDL and MinGW Studio
    By Vicious in forum Tech Board
    Replies: 0
    Last Post: 07-30-2004, 10:59 PM
  4. simple SDL question
    By sand_man in forum Game Programming
    Replies: 3
    Last Post: 07-02-2004, 01:04 AM
  5. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 10:47 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21