How can I get height and width of an image?

前端 未结 5 1046
野的像风
野的像风 2021-01-04 19:40

Why is the following bit of code returns Height: -1 which means that the height is yet not known. How to get height of the image?

 try {
        // Create a          


        
5条回答
  •  时光取名叫无心
    2021-01-04 20:00

    createImage runs in background to load the Image.

    use a MediaTracker to wait for the loading and then use getHeight (and use a valid ImageObserver to prevent errors)

提交回复
热议问题