Here you can find the source of blendAlpha(Color under, Color over)
public static Color blendAlpha(Color under, Color over)
//package com.java2s; /*/*from w w w .j ava2 s . c o m*/ * This code is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This code is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this program; if not, write to the Free * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. */ import java.awt.Color; public class Main { public static Color blendAlpha(Color under, Color over) { float rgb1[] = new float[3]; float rgb2[] = new float[3]; under.getColorComponents(rgb1); over.getColorComponents(rgb2); int ualpha = under.getAlpha(); int oalpha = over.getAlpha(); float u = ualpha / 255f; float o = oalpha / 255f; u *= u * o; Color color = new Color(rgb1[0] * u + rgb2[0] * o, rgb1[1] * u + rgb2[1] * o, rgb1[2] * u + rgb2[2] * o); return color; } }