Java BufferedImage Operation tile(BufferedImage source, Rectangle r, GraphicsConfiguration conf)

Here you can find the source of tile(BufferedImage source, Rectangle r, GraphicsConfiguration conf)

Description

Cut out a rectangular section of the target image and create a GraphicsConfiguration -compatible (but not volatile) copy.

License

Open Source License

Declaration

public static BufferedImage tile(BufferedImage source, Rectangle r, GraphicsConfiguration conf)
        throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;

public class Main {
    /**/*from w ww .  j  av  a2 s.  c om*/
     * Cut out a rectangular section of the target image and create a
     * {@link GraphicsConfiguration}-compatible (but not volatile) copy.
     */
    public static BufferedImage tile(BufferedImage source, Rectangle r, GraphicsConfiguration conf)
            throws IOException {
        final BufferedImage sub = source.getSubimage(r.x, r.y, r.width, r.height);
        final BufferedImage tile = conf.createCompatibleImage(r.width, r.height, Transparency.BITMASK);

        final Graphics2D g = (Graphics2D) tile.getGraphics();
        g.drawImage(sub, null, 0, 0);
        g.dispose();

        return tile;
    }
}

Related

  1. switchAxes(BufferedImage img)
  2. symmetrifyY(BufferedImage image, boolean useFirstHalfImage, boolean flipVertical)
  3. testNeighbours(BufferedImage source, int x, int y, boolean alpha)
  4. texture2D(BufferedImage normalMap, int x, int y)
  5. thresholdImage(BufferedImage image, int threshold)
  6. tileStretchPaint(Graphics g, Component component, BufferedImage image, Insets insets)
  7. tilt(BufferedImage image, double angle)
  8. tintImage(BufferedImage src, Color color, float tintOpacity)
  9. unweaveFrom(BufferedImage bufferedImage)