Java BufferedImage Split tileStretchPaint(Graphics g, JComponent comp, BufferedImage img, Insets ins)

Here you can find the source of tileStretchPaint(Graphics g, JComponent comp, BufferedImage img, Insets ins)

Description

tile Stretch Paint

License

LGPL

Declaration

public static void tileStretchPaint(Graphics g, JComponent comp, BufferedImage img, Insets ins) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.awt.Graphics;

import java.awt.Insets;

import java.awt.image.BufferedImage;

import javax.swing.JComponent;

public class Main {
    public static void tileStretchPaint(Graphics g, JComponent comp, BufferedImage img, Insets ins) {
        int left = ins.left;
        int right = ins.right;
        int top = ins.top;
        int bottom = ins.bottom;

        g.drawImage(img, 0, 0, left, top, 0, 0, left, top, null);
        g.drawImage(img, left, 0, comp.getWidth() - right, top, left, 0, img.getWidth() - right, top, null);
        g.drawImage(img, comp.getWidth() - right, 0, comp.getWidth(), top, img.getWidth() - right, 0,
                img.getWidth(), top, null);
        g.drawImage(img, 0, top, left, comp.getHeight() - bottom, 0, top, left, img.getHeight() - bottom, null);
        g.drawImage(img, left, top, comp.getWidth() - right, comp.getHeight() - bottom, left, top,
                img.getWidth() - right, img.getHeight() - bottom, null);
        g.drawImage(img, comp.getWidth() - right, top, comp.getWidth(), comp.getHeight() - bottom,
                img.getWidth() - right, top, img.getWidth(), img.getHeight() - bottom, null);
        g.drawImage(img, 0, comp.getHeight() - bottom, left, comp.getHeight(), 0, img.getHeight() - bottom, left,
                img.getHeight(), null);//  ww  w. j  av a 2s.  com
        g.drawImage(img, left, comp.getHeight() - bottom, comp.getWidth() - right, comp.getHeight(), left,
                img.getHeight() - bottom, img.getWidth() - right, img.getHeight(), null);
        g.drawImage(img, comp.getWidth() - right, comp.getHeight() - bottom, comp.getWidth(), comp.getHeight(),
                img.getWidth() - right, img.getHeight() - bottom, img.getWidth(), img.getHeight(), null);
    }
}

Related

  1. splitImage(BufferedImage img, int rows, int cols)
  2. splitImage(final Image img, final int rows, final int cols)
  3. splitImage2D(BufferedImage img, int cols, int rows)
  4. splitImageIntoTiles(final BufferedImage imageWithTiles, final int numberOfTilesAcross, final int numberOfTilesDown)
  5. splitVertically(BufferedImage top, int elements)