I'm using the Kilobolt Android framework. Using a custom Assets class, I'm loading images by using a BitmapFactory
and reading the actual image from an InputStream
. Now I'm having problems loading the bitmap from the folder, it keeps giving me an IOException
.
I tried copying my image file directly to the drawable-xxhdpi
folder. I don't understand why this isn't working.
My folders look like this:
src
|--main
|---|--java
|---|---|--all the fancy java files :D
|---|--res
|---|---|--drawable-xxhdpi
|---|---|---|--fancy images
|---|---|--other folders and files...
|---|--other folders and files...
|--other folders and files...
If you're trying to get a Bitmap from a drawable in a res/drawable-** folder, you should use BitmapFactory.decodeResource(R.drawable.<drawable id>)
Edit: to get the Resources for decodeResource, you need to have a Context (such as an Activity or a Service), call getResources()
to get the Resources object
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.