Mercurial > sdl-ios-xcode
comparison src/video/SDL_blit.h @ 4293:63b54ddd38ea SDL-1.2
Fixed bug #627
Increased accuracy of alpha blend calculation
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 10 Oct 2009 07:48:15 +0000 |
parents | a1b03ba2fcd0 |
children | 2d00ed718720 |
comparison
equal
deleted
inserted
replaced
4292:464126f4c7db | 4293:63b54ddd38ea |
---|---|
382 } | 382 } |
383 | 383 |
384 /* Blend the RGB values of two Pixels based on a source alpha value */ | 384 /* Blend the RGB values of two Pixels based on a source alpha value */ |
385 #define ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB) \ | 385 #define ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB) \ |
386 do { \ | 386 do { \ |
387 dR = (((sR-dR)*(A))>>8)+dR; \ | 387 dR = (((sR-dR)*(A)+255)>>8)+dR; \ |
388 dG = (((sG-dG)*(A))>>8)+dG; \ | 388 dG = (((sG-dG)*(A)+255)>>8)+dG; \ |
389 dB = (((sB-dB)*(A))>>8)+dB; \ | 389 dB = (((sB-dB)*(A)+255)>>8)+dB; \ |
390 } while(0) | |
391 | |
392 /* Blend the RGB values of two Pixels based on a source alpha value */ | |
393 #define ACCURATE_ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB) \ | |
394 do { \ | |
395 unsigned tR, tG, tB, tA; \ | |
396 tA = 255 - sA; \ | |
397 tR = 1 + (sR * sA) + (dR * tA); \ | |
398 dR = (tR + (tR >> 8)) >> 8; \ | |
399 tG = 1 + (sG * sA) + (dG * tA); \ | |
400 dG = (tG + (tG >> 8)) >> 8; \ | |
401 tB = 1 + (sB * sA) + (dB * tA); \ | |
402 dB = (tB + (tB >> 8)) >> 8; \ | |
403 } while(0) | 390 } while(0) |
404 | 391 |
405 | 392 |
406 /* This is a very useful loop for optimizing blitters */ | 393 /* This is a very useful loop for optimizing blitters */ |
407 #if defined(_MSC_VER) && (_MSC_VER == 1300) | 394 #if defined(_MSC_VER) && (_MSC_VER == 1300) |