Java Advanced Imagingで画像を中心から4分割するコーディングをお願いします。
質問する
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 に答える