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

最佳答案

找到了答案,这要归功于这个很棒的库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/

10-10 14:14