1

Java Advanced Imagingで画像を中心から4分割するコーディングをお願いします。

4

3 に答える 3

2

JAI についてはよくわかりませんが、BufferedImageJAI の入力として使用できるアプローチを次に示します。だから多分これはあなたのユースケースでうまくいく

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 に答える
1

Sun のJava2D *デモには、4 つの等しくない部分を使用した興味深いだまし絵があります。

* タブの右下の象限を参照してくださいImages

于 2010-02-03T16:54:23.627 に答える