Vultraz

Untitled

Oct 15th, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. static void from_cairo_format(Uint32 & c)
  2. {
  3. #ifdef _WIN32
  4.     Uint8 r = (c >> 24) & 0xff;
  5.     Uint8 g = (c >> 16) & 0xff;
  6.     Uint8 b = (c >> 8) & 0xff;
  7.     Uint8 a = c & 0xff;
  8. #else
  9.     Uint8 a = (c >> 24) & 0xff;
  10.     Uint8 r = (c >> 16) & 0xff;
  11.     Uint8 g = (c >> 8) & 0xff;
  12.     Uint8 b = c & 0xff;
  13. #endif
  14.  
  15.     const unsigned div = inverse_table_[a];
  16.     unpremultiply(r, div);
  17.     unpremultiply(g, div);
  18.     unpremultiply(b, div);
  19.  
  20.     c = (static_cast<Uint32>(a) << 24) | (static_cast<Uint32>(r) << 16) | (static_cast<Uint32>(g) << 8) | static_cast<Uint32>(b);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment