@Nonnull @Override protected Object[] stringValues() { return new Object[] { hashCode() }; }
@Nonnull public java.awt.Color getAwtColor() { return cachedAwtColor != null ? cachedAwtColor : (cachedAwtColor = new java.awt.Color(hashCode(), true)); }
@Nonnull public String toHash() { return String.format("%08X", hashCode()); }
@Nonnull public ImageProcessor setPixel(int x, int y, @Nonnull Color color) { return setPixel(x, y, color.hashCode()); }
@Override public void applyFilter(@Nonnull BufferedImage image, @Nonnull FilterMask mask) { int remove = isBackgroundAutomaticallyDetected() ? image.getRGB(0, 0) : getBackground().hashCode(); int width = image.getWidth(); int height = image.getHeight(); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { int rgb = image.getRGB(x, y); if (mask.accepts(x, y) && (rgb | 0xFF000000) == remove) { image.setRGB(x, y, 0x00FFFFFF & rgb); } } } }
@Nonnull public static Color createCached(@Nonnull Color mainColor, int alpha) { int hash = mainColor.hashCode(); if (mapping.containsKey(hash)) { Color[] array = mapping.get((Integer) hash); if (array[alpha] != null) { return array[alpha]; } Color newColor = createDirect(mainColor, alpha); array[alpha] = newColor; return newColor; } Color color = createDirect(mainColor, alpha); Color[] array = new Color[256]; array[alpha] = color; mapping.add(hash, array); return color; }
@Override public void applyFilter(@Nonnull BufferedImage image, @Nonnull FilterMask mask) { Color[] grayMatrix = new Color[256]; int width = image.getWidth(); int height = image.getHeight(); int[][] luminance = new int[width][height]; for (int i = 0; i < grayMatrix.length; i++) { grayMatrix[i] = new Color(i, i, i); } for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { if (mask.accepts(x, y)) { int pixel = image.getRGB(x, y); int red = pixel >> 16 & 0xFF; int green = pixel >> 8 & 0xFF; int blue = pixel & 0xFF; luminance[x][y] = (int) (getRedLuminance() * red + getGreenLuminance() * green + getBlueLuminance() * blue); } } } for (int y = 1; y < height - 1; y++) { for (int x = 1; x < width - 1; x++) { if (mask.accepts(x, y)) { int grayY = luminance[x - 1][y - 1] + 2 * luminance[x - 1][y] + luminance[x - 1][y + 1] - luminance[x + 1][y - 1] - 2 * luminance[x + 1][y] - luminance[x + 1][y + 1]; int magnitude = 255 - ImageWorker.truncate(Math.abs(grayY)); image.setRGB(x, y, grayMatrix[magnitude].hashCode()); } } } }
int pixel = image.pixelAt(x, y).hashCode();
for (int x = 0; x < image.getWidth(); x++) { for (int y = 0; y < image.getHeight(); y++) { int pixel = image.pixelAt(x, y).hashCode();