Closed RamV13 closed 6 years ago
This is quite different from the conversion functions defined on Bitmap
and Color
. This is not a conversion, but an expensive decode. All you are effectively saving is the ImageDecoder.
prefix in the original call (and admittedly having to use the decoder
receiver inside the lambda). If the extension was called decode
instead of toBitmap
I'd be more inclined to accept it.
That makes sense. What would be a better name then, because decodeDrawable
and decodeBitmap
wouldn't clearly indicate that it's decoding to that type whereas decodeToDrawable
and decodeToBitmap
might be too verbose?
Given the wording in the docs for ImageDecoder.Source
, I think it's reasonable to name the functions decodeBitmap
and decodeDrawable
. Updated the PR.
Ran tests locally, everything's green, thanks for the contribution!
These extensions add
decodeBitmap
anddecodeDrawable
functions to theImageDecoder
API for decodingImageDecoder.Source
instances. Further, thedecoder
instance is now passed as thethis
to the lambda to enable callingImageDecoder
functions more seamlessly.Before
After
Code snippet adapted from I/O 2018 (https://youtu.be/eMHsnvhcf78?t=1695)