3
大家好。android圖像旋轉,導入錯誤
我遇到了導入問題。它顯示我的進口錯誤,如果我刪除它們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