[SDL] surface transparency

Krata krata at matfyz.cz
Mon Jul 29 00:42:01 PDT 2002


On 28 Jul 2002, Chris Thielen wrote:

> Hello everybody,
> 	I was wondering if there's anything special that I need to do to read
> the transparency off an image when directly handling the image. Using
> IMG_Load I've brought in a PNG w/ transparency (used for the empty
> spaces around a non-rectangular sprite) and I do various transformations
> operations w/ it, such as rotating it. Using code like the following, I
> read pixels and put pixels, but, what do I have to do to also get that
> transparency? Using the following method and performing transformations,
> the non-pixels (those that shouldnt appear) come out black. How do I
> read the transparency as well? Thanks.
> 
> inline Uint16 getpixel(SDL_Surface *surface, int x, int y) {
> 	Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x *
> surface->format->BytesPerPixel;
> 	return (*(Uint16 *)p);
> }
> 
> inline void putpixel(SDL_Surface *surface, int x, int y, Uint16 color) {
> 	Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x *
> surface->format->BytesPerPixel;
> 	*(Uint16 *)p = color;
> }
> 
> -- chris (chris at luethy.net)
> 
Hi,
 can you provide some sourcecode? Shortest example which shows unexpected 
behaviour?
Krata





More information about the SDL mailing list