Results 1 to 6 of 6

Thread: Problems setting transparency after SDL_CreateRGBSurfaceFrom

  1. #1

    Problems setting transparency after SDL_CreateRGBSurfaceFrom

    Hello All!

    I create a PSDL_Surface like this:
    Code:
    FSurface := SDL_CreateRGBSurfaceFrom(@FPixels[0], FWidth, FHeight, 32, FWidth*SizeOf(FPixels[0]), rmask, gmask, bmask, amask);
    Where FPixels is a dynamic array of Uint32. Now when I try to make a certain color transparent nothing happens. Anybody have any idea to why? Maybe even have some tutorial on how to do this sort of thing (I haven't found any myself).

    Any help is really appreciated!
    Signature:
    <br />This is a block of text that can be added to posts you make. There is a 255 character limit

  2. #2
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Problems setting transparency after SDL_CreateRGBSurfaceFrom

    Gonna need a wee bit more info on what you are trying to do.

    Where are you drawing from and to?

    AND

    What funciton are you using to draw?
    Jason McMillen
    Pascal Game Development
    Co-Founder





  3. #3
    Legendary Member cairnswm's Avatar
    Join Date
    Nov 2002
    Location
    Randburg, South Africa
    Posts
    1,537

    Problems setting transparency after SDL_CreateRGBSurfaceFrom

    This isn't exactly what you are doing but it works and makes it transparent

    [pascal]
    ImageSurface := SDL_CreateRGBSurface(SDL_SWSURFACE or SDL_HWPALETTE, Width,Height,
    ColorDepth, 0, 0, 0, 0);
    SDL_SetColorKey(ImageSurface, SDL_SRCCOLORKEY or SDL_RLEACCEL or SDL_HWACCEL,
    SDL_MapRGB(ImageSurface.format, R,G,B));
    SDL_BlitSurface(FontSurface, nil, Image.ImageSurface, @D );
    [/pascal]

    I set the transparency BEFORE drawing on the surface.

    Let us know if this helps.
    William Cairns
    My Games: http://www.cairnsgames.co.za (Currently very inactive)
    MyOnline Games: http://TheGameDeveloper.co.za (Currently very inactive)

  4. #4
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Problems setting transparency after SDL_CreateRGBSurfaceFrom

    cairnswm pretty much took the code right out of my brain.

    However, if that leads you down the wrong path then tell us what you can and we'll try to help.
    Jason McMillen
    Pascal Game Development
    Co-Founder





  5. #5

    Problems setting transparency after SDL_CreateRGBSurfaceFrom

    Nope, it didn't work. I'm probably doing something stupid somewhere else in my code (I suspect having different alpha values on the color I want transparent and the one in the image :? ). I'm gonna try to get it to work later but if I fail I'll post all the code for the images.

    Basically what I want to do is having my own image format (actually just a 32 bitmap (not to confuse with .bmp) and a header with the width/height + transparent color) and create a PSDL_Surface from this. The reason why I want this is because then I can easily have all images in one big file which I consider less messy than a lot of images on the hard drive.
    Signature:
    <br />This is a block of text that can be added to posts you make. There is a 255 character limit

  6. #6

    Problems setting transparency after SDL_CreateRGBSurfaceFrom

    Ok. Still haven't found the problem. To tell the truth I've hardly looked at it, I've had to many problems with this project so I'm gonna try to rewrite everything from scratch (again!) and hope no bug that I can't seem to fix will turn up this time.

    Anyway just thought you should know. Thanks for trying to help though!
    Signature:
    <br />This is a block of text that can be added to posts you make. There is a 255 character limit

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •