Java Color Multiply multiply(double color1, double color2)

Here you can find the source of multiply(double color1, double color2)

Description

multiply

License

Open Source License

Declaration

static double multiply(double color1, double color2) 

Method Source Code

//package com.java2s;
/**/*  w ww.  ja  va 2 s.c o m*/
 * MIT License (MIT)
 *
 * Copyright (c) 2014 Volker Berlin
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * UT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * @author Volker Berlin
 * @license: The MIT license <http://opensource.org/licenses/MIT>
 */

public class Main {
    static double multiply(double color1, double color2) {
        long argb1 = Double.doubleToRawLongBits(color1);
        long r1 = ((argb1 >> 32) & 0xFFFF);
        long g1 = ((argb1 >> 16) & 0xFFFF);
        long b1 = ((argb1) & 0xFFFF);

        long argb2 = Double.doubleToRawLongBits(color2);
        long r2 = ((argb2 >> 32) & 0xFFFF);
        long g2 = ((argb2 >> 16) & 0xFFFF);
        long b2 = ((argb2) & 0xFFFF);

        argb1 = ((r1 * r2) / 0xFF00) << 32 | ((g1 * g2) / 0xFF00) << 16 | ((b1 * b2) / 0xFF00);

        return Double.longBitsToDouble(argb1);
    }
}

Related

  1. multiply(int colorA, int colorB)
  2. multiplyColor(int p_180188_0_, int p_180188_1_)
  3. multiplyColor(int src, int dst)
  4. multiplyColorComponents(int color, float brightnessFactor)