transparent surface problem |
Davide "M3xican" Coppola
Guest
|
Hi,
I have a problem with trasnparent surface and PNG images. I need to create a transparent surface then blit images on it and finally blit this surface on screen. The images are PNG with alpha channel and transparency, the problem is that when I create the surface and blit images on it, the partially transparent pixels of the images disappear, losing so the AA and several details! this is the code that load the image:
and this is the code that create the surface:
I have also tried the example code in the man page of SDL_CreateRGBSurface, but the result is the same. This is an image that shows the problem: http://mars.sourceforge.net/data/img/surf_problem.png the building on the right (2) is the PNG blitted on screen, the one on the left (1) is the PNG blitted on the surface. What's the problem? Thank you for help. -- Davide "M3xican" Coppola -------------------------------------------------------------------- email: dmc at dev-labs.net homep: http://dmc.dev-labs.net ICQ: 104241710 MSN: bad_hangover at hotmail.it Don't use IE and OE! Download FireFox and ThunderBird: http://www.mozilla.org/ -------------------------------------------------------------------- |
|||||||||||||||
|
transparent surface problem |
transparent surface problem |
Alex Volkov
Guest
|
I am assuming that the image of the fortification is separate from the image
of its shadow, and that the shadow image is translucent (partial alpha). In that case, SDL_BlitSurface is behaving according to doc: * RGBA->RGBA: * SDL_SRCALPHA set: * alpha-blend (using the source alpha channel) the RGB values; * leave destination alpha untouched. * SDL_SRCALPHA not set: * copy all of RGBA to the destination. If you want the alpha channel to be transferred as well you need to remove the SDL_SRCALPHA flag from the source image surfaces. But also keep in mind that if the translucent pixels of your image surfaces overlap when blitted to your transparent surface, you will not get a 100% correct result -- they will not be blended, and neither will translucent pixels with opaque ones. You would need to write your own (transblending) blit for that. -Alex. -----Original Message----- From: Davide "M3xican" Coppola Sent: Thursday, January 19, 2006 5:17 AM To: sdl at libsdl.org Subject: [SDL] transparent surface problem [...snip...] I need to create a transparent surface then blit images on it and finally blit this surface on screen. The images are PNG with alpha channel and transparency, the problem is that when I create the surface and blit images on it, the partially transparent pixels of the images disappear, losing so the AA and several details! this is the code that load the image:
[...snip...] This is an image that shows the problem: http://mars.sourceforge.net/data/img/surf_problem.png |
|||||||||||||
|
transparent surface problem |
Bill Kendrick
Guest
|
On Fri, Jan 20, 2006 at 12:39:39AM +0000, Brian Barrett wrote:
maybe _i'm_ misunderstanding, but wouldn't that not do what you expect in some cases? (e.g., if src and dest are of different formats; or one HW surface, the other SW surface) -bill! |
|||||||||||||
|
transparent surface problem |
Brian Barrett
Guest
|
well lock the surface, and use the getpixel and putpixel code from the docs, and is my suggestion any better? anyway, looking at the original message, i think the pixel frmat will be the same " SDL_Surface * temp = IMG_Load(file.c_str()); //snip... img = SDL_DisplayFormatAlpha(temp); //snip.... SDL_PixelFormat * format = img->format; a_surface = SDL_CreateRGBSurface(SDL_SWSURFACE|SDL_SRCALPHA,w,h,format->BitsPerPixel, format->Rmask, format->Gmask, format->Bmask, format->Amask );" |
|||||||||||||
|
transparent surface problem |
Davide "M3xican" Coppola
Guest
|
Hi, after some tests I have solved the problem, these are the results:
1- it's useless use SDL_BlitSurface() if you need to blit an image with transparent pixels on a surface totally transparent. 2- it's possible use getpixel() and putpixel() functions, but this method is very slow. 3- the fastest method possible is use memcpy() copying pixels data from the image to the surface. Thanks to everybody has replied me. -- Davide "M3xican" Coppola -------------------------------------------------------------------- email: dmc at dev-labs.net homep: http://dmc.dev-labs.net ICQ: 104241710 MSN: bad_hangover at hotmail.it Don't use IE and OE! Download FireFox and ThunderBird: http://www.mozilla.org/ -------------------------------------------------------------------- |
|||||||||||
|
transparent surface problem |
Sam Lantinga
Guest
|
Can you enter this bug in the SDL bugzilla: http://bugzilla.libsdl.org/ Please include a small test program and image that can be used to see the problem. Thanks! -Sam Lantinga, Senior Software Engineer, Blizzard Entertainment |
|||||||||||||||||||
|
transparent surface problem |
Davide "M3xican" Coppola
Guest
|
I have submitted the bug: https://bugzilla.libsdl.org/show_bug.cgi?id=68 I have also created a package that shows the problem and my (temporary) solutions: http://mars.sourceforge.net/SDL/trans_bug.tar.gz I hope this could help you. -- Davide "M3xican" Coppola -------------------------------------------------------------------- email: dmc at dev-labs.net homep: http://dmc.dev-labs.net ICQ: 104241710 MSN: bad_hangover at hotmail.it Don't use IE and OE! Download FireFox and ThunderBird: http://www.mozilla.org/ -------------------------------------------------------------------- |
|||||||||||||||
|