Java tutorial
//package com.java2s; import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Composite; public class Main { public static double getAlpha(Color color, Composite composite) { int trans = color.getTransparency(); if ((trans == Color.TRANSLUCENT || trans == Color.BITMASK)) { return color.getAlpha() / 255d; } if (composite instanceof AlphaComposite) { AlphaComposite ac = (AlphaComposite) composite; return ac.getAlpha(); } return 1d; } }