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); if (Rr > 0) { r = (int) (r * Rr) / 255 + backgroundColor.getRed(); } else { r = (int) (r * -Rr) / 255 + foregroundColor.getRed(); } if (Rr > 0) { g = (int) (g * Rg) / 255 + backgroundColor.getGreen(); } else { g = (int) (g * -Rg) / 255 + foregroundColor.getGreen(); } if (Rr > 0) { b = (int) (b * Rb) / 255 + backgroundColor.getBlue(); } else { b = (int) (b * -Rb) / 255 + foregroundColor.getBlue(); } return a | (r << 16) | (g << 8) | b; }
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 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 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; }
public BWImageFilter (double Yr, double Yg, double Yb) { this.Yr = Yr; this.Yg = Yg; this.Yb = Yb; backgroundColor = SwtDeviceComponent.getColor(new RGB( ((SwtDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getBackgroundColor().getRed(), ((SwtDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getBackgroundColor().getGreen(), ((SwtDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getBackgroundColor().getBlue())); foregroundColor = SwtDeviceComponent.getColor(new RGB( ((SwtDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getForegroundColor().getRed(), ((SwtDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getForegroundColor().getGreen(), ((SwtDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getForegroundColor().getBlue())); }
public RGBImageFilter() { backgroundColor = SwtDeviceComponent.getColor(new RGB( ((SwtDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getBackgroundColor().getRed(), ((SwtDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getBackgroundColor().getGreen(), ((SwtDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getBackgroundColor().getBlue())); foregroundColor = SwtDeviceComponent.getColor(new RGB( ((SwtDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getForegroundColor().getRed(), ((SwtDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getForegroundColor().getGreen(), ((SwtDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getForegroundColor().getBlue())); 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; Color backgroundColor = SwtDeviceComponent.getColor(new RGB( ((SwtDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getBackgroundColor().getRed(), ((SwtDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getBackgroundColor().getGreen(), ((SwtDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getBackgroundColor().getBlue())); foregroundColor = SwtDeviceComponent.getColor(new RGB( ((SwtDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getForegroundColor().getRed(), ((SwtDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getForegroundColor().getGreen(), ((SwtDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getForegroundColor().getBlue())); Rr = (backgroundColor.getRed() - foregroundColor.getRed()) / 256d; Rg = (backgroundColor.getGreen() - foregroundColor.getGreen()) / 256d; Rb = (backgroundColor.getBlue() - foregroundColor.getBlue()) / 256d; }
g.setForeground(g.getColor(new RGB(deviceDisplay .getForegroundColor().getRed(), deviceDisplay .getForegroundColor().getGreen(), deviceDisplay .getForegroundColor().getBlue()))); } else { g.setBackground(g.getColor(new RGB(deviceDisplay .getBackgroundColor().getRed(), deviceDisplay .getBackgroundColor().getGreen(), deviceDisplay .getBackgroundColor().getBlue()))); g.setBackground(g.getColor(new RGB(deviceDisplay .getBackgroundColor().getRed(), deviceDisplay .getBackgroundColor().getGreen(), deviceDisplay .getBackgroundColor().getBlue()))); } else { g.setForeground(g.getColor(new RGB(deviceDisplay .getForegroundColor().getRed(), deviceDisplay .getForegroundColor().getGreen(), deviceDisplay .getForegroundColor().getBlue())));
public SwtDisplayGraphics(SwtGraphics a_g, MutableImage a_image) { this.g = a_g; this.image = a_image; Device device = DeviceFactory.getDevice(); this.g.setBackground(g.getColor(new RGB( ((SwtDeviceDisplay) device.getDeviceDisplay()).getBackgroundColor().getRed(), ((SwtDeviceDisplay) device.getDeviceDisplay()).getBackgroundColor().getGreen(), ((SwtDeviceDisplay) device.getDeviceDisplay()).getBackgroundColor().getBlue()))); SwtFont tmpFont = (SwtFont) ((SwtFontManager) device.getFontManager()).getFont(currentFont); this.g.setFont(tmpFont.getFont()); if (device.getDeviceDisplay().isColor()) { this.filter = new RGBImageFilter(); } else { if (device.getDeviceDisplay().numColors() == 2) { this.filter = new BWImageFilter(); } else { this.filter = new GrayImageFilter(); } } }
foregroundColor.getGreen(), foregroundColor.getBlue())));