我在java中有一个程序,其中tif文件在源缓冲图像中读取,然后这个缓冲图像被复制为目标缓冲图像。当我将此缓冲图像写入磁盘时,图像会丢失其坐标信息。怎样做才能不丢失坐标信息?
我的代码是:
/* Check if imageType if tif */
if (imageType.equalsIgnoreCase(TIFF)) {
bufferedImageType = BufferedImage.TYPE_INT_RGB;
}
BufferedImage destination = new BufferedImage(source.getWidth(), source.getHeight(),
bufferedImageType);
/* Loop to cover all pixels */
for (int width = 0; width < source.getWidth(); width++) {
/* Loop to cover all lines */
for (int height = 0; height < source.getHeight(); height++) {
destination.setRGB(width, height, source.getRGB(width, height));
}
}
file = new File(TEMP_DIR + TEMP_FILE_NAME + "tif");
ImageIO.write(destination, "tif", file);