src/video/SDL_blit.h
changeset 7502 6ff02ff3cf06
parent 7373 5e6efd29b461
child 7562 5287c82340e3
     1.1 --- a/src/video/SDL_blit.h	Mon Jul 22 02:51:45 2013 -0700
     1.2 +++ b/src/video/SDL_blit.h	Tue Jul 23 08:06:49 2013 -0700
     1.3 @@ -440,12 +440,22 @@
     1.4      }                                                                   \
     1.5  }
     1.6  
     1.7 -/* Blend the RGB values of two Pixels based on a source alpha value */
     1.8 -#define ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB)                          \
     1.9 +/* Blend the RGB values of two pixels with an alpha value */
    1.10 +#define ALPHA_BLEND_RGB(sR, sG, sB, A, dR, dG, dB)                      \
    1.11  do {                                                                    \
    1.12 -    dR = ((((int)(sR-dR)*(int)A)/255)+dR);                              \
    1.13 -    dG = ((((int)(sG-dG)*(int)A)/255)+dG);                              \
    1.14 -    dB = ((((int)(sB-dB)*(int)A)/255)+dB);                              \
    1.15 +    dR = ((((unsigned)(sR-dR)*(unsigned)A)/255)+dR);                    \
    1.16 +    dG = ((((unsigned)(sG-dG)*(unsigned)A)/255)+dG);                    \
    1.17 +    dB = ((((unsigned)(sB-dB)*(unsigned)A)/255)+dB);                    \
    1.18 +} while(0)
    1.19 +
    1.20 +
    1.21 +/* Blend the RGBA values of two pixels */
    1.22 +#define ALPHA_BLEND_RGBA(sR, sG, sB, sA, dR, dG, dB, dA)                \
    1.23 +do {                                                                    \
    1.24 +    dR = ((((unsigned)(sR-dR)*(unsigned)sA)/255)+dR);                   \
    1.25 +    dG = ((((unsigned)(sG-dG)*(unsigned)sA)/255)+dG);                   \
    1.26 +    dB = ((((unsigned)(sB-dB)*(unsigned)sA)/255)+dB);                   \
    1.27 +    dA = ((unsigned)sA+(unsigned)dA-((unsigned)sA*dA)/255);             \
    1.28  } while(0)
    1.29  
    1.30