Java Color Multiply multiply(int colorA, int colorB)

Here you can find the source of multiply(int colorA, int colorB)

Description

multiply

License

Open Source License

Declaration

public static int multiply(int colorA, int colorB) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static int multiply(int colorA, int colorB) {
        return makeColor(getAlphaF(colorA), getRedF(colorA) * getRedF(colorB),
                getGreenF(colorA) * getGreenF(colorB), getBlueF(colorA) * getBlueF(colorB));
    }/*  w w  w . ja va  2 s  .  co  m*/

    public static int makeColor(float alpha, float red, float green, float blue) {
        return ((int) (alpha * 255) << 24) | ((int) (red * 255) << 16) | ((int) (green * 255) << 8)
                | (int) (blue * 255);
    }

    public static float getAlphaF(int col) {
        return (float) ((col & 0xff000000) >> 24) / 255;
    }

    public static float getRedF(int col) {
        return (float) ((col & 0x00ff0000) >> 16) / 255;
    }

    public static float getGreenF(int col) {
        return (float) ((col & 0x0000ff00) >> 8) / 255;
    }

    public static float getBlueF(int col) {
        return (float) (col & 0x000000ff) / 255;
    }
}

Related

  1. multiply(double color1, double color2)
  2. multiplyColor(int p_180188_0_, int p_180188_1_)
  3. multiplyColor(int src, int dst)
  4. multiplyColorComponents(int color, float brightnessFactor)