1

请给我在Java Advanced Imaging中将图像从中心分成四部分的编码..

4

3 回答 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 回答
1

在 Sun 的Java2D *演示中使用四个不相等的部分有一个有趣的trompe-l'oeil

* 请参阅选项卡的右下象限Images

于 2010-02-03T16:54:23.627 回答