Java 放大BuffereImage的特定部分

Java 放大BuffereImage的特定部分,java,graphics,zooming,bufferedimage,Java,Graphics,Zooming,Bufferedimage,我正在尝试获取buffereImage的子图像,然后使用此子图像替换原始buffereImage,以基于用户指定的选择实现缩放功能。但是,当我将子图像重绘到原始图像上时,子图像的底部不会显示。我不知道为什么。我想知道是否有人能发现任何明显的错误 private void zoomImage(int x1, int x2, int y1, int y2){ BufferedImage subImage = originalImage.getSubimage(x1, y1, x2-x1, y

我正在尝试获取
buffereImage
的子图像,然后使用此子图像替换原始
buffereImage
,以基于用户指定的选择实现缩放功能。但是,当我将子图像重绘到原始图像上时,子图像的底部不会显示。我不知道为什么。我想知道是否有人能发现任何明显的错误

private void zoomImage(int x1, int x2, int y1, int y2){
    BufferedImage subImage = originalImage.getSubimage(x1, y1, x2-x1, y2-y1);
    Graphics2D graphics2D = (Graphics2D) originalImage.getGraphics();
    graphics2D.drawImage(subImage, 0, 0, 600, 400, 0,0, x2-x1,y2-y1, null);
    // clean up
    graphics2D.dispose();
}

我还想知道是否有更好的方法来实现对特定矩形选择的放大,并使用放大部分替换原始图像。

应该注意,子图像的大小不应超过原始图像的宽度和高度。 例如,如果
originalimage.width=600
originalimage.height=800
则可以创建大小应为
subimage.horizentalorigin+subimage.width的子图像