PDA

View Full Version : Problems setting transparency after SDL_CreateRGBSurfaceFrom



Ultra
25-11-2004, 09:43 PM
Hello All!

I create a PSDL_Surface like this:


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!

WILL
26-11-2004, 12:25 AM
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?

cairnswm
26-11-2004, 08:53 AM
This isn't exactly what you are doing but it works and makes it transparent


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 );


I set the transparency BEFORE drawing on the surface.

Let us know if this helps.

WILL
27-11-2004, 03:35 AM
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.

Ultra
27-11-2004, 01:00 PM
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.

Ultra
01-12-2004, 10:36 PM
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!