Java Color Convert To colorToFloat(int color)

Here you can find the source of colorToFloat(int color)

Description

color To Float

License

Open Source License

Declaration

public static float[] colorToFloat(int color) 

Method Source Code

//package com.java2s;
/*//from ww  w . j av a 2s .co m
 * Copyright 2013 Hannes Janetzek
 * Copyright 2016 devemux86
 *
 * This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
 *
 * This program 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 3 of the License, or (at your option) any later version.
 *
 * This program 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, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    public static float[] colorToFloat(int color) {
        float[] c = new float[4];
        c[3] = (color >> 24 & 0xff) / 255.0f;
        c[0] = (color >> 16 & 0xff) / 255.0f;
        c[1] = (color >> 8 & 0xff) / 255.0f;
        c[2] = (color >> 0 & 0xff) / 255.0f;
        return c;
    }
}

Related

  1. colorToHex(int color)
  2. colorToHex(int integer)
  3. colorToRGB(final int alpha, final int red, final int green, final int blue)
  4. colorToString(int color, boolean rgb)