Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. uint32_t blue = 0, red = 0 , green = 0, alpha = 0, factor = 0 , shift = 0;
  2.  
  3. // some initial calculation to calculate factor shift and R G B init values all are expected to be initilized with 16 bit unsigned
  4.  
  5. //pSRC is 32 bbp flat pixel array and count is total pixels count
  6.  
  7. for( int i = 0; i < count; i++ )
  8. {
  9. blue += *psrc++;
  10. green += *psrc++;
  11. green += *psrc++;
  12. alpha += *psrc++;
  13.  
  14. *pDest++ = static_cast< uint_8 >( ( blue * factor ) >> shift );
  15. *pDest++ = static_cast< uint_8 >( ( green * factor ) >> shift );
  16. *pDest++ = static_cast< uint_8 >( ( red * factor ) >> shift );
  17. *pDest++ = static_cast< uint_8 >( ( alpha * factor ) >> shift );
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement