下面是我的代码:
String[] filePathColumn = { MediaStore.Images.Media.DATA };
Cursor cur = getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new String[] {ImageColumns._ID}, null, null,null);
if ((cur != null) && cur.moveToFirst()) {
// Integer idsArray[] = new Integer[cur.getCount()];
for (int i = 0; i < cur.getCount(); i++) {
idsArray[i] = cur.getInt(cur.getColumnIndex(ImageColumns._ID));
cur.moveToNext();
}
}
Bitmap originalImage = BitmapFactory.decodeFile(cur.getString(cur.getColumnIndex(filePathColumn[0])));
int width = originalImage.getWidth();
int height = originalImage.getHeight();
cur.close();
我想获取每个图像的高度和宽度。我想使用getHeight()
andgetWidth()
方法,但上面的代码给了我一个错误。请帮帮我。