List of usage examples for java.awt Color getBlue
public int getBlue()
From source file:cn.z.Ocr5.java
public static int getColorBright(int colorInt) { Color color = new Color(colorInt); return color.getRed() + color.getGreen() + color.getBlue(); }
From source file:com.lingxiang2014.util.ImageUtils.java
private static String toHexEncoding(Color color) { String R, G, B;// w w w .j a va 2 s.com StringBuffer stringBuffer = new StringBuffer(); R = Integer.toHexString(color.getRed()); G = Integer.toHexString(color.getGreen()); B = Integer.toHexString(color.getBlue()); R = R.length() == 1 ? "0" + R : R; G = G.length() == 1 ? "0" + G : G; B = B.length() == 1 ? "0" + B : B; stringBuffer.append("#"); stringBuffer.append(R); stringBuffer.append(G); stringBuffer.append(B); return stringBuffer.toString(); }
From source file:cn.z.Ocr5.java
public static int isBlack(int colorInt, int blackThreshold) { final Color color = new Color(colorInt); if (color.getRed() + color.getGreen() + color.getBlue() <= blackThreshold) { return 1; }//from w w w. j a v a2 s . c o m return 0; }
From source file:cn.z.Ocr5.java
public static int isWhite(int colorInt, int whiteThreshold) { final Color color = new Color(colorInt); if (color.getRed() + color.getGreen() + color.getBlue() > whiteThreshold) { return 1; }//w w w . j av a2 s.co m return 0; }
From source file:imageprocessingproject.ImageHistogram.java
public static BufferedImage autoContrastImage(BufferedImage image) { createContrastLUT(image);/*from w w w . j a v a2 s. c om*/ int height = image.getHeight(); int width = image.getWidth(); int r, g, b; Color c; BufferedImage tempImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { c = new Color(image.getRGB(i, j)); r = (int) (255 * contrast_lut[c.getRed()]); g = (int) (255 * contrast_lut[c.getGreen()]); b = (int) (255 * contrast_lut[c.getBlue()]); tempImage.setRGB(i, j, new Color(r, g, b, c.getAlpha()).getRGB()); } } return tempImage; }
From source file:lu.lippmann.cdb.graph.renderer.CadralEdgeColorTransformer.java
private static Color rangeColor(Color colorMin, Color colorMax, BigDecimal grow, BigDecimal minValue, BigDecimal maxValue) {/* w w w . j a v a2 s.c o m*/ BigDecimal colorValue = grow; if (colorValue == null) { return Color.LIGHT_GRAY; } if (maxValue.compareTo(minValue) < 0) { return rangeColor(colorMin, colorMax, grow, maxValue, minValue); } else { int rMax = colorMax.getRed(); int gMax = colorMax.getGreen(); int bMax = colorMax.getBlue(); double color = 0.0; color = 255.0 - grow.subtract(minValue).doubleValue() * 255.0 / maxValue.subtract(minValue).doubleValue(); int r = rMax + (int) ((255 - rMax) * color / 255.0); int g = gMax + (int) ((255 - gMax) * color / 255.0); int b = bMax + (int) ((255 - bMax) * color / 255.0); if (r > 192 && g > 192 && b > 192) return Color.LIGHT_GRAY; return new Color(r, g, b); } }
From source file:org.polymap.rhei.batik.engine.svg.Svg2Png.java
private static float[] getHsb(ImageConfiguration imageConfiguration, Color color) { float[] hsb = new float[3]; if (imageConfiguration.isInvert()) { Color.RGBtoHSB(255 - color.getRed(), 255 - color.getGreen(), 255 - color.getBlue(), hsb); } else {/* w w w. j av a 2s .com*/ Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsb); } return hsb; }
From source file:fxts.stations.util.UserPreferences.java
public static String getStringValue(Color aValue) { return aValue.getRed() + "," + aValue.getGreen() + "," + aValue.getBlue(); }
From source file:ala.soils2sat.DrawingUtils.java
public static List<Color> generatePalette(int size, Color baseColor) { float[] hsb = { 0, 0, 0 }; Color.RGBtoHSB(baseColor.getRed(), baseColor.getGreen(), baseColor.getBlue(), hsb); double baseHue = hsb[0]; List<Color> colors = new ArrayList<Color>(); colors.add(baseColor);//from ww w .j a v a 2s. co m double step = (240.0 / (double) size); for (int i = 1; i < size; ++i) { float hue = (float) ((baseHue + step * ((double) i)) % 240.0); // this gives a number out of 240. need to scale that to percent hue = hue / 240; Color nextColor = Color.getHSBColor(hue, hsb[1], hsb[2]); colors.add(nextColor); } return colors; }
From source file:com.igormaznitsa.jhexed.swing.editor.ui.Utils.java
public static String color2html(final Color c, final boolean alpha) { final String ac = Integer.toHexString(c.getAlpha()).toUpperCase(Locale.ENGLISH); final String rc = Integer.toHexString(c.getRed()).toUpperCase(Locale.ENGLISH); final String gc = Integer.toHexString(c.getGreen()).toUpperCase(Locale.ENGLISH); final String bc = Integer.toHexString(c.getBlue()).toUpperCase(Locale.ENGLISH); final StringBuilder result = new StringBuilder(7); result.append('#'); if (alpha) {/*from www. j a v a2s.c om*/ if (ac.length() == 1) { result.append('0'); } result.append(ac); } if (rc.length() == 1) { result.append('0'); } result.append(rc); if (gc.length() == 1) { result.append('0'); } result.append(gc); if (bc.length() == 1) { result.append('0'); } result.append(bc); return result.toString(); }