441 } |
441 } |
442 |
442 |
443 /* Blend the RGB values of two pixels with an alpha value */ |
443 /* Blend the RGB values of two pixels with an alpha value */ |
444 #define ALPHA_BLEND_RGB(sR, sG, sB, A, dR, dG, dB) \ |
444 #define ALPHA_BLEND_RGB(sR, sG, sB, A, dR, dG, dB) \ |
445 do { \ |
445 do { \ |
446 dR = ((((unsigned)(sR-dR)*(unsigned)A)/255)+dR); \ |
446 dR = (Uint8)((((int)(sR-dR)*A)/255)+dR); \ |
447 dG = ((((unsigned)(sG-dG)*(unsigned)A)/255)+dG); \ |
447 dG = (Uint8)((((int)(sG-dG)*A)/255)+dG); \ |
448 dB = ((((unsigned)(sB-dB)*(unsigned)A)/255)+dB); \ |
448 dB = (Uint8)((((int)(sB-dB)*A)/255)+dB); \ |
449 } while(0) |
449 } while(0) |
450 |
450 |
451 |
451 |
452 /* Blend the RGBA values of two pixels */ |
452 /* Blend the RGBA values of two pixels */ |
453 #define ALPHA_BLEND_RGBA(sR, sG, sB, sA, dR, dG, dB, dA) \ |
453 #define ALPHA_BLEND_RGBA(sR, sG, sB, sA, dR, dG, dB, dA) \ |
454 do { \ |
454 do { \ |
455 dR = ((((unsigned)(sR-dR)*(unsigned)sA)/255)+dR); \ |
455 dR = (Uint8)((((int)(sR-dR)*sA)/255)+dR); \ |
456 dG = ((((unsigned)(sG-dG)*(unsigned)sA)/255)+dG); \ |
456 dG = (Uint8)((((int)(sG-dG)*sA)/255)+dG); \ |
457 dB = ((((unsigned)(sB-dB)*(unsigned)sA)/255)+dB); \ |
457 dB = (Uint8)((((int)(sB-dB)*sA)/255)+dB); \ |
458 dA = ((unsigned)sA+(unsigned)dA-((unsigned)sA*dA)/255); \ |
458 dA = (Uint8)((int)sA+dA-((int)sA*dA)/255); \ |
459 } while(0) |
459 } while(0) |
460 |
460 |
461 |
461 |
462 /* This is a very useful loop for optimizing blitters */ |
462 /* This is a very useful loop for optimizing blitters */ |
463 #if defined(_MSC_VER) && (_MSC_VER == 1300) |
463 #if defined(_MSC_VER) && (_MSC_VER == 1300) |