1

With android Pie a new Class is available to handle bitmap and drawable operation. Previously i used BitmapFactory in my most application to handle bitmap operations.

My question is

Should i start using ImageDecoder?, how ImageDecoder is better then the BitmapFactory?

it's given that

"ImageDecoder class, which provides a modernized approach for decoding images"

but official document don't saying much about this

if anyone used this class, can explain what will be advantage of using this ImageDecoder class?

here is the official documentation where i found it

Ashwini Saini
  • 1,324
  • 11
  • 20

2 Answers2

3

The new ImageDecoder api is much more powerful and supports a variety of different types. It can handle assets, gifs, resources, drawables and much more. You can pass it many different kinds of types and it will take care of converting them to Drawables or Bitmaps for you.

Here are some guides to get you started:

Angel Kjos
  • 1,951
  • 1
  • 12
  • 12
1

As of now, ImageDecoder is at beta version stage, It has only 19 methods of which 7 are static factory methods yet powerful. ImageDecoder can decode the image from a ByteBuffer, a File or a Uri to a Bitmap or a Drawable. This thing is pretty good that they also threw in the support to decode animated GIFs and WebP images. These animated images would be of type AnimatedImageDrawable which can be played using the start() method anytime you want to play a cute cat GIF. you can also perform post-processing, masking, Error Handling, Cropping, & Scaling very easily which is really amazing.

My Suggestion

At present, it only appears within the Framework so we can only use it on devices running P so my personal advice is to just wait for the official release and check what they are offering for the previous version as they do not mention much in the official document.

Samarth Sevak
  • 521
  • 4
  • 16