Java Color Create toColor(byte red, byte green, byte blue)

Here you can find the source of toColor(byte red, byte green, byte blue)

Description

Convert RGB color model to a Color object

License

Open Source License

Parameter

Parameter Description
red The red component (up to 255) of the color to convert
green The green component (up to 255) of the color to convert
blue The blue component (up to 255) of the color to convert

Return

The object for the color

Declaration

public static Color toColor(byte red, byte green, byte blue) 

Method Source Code


//package com.java2s;
/*//from w  w  w.  j  a  va 2s  .  co  m
 * ColorHelper.java
 *
 * Copyright (c) 2015 TheRoBrit
 *
 * Nucli is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Nucli 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 this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.awt.*;

public class Main {
    /**
     * Convert RGB color model to a {@link Color} object
     * @param red The red component (up to 255) of the color to convert
     * @param green The green component (up to 255) of the color to convert
     * @param blue The blue component (up to 255) of the color to convert
     * @return The {@link Color} object for the color
     */
    public static Color toColor(byte red, byte green, byte blue) {
        return new Color(red, green, blue);
    }

    /**
     * Convert integer to a {@link Color} object
     * @param color The integer representation of a color
     * @return The {@link Color} object for the color
     */
    public static Color toColor(int color) {
        return new Color(color);
    }
}

Related

  1. generateNextValidColor()
  2. generatePallete(final int colours)
  3. generateRGBRandomColor()
  4. generateTexturePaint(String text, Font font, Color textColor, Color bgColor, int width, int height)
  5. generateVisuallyDistinctColors(int ncolors, float minComponent, float maxComponent)
  6. toColor(byte[] bytes)
  7. toColor(final String hexColor)
  8. toColor(final String hexString)
  9. toColor(final String text, final Color defaultValue)