下面是我的代码。单击imageview相机将打开,我们将捕获图像。在下面的onActivityResult中,图像大小是缩略图的大小。我想要实际的图像大小。怎么办?
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_REQUEST && resultCode == Activity.RESULT_OK) {
Bitmap photo = (Bitmap) data.getExtras().get("data");
if (CAMERA_REQUEST == 1) {
ivBeforeLoading.setImageBitmap(photo);
ivBeforeLoading.setBackgroundResource(0);
imgBefLoad = photo;
}
}
}发布于 2020-03-04 21:34:06
-You需要获取完整的图像路径,而不仅仅是来自意图的额外数据,然后从该路径获取文件,只有这样您才能获得图片的真实大小。-you可以使用一些选取器库,或者您可以只检查此链接
Dialog to pick image from gallery or from camera
你会找到你要找的东西
发布于 2020-03-05 00:05:11
试试这个(how do I get file size of temp file in android?)
File file = new File(selectedPath);
int file_size = Integer.parseInt(String.valueOf(file.length()/1024));https://stackoverflow.com/questions/60527050
复制相似问题