can i get image file width and height from uri in android?

前端 未结 10 2118
深忆病人
深忆病人 2020-12-08 01:58

i can getting the image width through MediaStore.Images.Media normally

but i need to getting the image width and height from image which selected from d

10条回答
  •  佛祖请我去吃肉
    2020-12-08 02:44

    If you guys keep getting (0,0) in the width and height, you probably want to decode a stream, and not a file.

    It probably because you're trying to read an image from the assets. Try this:

    val b = BitmapFactory.decodeStream(context.assets.open("path/in/assets/img.png"))
    val width = b.width
    val height = b.height
    

提交回复
热议问题