Every image on android should be treated as a bitmap

I was having a problem with loading images into a TextView, when I came across a pretty dumb doubt, rs, would anyone know how to answer?

Is next, I was trying to load a large image(high resolution) as background of a TextView, dai I found that I would have to resize the image to not give problem.
Until then everything is fine, but I wondered, in the end on android every image is a bitmap ???

Because it was loading the image .jpg of the drawable folder, direct as resource (txt.setBackgroundResource()) was not even using the Class bitmap , however in the error logcat it said "problems loading bitmap" (something like that).

So the doubt is: it doesn't matter if I'm working with a drawable (R.drawable.img), an image coming from a url, or a bitmap, android, internally will work / transform, all in bitmap ?

I know it's an idiot doubt, but if anyone can clarify me, I appreciate it. And also, no matter where the image comes from, should I always resize it as if it were a bitmap?

Author: ramaral, 2016-08-06

1 answers

Should every image on android be treated as a bitmap?

Depends.

Yes , because bitmap is the class of choice for working with images whose format represents a map of bits.
A bit map is a bit array that specifies the color of each pixel in a rectangular array of pixels.

There are several(file) formats to represent this map, the bitmap supports JPEG, PNG and WebP(Android 4.0+).

Not , because most methods accept a drawable as a parameter.
A Drawable is a general abstraction for "something that can be drawn."It can take a variety of forms, including that of a bitmap.

To create a bitmap from a Drawable use:

Bitmap bipmap = BitmapFactory.decodeResource(context.getResources(),
                                             R.drawable.icon_resource);

To create a Drawable from a Bitmap use:

Drawable drawable = new BitmapDrawable(getResources(), bitmap);  

To read in the Android documentation:

 4
Author: ramaral, 2016-08-06 19:50:03