RGB versus RGBa
1 posts in topic
Flat View  Flat View

Posted By:   David_Woosley
Posted On:   Tuesday, January 24, 2006 10:27 AM

If I create a non-opaque color with (R,G,B,A), how do I obtain the opaque equivalent? For this project, I start with a master color and then need to print the RGB equivalents of that master color with alpha of 25%, 50% and 75% as they would appear against a WHITE background. No images are involved. I simply need a method to calculate the new alpha-simulated RGB values.

Re: RGB versus RGBa

Posted By:   Almagest_FUTT  
Posted On:   Tuesday, January 24, 2006 11:03 AM

Is that of help ?

public static Color getAlphaEquivalent(Color c, int alpha){
assert alpha >= 0 && alpha <= 0xff;

return new Color(alpha << 24 | c.getRGB() & 0xffffff);

public static Color getOpaqueEquivalent(Color c){
return c.getAlpha() == 0xff ? c : new Color( c.getRGB() & 0xffffff );
About | Sitemap | Contact