/** * Gets the default red content of this colour. Used when writing the * default colour palette * * @return the red content of this colour * @deprecated use getDefaultRGB instead */ public int getDefaultRed() { return rgb.getRed(); }
/** * Gets the default red content of this colour. Used when writing the * default colour palette * * @return the red content of this colour * @deprecated use getDefaultRGB instead */ public int getDefaultRed() { return rgb.getRed(); }
protected static int rgbDistance(Color awtColor, RGB rgb) { int diff = Math.abs(rgb.getRed() - awtColor.getRed()) + Math.abs(rgb.getGreen() - awtColor.getGreen()) + Math.abs(rgb.getBlue() - awtColor.getBlue()); return diff; }
public static void dump() { Colour[] cols = getAllColours(); for (int i = 0; i < cols.length; i++) { RGB rgb = cols[i].getDefaultRGB(); System.out.println(i + ") " + rgb.getRed() + ", " + rgb.getGreen() + ", " + rgb.getBlue()); } }
private static Boolean compareColours(Colour col, int r, int g, int b) { RGB rgb = col.getDefaultRGB(); if ((rgb.getRed() == r) && (rgb.getGreen() == g) && (rgb.getBlue() == b)) return true; else return false; }
public int filterRGB(int x, int y, int rgb) { // int a = rgb & 0xff000000; for (RGB c : colorsToLookFor) { double colorDiff = colorDist((rgb >> 16) & 0xff, (rgb >> 8) & 0xff, rgb & 0xff, c.getRed(), c.getGreen(), c.getBlue()); if (colorDiff < threshold) { return 0; } } return 16777215; }
private static int getRGB(Colour c) { RGB defaultRGB = c.getDefaultRGB(); return defaultRGB.getRed() << 16 | defaultRGB.getGreen() << 8 | defaultRGB.getBlue(); }
/** * Accessor for the binary data - used when copying * * @return the binary data */ public byte[] getData() { // Palette was read in, but has not been changed if (read && !dirty) { return getRecord().getData(); } byte[] data = new byte[numColours * 4 + 2]; int pos = 0; // Set the number of records IntegerHelper.getTwoBytes(numColours, data, pos); // Set the rgb content for (int i = 0; i < numColours; i++) { pos = i * 4 + 2; data[pos] = (byte) rgbColours[i].getRed(); data[pos + 1] = (byte) rgbColours[i].getGreen(); data[pos + 2] = (byte) rgbColours[i].getBlue(); } return data; }
/** * Accessor for the binary data - used when copying * * @return the binary data */ public byte[] getData() { // Palette was read in, but has not been changed if (read && !dirty) { return getRecord().getData(); } byte[] data = new byte[numColours * 4 + 2]; int pos = 0; // Set the number of records IntegerHelper.getTwoBytes(numColours, data, pos); // Set the rgb content for (int i = 0; i < numColours; i++) { pos = i * 4 + 2; data[pos] = (byte) rgbColours[i].getRed(); data[pos + 1] = (byte) rgbColours[i].getGreen(); data[pos + 2] = (byte) rgbColours[i].getBlue(); } return data; }
/** * Default constructor - used when there is no palette specified */ public PaletteRecord() { super(Type.PALETTE); initialized = true; dirty = false; read = false; // Initialize the array with all the default colours Colour[] colours = Colour.getAllColours(); for (int i = 0; i < colours.length; i++) { Colour c = colours[i]; setColourRGB(c, c.getDefaultRGB().getRed(), c.getDefaultRGB().getGreen(), c.getDefaultRGB().getBlue()); } }
/** * Default constructor - used when there is no palette specified */ public PaletteRecord() { super(Type.PALETTE); initialized = true; dirty = false; read = false; // Initialize the array with all the default colours Colour[] colours = Colour.getAllColours(); for (int i = 0; i < colours.length; i++) { Colour c = colours[i]; setColourRGB(c, c.getDefaultRGB().getRed(), c.getDefaultRGB().getGreen(), c.getDefaultRGB().getBlue()); } }