0

我想获得图像 dpi 以将像素转换为厘米,所以我使用 ImageInfo.java 来获得这个:

ImageInfo myMapInfo = new ImageInfo();
            try {
                File testFile = new File(fileNameString);
                InputStream myMapStream = new FileInputStream(testFile);
                myMapInfo.setInput(myMapStream);
                myMapInfo.setDetermineImageNumber(true);
                myMapInfo.setCollectComments(true);

            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }

            x = myMapInfo.getPhysicalWidthInch();
            y = myMapInfo.getPhysicalHeightInch();

但不幸的是我在(x,y)中得到-1和-1!我使用这个类: ImageInfo.java

4

1 回答 1

0

通过查看 ImageInfo 的源代码,您需要调用变量的check()方法,myMapInfo如果通过,您可以使用各种getXxX()方法来获取所需的任何信息。顺便得到 -1 作为结果意味着信息不可用,但这很可能是因为您没有调用该check()方法。

于 2017-05-22T15:52:11.763 回答