我有一张图像,其尺寸为16x6080像素。这是一个堆叠的图像,其中包含16x16像素的国旗区块。我的目标是从该图像中仅提取特定国家的国旗并将其保存为自己的文件。这是我的当前代码:
//Original Image
BufferedImage image = ImageIO.read(new File(countryImageNamePath));
System.out.println("Original Image Dimension: "+image.getWidth()+"x"+image.getHeight());
//Get the cropped image
BufferedImage out = image.getSubimage(0, 1808, 16, 16);
//Create a file to stream the out buffered image to
File croppedFile = new File(countryImagePath + countryName + ".gif");
//Write the cropped file
ImageIO.write(out, "gif", croppedFile);
生成的输出结果为:
Original Image Dimension: 16x6080
Write File : C:\Applications\WorldCoinParser\images\country\US.gif
无论我输入什么Y坐标的值,都只能显示从x=0和y=0开始的图像顶部,宽度和高度为16像素。
有没有人看出我的错误所在呢?
谢谢!