获取图像宽度和高度的URI [英] Get Image Width and Height from URI
本文介绍了获取图像宽度和高度的URI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有可能得到从它的URI的图像文件的宽度和高度。我试图用这个code,但他们的一个错误:
有语法错误的getAbsolutePath()
令牌),语法错误,无效的参数列表
私人无效getDropboxIMGSize(URI URI){
BitmapFactory.Options选项=新BitmapFactory.Options();
options.inJustDe codeBounds = TRUE;
BitmapFactory.de codeFILE(uri.getPath())getAbsolutePath(),期权)。
INT imageHeight = options.outHeight;
INT imageWidth = options.outWidth;
}
解决方案
我有同样的问题,我发现它的解决方案在这个答案。你必须使用
BitmapFactory.de codeFILE(新文件(uri.getPath())getAbsolutePath(),选件);
在code,而不是这样的:
BitmapFactory.de codeFILE(uri.getPath())getAbsolutePath(),期权)。
Is it possible to get the width and height of a image file from its URI. I was trying to use this code but theirs a error: has a syntax error after the getAbsolutePath()
Syntax error on token ")", invalid ArgumentList
private void getDropboxIMGSize(Uri uri){
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(uri.getPath()).getAbsolutePath(), options);
int imageHeight = options.outHeight;
int imageWidth = options.outWidth;
}
解决方案
I had the same problem and I found it's solution at this answer.You have to use
BitmapFactory.decodeFile(new File(uri.getPath()).getAbsolutePath(), options);
in your code instead of this:
BitmapFactory.decodeFile(uri.getPath()).getAbsolutePath(), options);
这篇关于获取图像宽度和高度的URI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文