public int filterRGB (int x, int y, int rgb) { int a = (rgb & 0xFF000000); int r = (rgb & 0x00FF0000) >>> 16; int g = (rgb & 0x0000FF00) >>> 8; int b = (rgb & 0x000000FF); int Y = (int)(Yr * r + Yg * g + Yb * b) % 256; if (Y > 255) { Y = 255; } Color foregroundColor = ((J2SEDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getForegroundColor(); r = (int) (Rr * Y) + foregroundColor.getRed(); g = (int) (Rg * Y) + foregroundColor.getGreen(); b = (int) (Rb * Y) + foregroundColor.getBlue(); return a | (r << 16) | (g << 8) | b; }
public int filterRGB (int x, int y, int rgb) { int a = (rgb & 0xFF000000); int r = (rgb & 0x00FF0000) >>> 16; int g = (rgb & 0x0000FF00) >>> 8; int b = (rgb & 0x000000FF); int Y = (int)(Yr * r + Yg * g + Yb * b); if (Y > 127) { return a | ((J2SEDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getBackgroundColor().getRGB(); } else { return a | ((J2SEDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getForegroundColor().getRGB(); } }
public RGBImageFilter() { canFilterIndexColorModel = true; backgroundColor = ((J2SEDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getBackgroundColor(); foregroundColor = ((J2SEDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getForegroundColor(); Rr = foregroundColor.getRed() - backgroundColor.getRed(); Rg = foregroundColor.getGreen() - backgroundColor.getGreen(); Rb = foregroundColor.getBlue() - backgroundColor.getBlue(); }
public GrayImageFilter (double Yr, double Yg, double Yb) { this.Yr = Yr; this.Yg = Yg; this.Yb = Yb; canFilterIndexColorModel = true; Color backgroundColor = ((J2SEDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getBackgroundColor(); Color foregroundColor = ((J2SEDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getForegroundColor(); Rr = (backgroundColor.getRed() - foregroundColor.getRed()) / 256d; Rg = (backgroundColor.getGreen() - foregroundColor.getGreen()) / 256d; Rb = (backgroundColor.getBlue() - foregroundColor.getBlue()) / 256d; }