Java Code Examples for java.awt.image.BufferedImageOp#filter()
The following examples show how to use
java.awt.image.BufferedImageOp#filter() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OGLDrawImage.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Override public void transformImage(SunGraphics2D sg, BufferedImage img, BufferedImageOp op, int x, int y) { if (op != null) { if (op instanceof AffineTransformOp) { AffineTransformOp atop = (AffineTransformOp) op; transformImage(sg, img, x, y, atop.getTransform(), atop.getInterpolationType()); return; } else { if (OGLBufImgOps.renderImageWithOp(sg, img, op, x, y)) { return; } } img = op.filter(img, null); } copyImage(sg, img, x, y, null); }
Example 2
Source File: MainPanel.java From java-swing-tips with MIT License | 6 votes |
private static BufferedImage getFilteredImage(URL url) { BufferedImage image = Optional.ofNullable(url) .map(u -> { try { return ImageIO.read(u); } catch (IOException ex) { return makeMissingImage(); } }).orElseGet(MainPanel::makeMissingImage); BufferedImage dest = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_RGB); byte[] b = new byte[256]; for (int i = 0; i < b.length; i++) { b[i] = (byte) (i * .2f); } BufferedImageOp op = new LookupOp(new ByteLookupTable(0, b), null); op.filter(image, dest); return dest; }
Example 3
Source File: D3DDrawImage.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Override public void transformImage(SunGraphics2D sg, BufferedImage img, BufferedImageOp op, int x, int y) { if (op != null) { if (op instanceof AffineTransformOp) { AffineTransformOp atop = (AffineTransformOp) op; transformImage(sg, img, x, y, atop.getTransform(), atop.getInterpolationType()); return; } else { if (D3DBufImgOps.renderImageWithOp(sg, img, op, x, y)) { return; } } img = op.filter(img, null); } copyImage(sg, img, x, y, null); }
Example 4
Source File: PathGraphics.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Draws a BufferedImage that is filtered with a BufferedImageOp. * The rendering attributes applied include the clip, transform * and composite attributes. This is equivalent to: * <pre> * img1 = op.filter(img, null); * drawImage(img1, new AffineTransform(1f,0f,0f,1f,x,y), null); * </pre> * @param op The filter to be applied to the image before drawing. * @param img The BufferedImage to be drawn. * This method does nothing if <code>img</code> is null. * @param x,y The location in user space where the image should be drawn. * @see #transform * @see #setTransform * @see #setComposite * @see #clip * @see #setClip */ public void drawImage(BufferedImage img, BufferedImageOp op, int x, int y) { if (img == null) { return; } int srcWidth = img.getWidth(null); int srcHeight = img.getHeight(null); if (op != null) { img = op.filter(img, null); } if (srcWidth <= 0 || srcHeight <= 0) { return; } else { AffineTransform xform = new AffineTransform(1f,0f,0f,1f,x,y); drawImageToPlatform(img, xform, null, 0, 0, srcWidth, srcHeight, false); } }
Example 5
Source File: D3DDrawImage.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Override public void transformImage(SunGraphics2D sg, BufferedImage img, BufferedImageOp op, int x, int y) { if (op != null) { if (op instanceof AffineTransformOp) { AffineTransformOp atop = (AffineTransformOp) op; transformImage(sg, img, x, y, atop.getTransform(), atop.getInterpolationType()); return; } else { if (D3DBufImgOps.renderImageWithOp(sg, img, op, x, y)) { return; } } img = op.filter(img, null); } copyImage(sg, img, x, y, null); }
Example 6
Source File: D3DDrawImage.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@Override public void transformImage(SunGraphics2D sg, BufferedImage img, BufferedImageOp op, int x, int y) { if (op != null) { if (op instanceof AffineTransformOp) { AffineTransformOp atop = (AffineTransformOp) op; transformImage(sg, img, x, y, atop.getTransform(), atop.getInterpolationType()); return; } else { if (D3DBufImgOps.renderImageWithOp(sg, img, op, x, y)) { return; } } img = op.filter(img, null); } copyImage(sg, img, x, y, null); }
Example 7
Source File: SamePackingTypeTest.java From hottub with GNU General Public License v2.0 | 6 votes |
private static void doTest(BufferedImageOp op, int stype, int dtype) { final int size = 100; final BufferedImage src = new BufferedImage(size, size, stype); Graphics2D g = src.createGraphics(); g.setColor(Color.red); g.fillRect(0, 0, size, size); g.dispose(); final BufferedImage dst = new BufferedImage(size, size, dtype); g = dst.createGraphics(); g.setColor(Color.blue); g.fillRect(0, 0, size, size); g.dispose(); op.filter(src, dst); final int rgb = dst.getRGB(size - 1, size - 1); System.out.printf("dst: 0x%X ", rgb); if (rgb != 0xFFFF0000) { throw new RuntimeException(String.format("Wrong color in dst: 0x%X", rgb)); } }
Example 8
Source File: DrawImage.java From Bytecoder with Apache License 2.0 | 6 votes |
public void transformImage(SunGraphics2D sg, BufferedImage img, BufferedImageOp op, int x, int y) { if (op != null) { if (op instanceof AffineTransformOp) { AffineTransformOp atop = (AffineTransformOp) op; transformImage(sg, img, x, y, atop.getTransform(), atop.getInterpolationType()); return; } else { img = op.filter(img, null); } } copyImage(sg, img, x, y, null); }
Example 9
Source File: SamePackingTypeTest.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
private static void doTest(BufferedImageOp op, int stype, int dtype) { final int size = 100; final BufferedImage src = new BufferedImage(size, size, stype); Graphics2D g = src.createGraphics(); g.setColor(Color.red); g.fillRect(0, 0, size, size); g.dispose(); final BufferedImage dst = new BufferedImage(size, size, dtype); g = dst.createGraphics(); g.setColor(Color.blue); g.fillRect(0, 0, size, size); g.dispose(); op.filter(src, dst); final int rgb = dst.getRGB(size - 1, size - 1); System.out.printf("dst: 0x%X ", rgb); if (rgb != 0xFFFF0000) { throw new RuntimeException(String.format("Wrong color in dst: 0x%X", rgb)); } }
Example 10
Source File: DrawImage.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public void transformImage(SunGraphics2D sg, BufferedImage img, BufferedImageOp op, int x, int y) { if (op != null) { if (op instanceof AffineTransformOp) { AffineTransformOp atop = (AffineTransformOp) op; transformImage(sg, img, x, y, atop.getTransform(), atop.getInterpolationType()); return; } else { img = op.filter(img, null); } } copyImage(sg, img, x, y, null); }
Example 11
Source File: DrawImage.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public void transformImage(SunGraphics2D sg, BufferedImage img, BufferedImageOp op, int x, int y) { if (op != null) { if (op instanceof AffineTransformOp) { AffineTransformOp atop = (AffineTransformOp) op; transformImage(sg, img, x, y, atop.getTransform(), atop.getInterpolationType()); return; } else { img = op.filter(img, null); } } copyImage(sg, img, x, y, null); }
Example 12
Source File: PdfGraphics2D.java From itext2 with GNU Lesser General Public License v3.0 | 5 votes |
/** * @see Graphics2D#drawImage(BufferedImage, BufferedImageOp, int, int) */ public void drawImage(BufferedImage img, BufferedImageOp op, int x, int y) { BufferedImage result = img; if (op != null) { result = op.createCompatibleDestImage(img, img.getColorModel()); result = op.filter(img, result); } drawImage(result, x, y, null); }
Example 13
Source File: ImageProducer.java From development with Apache License 2.0 | 5 votes |
/** * @param bimage */ private static BufferedImage blurImage(final BufferedImage bimage) { float[] fs = new float[] { 1f / 9f, 1f / 9f, 1f / 9f, 1f / 9f, 1f / 9f, 1f / 9f, 1f / 9f, 1f / 9f, 1f / 9f }; final Kernel kernel = new Kernel(3, 3, fs); final BufferedImageOp op = new ConvolveOp(kernel); return op.filter(bimage, null); }
Example 14
Source File: AnimatedPanel.java From qmcflactomp3 with GNU General Public License v3.0 | 5 votes |
/** * Modifie la luminosit茅 de l'image. * * @param multiple Le taux de luminosit茅 */ private void setBrightness(float multiple) { float[] brightKernel = { multiple }; RenderingHints hints = new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); BufferedImageOp bright = new ConvolveOp(new Kernel(1, 1, brightKernel), ConvolveOp.EDGE_NO_OP, hints); bright.filter(originalImage, convolvedImage); repaint(); }
Example 15
Source File: ExtractChannel.java From Pixelitor with GNU General Public License v3.0 | 5 votes |
private static BufferedImage colorExtractChannel(BufferedImage src, BufferedImage dest, int channel) { LookupTable lookupTable; switch (channel) { case RED_CHANNEL: lookupTable = LookupFactory.createLookupForOnlyRed(); break; case REMOVE_RED_CHANNEL: lookupTable = LookupFactory.createLookupForRemoveRed(); break; case GREEN_CHANNEL: lookupTable = LookupFactory.createLookupForOnlyGreen(); break; case REMOVE_GREEN_CHANNEL: lookupTable = LookupFactory.createLookupForRemoveGreen(); break; case BLUE_CHANNEL: lookupTable = LookupFactory.createLookupForOnlyBlue(); break; case REMOVE_BLUE_CHANNEL: lookupTable = LookupFactory.createLookupForRemoveBlue(); break; default: throw new IllegalStateException("should not het here"); } BufferedImageOp filterOp = new FastLookupOp((ShortLookupTable) lookupTable); filterOp.filter(src, dest); return dest; }
Example 16
Source File: FilterPanelSeparator.java From jeveassets with GNU General Public License v2.0 | 5 votes |
public FilterPanelSeparator(int group) { this.group = group; jPanel = new JPanel(); GroupLayout layout = new GroupLayout(jPanel); jPanel.setLayout(layout); layout.setAutoCreateGaps(true); layout.setAutoCreateContainerGaps(false); BufferedImageOp lookup = new LookupOp(new ColorMapper(Color.WHITE, getColor("nimbusBlueGrey", "Separator.foreground")), null); BufferedImage convertedImage = lookup.filter((BufferedImage)Images.MISC_AND.getImage(), null); JLabel jIcon = new JLabel(new ImageIcon(convertedImage)); layout.setHorizontalGroup( layout.createSequentialGroup() .addGap(30) .addComponent(jIcon, 12, 12, 12) ); layout.setVerticalGroup( layout.createSequentialGroup() .addGap(1) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER) .addComponent(jIcon, 4, 4, 4) ) .addGap(1) ); }
Example 17
Source File: ImageProcessor.java From selenium-shutterbug with MIT License | 4 votes |
public static BufferedImage blur(BufferedImage sourceImage) { BufferedImageOp options = new ConvolveOp(new Kernel(7, 7, matrix), ConvolveOp.EDGE_NO_OP, null); return options.filter(sourceImage, null); }
Example 18
Source File: Filtering.java From jpexs-decompiler with GNU General Public License v3.0 | 4 votes |
public static SerializableImage convolution(SerializableImage src, float[] matrix, int w, int h) { BufferedImage dst = new BufferedImage(src.getWidth(), src.getHeight(), src.getType()); BufferedImageOp op = new ConvolveOp(new Kernel(w, h, matrix), ConvolveOp.EDGE_ZERO_FILL, new RenderingHints(null)); op.filter(src.getBufferedImage(), dst); return new SerializableImage(dst); }
Example 19
Source File: Img.java From java-tool with Apache License 2.0 | 4 votes |
@Override protected BufferedImage run() { BufferedImageOp op = new ConvolveOp(new Kernel(level, level, matrix), ConvolveOp.EDGE_NO_OP, null); target = op.filter(target, null); return target; }
Example 20
Source File: AbstractGraphics2D.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 2 votes |
/** * Renders a <code>BufferedImage</code> that is filtered with a {@link java.awt.image.BufferedImageOp}. The rendering * attributes applied include the <code>Clip</code>, <code>Transform</code> and <code>Composite</code> attributes. * This is equivalent to: * * <pre> * img1 = op.filter( img, null ); * drawImage( img1, new AffineTransform( 1f, 0f, 0f, 1f, x, y ), null ); * </pre> * * @param op * the filter to be applied to the image before rendering * @param img * the specified <code>BufferedImage</code> to be rendered. This method does nothing if <code>img</code> is * null. * @param x * the x coordinate of the location in user space where the upper left corner of the image is rendered * @param y * the y coordinate of the location in user space where the upper left corner of the image is rendered * @see #transform * @see #setTransform * @see #setComposite * @see #clip * @see #setClip */ public void drawImage( final BufferedImage img, final BufferedImageOp op, final int x, final int y ) { final BufferedImage filter = op.filter( img, null ); drawImage( filter, new AffineTransform( 1f, 0f, 0f, 1f, x, y ), null ); }