Java BufferedImage Split split(int w, int h, BufferedImage src)

Here you can find the source of split(int w, int h, BufferedImage src)

Description

split

License

Apache License

Declaration

public static BufferedImage[] split(int w, int h, BufferedImage src) 

Method Source Code


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

import java.awt.image.BufferedImage;

public class Main {
    public static BufferedImage[] split(int w, int h, BufferedImage src) {
        int xs = src.getWidth() / w;
        int ys = src.getHeight() / h;
        BufferedImage[] result = new BufferedImage[xs * ys];

        int i = 0;
        for (int y = 0; y < ys; y++) {
            for (int x = 0; x < xs; x++) {
                result[i++] = src.getSubimage(x * w, y * h, w, h);
            }//  w  w  w.  j av  a 2s .  c o  m
        }
        return result;
    }
}

Related

  1. splitByWidth(BufferedImage img, int width)
  2. splitImage(BufferedImage image, int row, int col)
  3. splitImage(BufferedImage image, int rows, int cols)
  4. splitImage(BufferedImage img, int cols, int rows)