3

大家好。

我在进口方面遇到问题。它向我显示导入错误,如果我删除它们JpegImageMetadata, , Sanselan, ImageReadException, TiffImageMetadata,ExifTagConstants将无法解析为类型。

我正在使用 Android 2.3.3 并且也尝试了 Android 3.2,但仍然遇到同样的问题。以下是进口:

import org.apache.sanselan.ImageReadException;
import org.apache.sanselan.Sanselan;
import org.apache.sanselan.formats.jpeg.JpegImageMetadata;
import org.apache.sanselan.formats.tiff.TiffImageMetadata;
import org.apache.sanselan.formats.tiff.constants.ExifTagConstants;

这是显示错误的代码的另一部分(如果需要,我可以发布整个代码):

private int degreeRotated(String filePath) {
        try {
            JpegImageMetadata meta = ((JpegImageMetadata) Sanselan.getMetadata(new File(filePath)));
            TiffImageMetadata data = null;
            if (meta != null) {
                data = meta.getExif();
            }
            int orientation = 0;
            if (data != null) {
                orientation = data.findField(ExifTagConstants.EXIF_TAG_ORIENTATION).getIntValue();
            } else {
                String[] projection = { Images.ImageColumns.ORIENTATION };
                Cursor c = getContentResolver().query(Uri.fromFile(new File(filePath)), projection, null, null, null);

                if (c != null && c.moveToFirst()) {
                    orientation = c.getInt(0);
                }
            }
            switch (orientation) {
                case 6:
                    return 90;
                case 8:
                    return 270;
                default:
                    return 0;

            }
            /*
             * } catch (JpegProcessingException e1) { e1.printStackTrace(); }
             * catch (MetadataException e) { e.printStackTrace(); }
             */} catch (ImageReadException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return 0;
    }

这是错误日志:

Description   Resource   Path   Location   Type
ImageReadException cannot be resolved to a type   Viewer.java   /Main/src/com/owleyes/moustache   line 687   Java Problem
ExifTagConstants cannot be resolved to a variable   Viewer.java   /Main/src/com/owleyes/moustache   line 666   Java Problem
TiffImageMetadata cannot be resolved to a type   Viewer.java   /Main/src/com/owleyes/moustache   line 660   Java Problem
Sanselan cannot be resolved   Viewer.java   /Main/src/com/owleyes/moustache   line 659   Java Problem
JpegImageMetadata cannot be resolved to a type   Viewer.java   /Main/src/com/owleyes/moustache   line 659   Java Problem
JpegImageMetadata cannot be resolved to a type   Viewer.java   /Main/src/com/owleyes/moustache   line 659   Java Problem
The import org.apache.sanselan cannot be resolved   Viewer.java   /Main/src/com/owleyes/moustache   line 11   Java Problem
The import org.apache.sanselan cannot be resolved   Viewer.java   /Main/src/com/owleyes/moustache   line 10   Java Problem
The import org.apache.sanselan cannot be resolved   Viewer.java   /Main/src/com/owleyes/moustache   line 9   Java Problem
The import org.apache.sanselan cannot be resolved   Viewer.java   /Main/src/com/owleyes/moustache   line 8   Java Problem
The import org.apache.sanselan cannot be resolved   Viewer.java   /Main/src/com/owleyes/moustache   line 7   Java Problem
4

1 回答 1

2

显然您没有所需的库:Apache Sanselan

在此处下载二进制文件:http: //commons.apache.org/imaging/download_sanselan.cgi,然后解压缩存档。把它sanselan-{version}.jar放在你的项目libs目录中。重新编译,错误应该消失了。

Remember - Android doesn't have Sanselan library included out of the box.

于 2013-01-14T01:58:08.547 回答