Here you can find the source of lerpAndPremultiplyColorWithAlpha(float t, int[] color1, int[] color2)
public static int lerpAndPremultiplyColorWithAlpha(float t, int[] color1, int[] color2)
//package com.java2s; /*/*from ww w . j av a 2 s . c om*/ * Copyright 2015 Laszlo Balazs-Csiki * * This file is part of Pixelitor. Pixelitor is free software: you * can redistribute it and/or modify it under the terms of the GNU * General Public License, version 3 as published by the Free * Software Foundation. * * Pixelitor 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Pixelitor. If not, see <http://www.gnu.org/licenses/>. */ public class Main { public static int lerpAndPremultiplyColorWithAlpha(float t, int[] color1, int[] color2) { int alpha = color1[0] + (int) (t * (color2[0] - color1[0])); int red; int green; int blue; if (alpha == 0) { red = 0; green = 0; blue = 0; } else { red = color1[1] + (int) (t * (color2[1] - color1[1])); green = color1[2] + (int) (t * (color2[2] - color1[2])); blue = color1[3] + (int) (t * (color2[3] - color1[3])); if (alpha != 255) { // premultiply float f = alpha / 255.0f; red *= f; green *= f; blue *= f; } } return (alpha << 24 | red << 16 | green << 8 | blue); } }