Example usage for java.awt Color getBlue

List of usage examples for java.awt Color getBlue

Introduction

In this page you can find the example usage for java.awt Color getBlue.

Prototype

public int getBlue() 

Source Link

Document

Returns the blue component in the range 0-255 in the default sRGB space.

Usage

From source file:Main.java

public static void main(String[] args) {
    Color myColor = Color.RED;

    System.out.println(myColor.getBlue());

}

From source file:Main.java

public static void main(String[] args) throws Exception {
    BufferedImage inputFile = ImageIO.read(new URL("http://www.java2s.com/style/download.png"));

    for (int x = 0; x < inputFile.getWidth(); x++) {
        for (int y = 0; y < inputFile.getHeight(); y++) {
            int rgba = inputFile.getRGB(x, y);
            Color col = new Color(rgba, true);
            col = new Color(255 - col.getRed(), 255 - col.getGreen(), 255 - col.getBlue());
            inputFile.setRGB(x, y, col.getRGB());
        }//from   ww  w  .  j av a2 s  .  c o m
    }

    File outputFile = new File("invert.png");
    ImageIO.write(inputFile, "png", outputFile);

}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Robot robot = new Robot();

    Color color = robot.getPixelColor(20, 20);

    System.out.println("Red   = " + color.getRed());
    System.out.println("Green = " + color.getGreen());
    System.out.println("Blue  = " + color.getBlue());
}

From source file:ColorUtil.java

public static Color makeTransparent(Color source, int alpha) {
    return new Color(source.getRed(), source.getGreen(), source.getBlue(), alpha);
}

From source file:ColorUtils.java

/**
 * Performs a somewhat subjective analysis of a color to determine how dark it looks to a user
 * /* w  ww .j a v a 2 s.c o m*/
 * @param color The color to analyze
 * @return The darkness of the color
 */
public static float getDarkness(Color color) {
    float ret = color.getRed() + color.getGreen() + color.getBlue() / 10;
    ret /= (255 + 255 + 255 / 10);
    ret = 1 - ret;
    final float lightDarkBorder = 0.7f;
    if (ret > lightDarkBorder)
        ret = 0.5f + (ret - lightDarkBorder) * 0.5f / (1 - lightDarkBorder);
    else
        ret = ret * 0.5f / lightDarkBorder;
    return ret;
}

From source file:Main.java

public static Color darken(Color c, float fr, float fg, float fb) {
    int r = c.getRed(), g = c.getGreen(), b = c.getBlue();
    return darken(c, (int) (r * (1f - fr)), (int) (g * (1f - fg)), (int) (b * (1f - fb)));
}

From source file:GuiUtil.java

public static Color cloneColor(Color c) {
    return new Color(c.getRed(), c.getGreen(), c.getBlue());
}

From source file:Main.java

public static Color darken(Color c, int r, int g, int b) {
    int or = c.getRed(), og = c.getGreen(), ob = c.getBlue();
    or -= r;/* www .j  av  a 2 s.  com*/
    og -= g;
    ob -= b;
    or = or < 0 ? 0 : or;
    or = or > 255 ? 255 : or;
    og = og < 0 ? 0 : og;
    og = og > 255 ? 255 : og;
    ob = ob < 0 ? 0 : ob;
    ob = ob > 255 ? 255 : ob;
    return new Color(or, og, ob);
}

From source file:ColorUtil.java

public static boolean isDark(Color c) {
    return c.getRed() + c.getGreen() + c.getBlue() < 3 * 180;
}

From source file:Main.java

public static Color shiftHue(Color color) {
    float[] hsl = new float[3];
    Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsl);

    hsl[0] += 0.33f % 1.0f;// w  w w.  j  av  a  2s .  c o m
    return Color.getHSBColor(hsl[0], hsl[1], hsl[2]);
}