Example code of loading pictures into memory in Android

This article demonstrates how to load pictures into memory in Android

First, design the interface:

The code is as follows:

Upload test pictures to MNT / sdcard

Add logical part code:

Run the code and generate an error because the picture is too large (large picture is selected)

You can use the static class options contained in bitmapfactory to get the width and height information of the picture without parsing the picture information:

Run the following:

09-04 06:09:10.519: I/System. Out (1812): picture width: 2560 09-04 06:09:10.519: I / system Out (1812): picture height 1920

Next, get the width and height of the mobile phone screen:

You can see that both getHeight and getWidth methods are outdated. Use the following method instead:

The complete code is as follows:

The above is the example code of loading pictures into memory in Android introduced by Xiaobian. I hope it will help you. If you have any questions, please leave me a message and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>