Java BufferedImage Trim trim(BufferedImage image)

Here you can find the source of trim(BufferedImage image)

Description

trim

License

Open Source License

Declaration

private static BufferedImage trim(BufferedImage image) 

Method Source Code

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

import java.awt.image.BufferedImage;

public class Main {

    private static BufferedImage trim(BufferedImage image) {
        int len;/* w w  w. ja  va  2s .c o m*/
        int x;
        int y;
        if (image.getWidth() > image.getHeight()) {
            len = image.getHeight();
            x = (image.getWidth() - len) / 2;
            y = 0;
        } else {
            len = image.getWidth();
            x = 0;
            y = (image.getHeight() - len) / 2;
        }
        return image.getSubimage(x, y, len, len);
    }
}

Related

  1. trim(BufferedImage image)
  2. trim(BufferedImage image, int trimTop, int trimLeft, int trimBottom, int trimRight)
  3. trim(BufferedImage image, Rectangle trimRect)
  4. trim(BufferedImage img)
  5. trim(final BufferedImage img)