0

I had a image in drawable folder. I want to load using BitmapFactory.decodeFile. What is the file path in this case??

Subramanya G
  • 39
  • 2
  • 8

1 Answers1

0

check out this way, provide resources id as a "path"

Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.image_resource);
snachmsm
  • 17,866
  • 3
  • 32
  • 74
  • The image I got is 29.9MB, so bmap is null. Anyway to solve it?? – Subramanya G Mar 24 '21 at 07:36
  • `drawable`s are for "normal size" images possible to fast load in UI thread. you should put your image in assets and read in separated `Thread` using [`decodeStream`](https://stackoverflow.com/questions/8501309/android-get-bitmap-or-sound-from-assets). but I must aware you that such big bitmap have probably big resolution, which may not be handled by at least some of Android devices (check [THIS](https://stackoverflow.com/questions/15313807/android-maximum-allowed-width-height-of-bitmap) topic) – snachmsm Mar 24 '21 at 07:39
  • 1
    Yes. Scale down the image while decoding the stream. Use an overloaded member which takes an Options parameter. – blackapps Mar 24 '21 at 09:43