Mercurial > sdl-ios-xcode
comparison src/video/SDL_blit_N.c @ 1543:98f9b16f565c
From: "Alex Volkov"
Date: Thu, 10 Nov 2005 21:53:40 -0500
Subject: [SDL] BUG[?]: 32bpp RGBA->RGB colorkey blit, no SDL_SRCALPHA
It seems there is either a documentation vs. reality mismatch or a real bug
in SDL_blit_N.c:BlitNtoNKey().
The exact blit in question is a 32bpp RGBA->RGB, where RGBA has SDL_COLORKEY
and *no* SDL_SRCALPHA flags. The doc in SDL_video.h states:
* RGBA->RGB:
* SDL_SRCALPHA not set:
* copy RGB.
* if SDL_SRCCOLORKEY set, only copy the pixels matching the
* RGB values of the source colour key, ignoring alpha in the
* comparison.
BlitNtoNKey(), however, forgets to "ignore alpha in the comparison". The
documentation makes perfect sense, so I think it is the code that is faulty.
The attached patch corrects the code.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 15 Mar 2006 15:43:15 +0000 |
parents | dc6b59e925a2 |
children | ab1e4c41ab71 |
comparison
equal
deleted
inserted
replaced
1542:a8bf1aa21020 | 1543:98f9b16f565c |
---|---|
2192 SDL_PixelFormat *srcfmt = info->src; | 2192 SDL_PixelFormat *srcfmt = info->src; |
2193 SDL_PixelFormat *dstfmt = info->dst; | 2193 SDL_PixelFormat *dstfmt = info->dst; |
2194 int srcbpp = srcfmt->BytesPerPixel; | 2194 int srcbpp = srcfmt->BytesPerPixel; |
2195 int dstbpp = dstfmt->BytesPerPixel; | 2195 int dstbpp = dstfmt->BytesPerPixel; |
2196 unsigned alpha = dstfmt->Amask ? srcfmt->alpha : 0; | 2196 unsigned alpha = dstfmt->Amask ? srcfmt->alpha : 0; |
2197 Uint32 rgbmask = ~srcfmt->Amask; | |
2198 | |
2199 /* Set up some basic variables */ | |
2200 ckey &= rgbmask; | |
2197 | 2201 |
2198 while ( height-- ) { | 2202 while ( height-- ) { |
2199 DUFFS_LOOP( | 2203 DUFFS_LOOP( |
2200 { | 2204 { |
2201 Uint32 Pixel; | 2205 Uint32 Pixel; |
2202 unsigned sR; | 2206 unsigned sR; |
2203 unsigned sG; | 2207 unsigned sG; |
2204 unsigned sB; | 2208 unsigned sB; |
2205 RETRIEVE_RGB_PIXEL(src, srcbpp, Pixel); | 2209 RETRIEVE_RGB_PIXEL(src, srcbpp, Pixel); |
2206 if ( Pixel != ckey ) { | 2210 if ( (Pixel & rgbmask) != ckey ) { |
2207 RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB); | 2211 RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB); |
2208 ASSEMBLE_RGBA(dst, dstbpp, dstfmt, | 2212 ASSEMBLE_RGBA(dst, dstbpp, dstfmt, |
2209 sR, sG, sB, alpha); | 2213 sR, sG, sB, alpha); |
2210 } | 2214 } |
2211 dst += dstbpp; | 2215 dst += dstbpp; |