Repository navigation
Description
Internal: b/160377720
instantiateImageCodec has some problematic documentation and defaults.
Specifically, the docs currently say:
The targetWidth and targetHeight arguments specify the size of the output image, in image pixels. If they are not equal to the intrinsic dimensions of the image, then the image will be scaled after being decoded. If only one dimension is specified, the omitted dimension will remain its original size. If both are not specified, then the image maintains its real size.
The second to last sentence there is not true - if only one dimension is specified, we scale the other dimension along its aspect ratio.
Additionally, the API is very challenging to use correctly since the caller may not know the intrinsic size of the image. I wrote a proposal to provide that from Dart (issue here: #50022 (comment)), but I think we can pretty easily clean up this API without requiring that.
We should do the following:
- Update the docs to be accurate
- Add a parameter to control whether we allow for upscaling of the image, i.e. whether the image should be allowed to be expanded beyond its intrinsic dimensions - and default it to false.
- Add a parameter to control how the aspect ratio is maintained, if it is maintained at all.
If we can fix these things, #50022 would either be mostly obsolete or could be moved easily to some kind of package status.
Activity
dnfield commentedon Jun 29, 2020
Considering an alternative here: creating a new dart:ui API surface for obtaining and decoding images.
dnfield commentedon Jul 21, 2020
Rather than adding a parameter, I've refactored the way this works. I'll file a new bug to expose this up through the framework, but the engine side work is done with #19537
github-actions commentedon Aug 18, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.