gpt4 book ai didi

Flutter:合并两个图像并将其作为单个图像存储在本地存储中

转载 作者:行者123 更新时间:2023-12-03 02:41:36 33 4
gpt4 key购买 nike

我想合并两个图像,并将它们显示并存储为单个图像。

最佳答案

找到了答案,这要归功于这个很棒的库https://pub.dev/packages/image

final image1 = decodeImage(File('imageA.jpg').readAsBytesSync());
final image2 = decodeImage(File('imageB.jpg').readAsBytesSync());
final mergedImage = Image(image1.width + image2.width, max(image1.height, image2.height));
copyInto(mergedImage, image1, blend = false);
copyInto(mergedImage, image2, dstx = image1.width, blend = false);

final documentDirectory = await getApplicationDocumentsDirectory();
final file = new File(join(documentDirectory.path, "merged_image.jpg"));
file.writeAsBytesSync(encodeJpg(mergedImage));

关于Flutter:合并两个图像并将其作为单个图像存储在本地存储中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59611736/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com