[SDL] BUG in copy_32(SDL_RLEaccel.c)?

li zhuo zuoli at zowietek.cn
Sat Jul 2 00:03:28 PDT 2011


copy_32 function in SDL_RLEaccel.c has below tow statement:

--------------------------------------

PIXEL_FROM_RGB(pixel, dfmt, r, g, b);

*d++ = pixel | a << 24;

--------------------------------------

 

PIXEL_FROM_RGB is macro, it is defined in SDL_blit.h.

--------------------------------------

#define PIXEL_FROM_RGB(Pixel, fmt, r, g, b)  \

{                                                       \

Pixel = ((r>>fmt->Rloss)<<fmt->Rshift)|     \

         ((g>>fmt->Gloss)<<fmt->Gshift)|       \

         ((b>>fmt->Bloss)<<fmt->Bshift)| \

         fmt->Amask;                       \

}

---------------------------------------

Basing PIXEL_FROM_RGB definition, when fmt->Amask is 0xff000000, then:

PIXEL_FROM_RGB(pixel, dfmt, r, g, b) will make bit[31, 24] of pixel variable
always 0xff!

 

pixel | a << 24, this operation does nothing!

 

On caller view, all translucent pixels change to opaque after RLE!

 

Code change to:

---------------------------------

PIXEL_FROM_RGB(pixel, dfmt, r, g, b);

*d++ = (pixel & 0xffffff) | a << 24;

----------------------------------

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20110702/a7f24a46/attachment-0007.htm>


More information about the SDL mailing list