Open akindone opened 2 years ago
I finally make it works by modifying the ImageLayer.drawLayout dst rect's width, height as below
//ImageLayer
@override
void drawLayer(Canvas canvas, Size size, Matrix4 parentMatrix,
{required int parentAlpha}) {
//...
// var dst = Rect.fromLTWH(0, 0, bitmap.width * density,
// bitmap.height.toDouble() * density);
var imageAsset = lottieDrawable.composition.images[layerModel.refId]!;
var dst = Rect.fromLTWH(0, 0, imageAsset.width * density, imageAsset.height * density);
canvas.drawImageRect(bitmap, src, dst, paint);
canvas.restore();
}
The original animation images taskes 70M memory, while using ResizeImage set width 600 only takes 18M. If this code is correct and no other side effect, can you put the changes to the next version? @xvrh
@akindone thanks for the report and sample code.
I see the problem but I'm not really sure what is the correct fix.
A user may want to return a different image with a different size (and aspect ratio) and expect the image to be rendered at the new size...
Maybe imageProviderFactory
should allow to return the size to use?
Flutter provides
ResizeImage
,This allows finer control of the size of the image in [ImageCache] and is generally used to reduce the memory footprint of [ImageCache]. But when usingResizeImage
in imageProviderFactory, the animation images looks not right.this video shows the asset location mismatch issue; https://user-images.githubusercontent.com/17843738/185293375-8f4dd717-122c-4667-9118-4641c9a19c25.mp4
If I passing null to
imageProviderFactory
, it can show correctly as below image shows.