Java Image Cut cutImage(BufferedImage img, int w, int h)

Here you can find the source of cutImage(BufferedImage img, int w, int h)

Description

cut Image

License

Open Source License

Declaration

public static BufferedImage[] cutImage(BufferedImage img, int w, int h) 

Method Source Code

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

import java.awt.image.BufferedImage;

public class Main {
    public static BufferedImage[] cutImage(BufferedImage img, int w, int h) {

        int cols = img.getWidth() / w;
        int rows = img.getHeight() / h;

        BufferedImage[] tiles = new BufferedImage[cols * rows];
        for (int x = 0; x < cols; x++) {
            for (int y = 0; y < rows; y++) {
                tiles[x + y * cols] = img.getSubimage(x * w, y * h, w, h);
            }//from w  ww  .  java  2 s.co m
        }

        return tiles;
    }
}

Related

  1. cropImage(Image originalImage, int left, int top, int right, int bottom)
  2. cropImage(URL url, float x, float y, float w, float h, OutputStream out)
  3. cut(String srcImageFile, String result, int x, int y, int width, int height)
  4. cut2(String srcImageFile, String descDir, int rows, int cols)
  5. cutImage(BufferedImage image, int posX, int posY, int width, int height)
  6. cutImage(File file, int x, int y, int width, int heigth)
  7. cutImage(final BufferedImage bufferedImage, final int targetW, final int targetH)
  8. cutImage(String src, String dest, int x, int y, int w, int h)
  9. cutImage(String src, String dest, int x, int y, int w, int h)