Created
January 13, 2016 19:16
-
-
Save TobleMiner/7b53cfc5aae7082260fb to your computer and use it in GitHub Desktop.
ARGB to RGB blend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int convertARGBtoRGB(int argbValue) | |
{ | |
int rgb = 0; | |
// Extract bit 24 - 31 and discard sign (& 0xFF) | |
double alpha = ((argbValue >> 24) & 0xFF) / 255d; | |
for(int i = 0; i <= 16; i += 8) | |
{ | |
// Extract color channel | |
int channel = argbValue >> i & 0xFF; | |
// Blend channel | |
channel = (int) (channel * alpha + 255 * (1 - alpha)); | |
// Store result | |
rgb |= channel << i; | |
} | |
return rgb; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment