简体   繁体   中英

How to open a JPG file as a BITMAP stored on the …/res/drawable-hdpi/?

I want to open a JPG file as Bitmap that stored on drawable-hdpi folder. But i do not use R.drawable.filename , because I don`t know its name. I only have a String of its name.

String IMAGE = String.valueof(Random());

In otherwise, I want to open an Image file with name IMAGE stored on the .../res/drawable-hdpi/ .

Thanks for any help.

您可以通过以下方式获取位图

Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.myimage);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM