【问题标题】:setRgb in java for tif buffered image loses its coordinate informationjava中用于tif缓冲图像的setRgb丢失其坐标信息
【发布时间】:2013-01-17 11:31:31
【问题描述】:

我在 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);

【问题讨论】:

  • “坐标信息” DYM 拍摄照片的地点/日期?

标签: java image-processing bufferedimage javax.imageio


【解决方案1】:

我知道这篇文章已经过时了,但是……

如果您谈论的是在此过程中丢失的所有标头数据,那么您可以使用 Apache Commons Imaging 将标头从源图像文件复制到目标图像文件。

这是一个例子:

https://commons.apache.org/proper/commons-imaging/xref-test/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriteTest.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-04-17
    • 1970-01-01
    • 2013-04-14
    • 2016-04-05
    • 2021-07-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多