public Rect (BufferedImage source, int left, int top, int newWidth, int newHeight, boolean isPatch) { image = new BufferedImage(source.getColorModel(), source.getRaster().createWritableChild(left, top, newWidth, newHeight, 0, 0, null), source.getColorModel().isAlphaPremultiplied(), null); offsetX = left; offsetY = top; regionWidth = newWidth; regionHeight = newHeight; originalWidth = source.getWidth(); originalHeight = source.getHeight(); width = newWidth; height = newHeight; this.isPatch = isPatch; }
private void drawHLine(BufferedImage im, int y, int x1, int x2) { for (int x = x1; x <= x2; x++) { im.setRGB(x, y, NP_COLOR); } }
private static BufferedImage createImage (int width, int height, Color color) { BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR); Graphics2D g = image.createGraphics(); g.setColor(color); g.fillRect(0, 0, width, height); g.dispose(); return image; } }
public void draw (BufferedImage image, Graphics2D g, UnicodeFont unicodeFont, Glyph glyph) { BufferedImage scratchImage = EffectUtil.getScratchImage(); filter.filter(image, scratchImage); image.getGraphics().drawImage(scratchImage, 0, 0, null); }
/** Returns an image that can be used by effects as a temp image. */ static public BufferedImage getScratchImage () { Graphics2D g = (Graphics2D)scratchImage.getGraphics(); g.setComposite(AlphaComposite.Clear); g.fillRect(0, 0, GlyphPage.MAX_GLYPH_SIZE, GlyphPage.MAX_GLYPH_SIZE); g.setComposite(AlphaComposite.SrcOver); g.setColor(java.awt.Color.white); return scratchImage; }
static private void copy (BufferedImage src, int x, int y, int w, int h, BufferedImage dst, int dx, int dy, boolean rotated) { if (rotated) { for (int i = 0; i < w; i++) for (int j = 0; j < h; j++) plot(dst, dx + j, dy + w - i - 1, src.getRGB(x + i, y + j)); } else { for (int i = 0; i < w; i++) for (int j = 0; j < h; j++) plot(dst, dx + i, dy + j, src.getRGB(x + i, y + j)); } }
private void blur (BufferedImage image) { float[] matrix = GAUSSIAN_BLUR_KERNELS[blurKernelSize - 1]; Kernel gaussianBlur1 = new Kernel(matrix.length, 1, matrix); Kernel gaussianBlur2 = new Kernel(1, matrix.length, matrix); RenderingHints hints = new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED); ConvolveOp gaussianOp1 = new ConvolveOp(gaussianBlur1, ConvolveOp.EDGE_NO_OP, hints); ConvolveOp gaussianOp2 = new ConvolveOp(gaussianBlur2, ConvolveOp.EDGE_NO_OP, hints); BufferedImage scratchImage = EffectUtil.getScratchImage(); for (int i = 0; i < blurPasses; i++) { gaussianOp1.filter(image, scratchImage); gaussianOp2.filter(scratchImage, image); } }
public Rect (BufferedImage source, int left, int top, int newWidth, int newHeight, boolean isPatch) { image = new BufferedImage(source.getColorModel(), source.getRaster().createWritableChild(left, top, newWidth, newHeight, 0, 0, null), source.getColorModel().isAlphaPremultiplied(), null); offsetX = left; offsetY = top; regionWidth = newWidth; regionHeight = newHeight; originalWidth = source.getWidth(); originalHeight = source.getHeight(); width = newWidth; height = newHeight; this.isPatch = isPatch; }
private static BufferedImage createImage (int width, int height, Color color) { BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR); Graphics2D g = image.createGraphics(); g.setColor(color); g.fillRect(0, 0, width, height); g.dispose(); return image; } }
public void draw (BufferedImage image, Graphics2D g, UnicodeFont unicodeFont, Glyph glyph) { BufferedImage scratchImage = EffectUtil.getScratchImage(); filter.filter(image, scratchImage); image.getGraphics().drawImage(scratchImage, 0, 0, null); }
/** Returns an image that can be used by effects as a temp image. */ static public BufferedImage getScratchImage () { Graphics2D g = (Graphics2D)scratchImage.getGraphics(); g.setComposite(AlphaComposite.Clear); g.fillRect(0, 0, GlyphPage.MAX_GLYPH_SIZE, GlyphPage.MAX_GLYPH_SIZE); g.setComposite(AlphaComposite.SrcOver); g.setColor(java.awt.Color.white); return scratchImage; }
private void drawVLine(BufferedImage im, int x, int y1, int y2) { for (int y = y1; y <= y2; y++) { im.setRGB(x, y, NP_COLOR); } }
private void blur (BufferedImage image) { float[] matrix = GAUSSIAN_BLUR_KERNELS[blurKernelSize - 1]; Kernel gaussianBlur1 = new Kernel(matrix.length, 1, matrix); Kernel gaussianBlur2 = new Kernel(1, matrix.length, matrix); RenderingHints hints = new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED); ConvolveOp gaussianOp1 = new ConvolveOp(gaussianBlur1, ConvolveOp.EDGE_NO_OP, hints); ConvolveOp gaussianOp2 = new ConvolveOp(gaussianBlur2, ConvolveOp.EDGE_NO_OP, hints); BufferedImage scratchImage = EffectUtil.getScratchImage(); for (int i = 0; i < blurPasses; i++) { gaussianOp1.filter(image, scratchImage); gaussianOp2.filter(scratchImage, image); } }
private void drawHLine(BufferedImage im, int y, int x1, int x2) { for (int x = x1; x <= x2; x++) { im.setRGB(x, y, NP_COLOR); } }
private void drawVLine(BufferedImage im, int x, int y1, int y2) { for (int y = y1; y <= y2; y++) { im.setRGB(x, y, NP_COLOR); } }