Skip to content

Instantly share code, notes, and snippets.

@TobleMiner
Created January 13, 2016 19:16
Show Gist options
  • Save TobleMiner/7b53cfc5aae7082260fb to your computer and use it in GitHub Desktop.
Save TobleMiner/7b53cfc5aae7082260fb to your computer and use it in GitHub Desktop.
ARGB to RGB blend
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