请给我在Java Advanced Imaging中将图像从中心分成四部分的编码..
问问题
1498 次
3 回答
2
不确定 JAI,但这是BufferedImage
您可以用作 JAI 输入的方法。所以也许这适用于您的用例
public static BufferedImage[] divide(BufferedImage source) {
// for odd widths or heights, the last row or column will be ignored
// fixing this behaviour is left as an exercise to the eager
int height = source.getHeight() / 2;
int width = source.getWidth() / 2;
return new BufferedImage[] {
source.getSubimage(0, 0, width, height), // top left
source.getSubimage(width, 0, width, height), // top right
source.getSubimage(0, height, width, height), // bottom left
source.getSubimage(width, height, width, height) // bottom right
};
}
于 2010-02-03T09:44:11.023 回答
1
在示例中,宽度必须高于高度。那是:
source.getSubimage(0, 0,width, height ), // top left
source.getSubimage(width, 0, width, height), // top right
source.getSubimage(0, height, width, height), // bottom left
于 2011-11-09T19:28:37.033 回答