fluttercandies / flutter_image_editor

Flutter plugin, support android/ios.Support crop, flip, rotate, color martix, mix image, add text. merge multi images.
Apache License 2.0
407 stars 124 forks source link

[Bug report] Rendered exported image produced from iPhone with white background is not completely white after export. Its become smokey white. For example for pure white(FFFFFF), rendered export image is produced as smokey white(FAFAFA). This is only occuring in iOS-iPhone platforms. #136

Open m2ahmed-exergy opened 3 months ago

m2ahmed-exergy commented 3 months ago

Version

1.5.0

Platforms

iOS

Device Model

iPhone 12 Pro Max

flutter info

Flutter version i am using 3.19.6

How to reproduce?

var rootMergeContainer = ImageMergeOption( canvasSize: Size(exportWidth.toDouble(), exportHeight.toDouble()), format: OutputFormat.jpeg(80), );

    ByteData exportBackgroundData;
    exportBackgroundData = await rootBundle.load(
        "assets/drawable/photobook_layouts/ic_photobook_text_white_bg.jpg");
    Uint8List exportBG = exportBackgroundData.buffer.asUint8List();
    rootMergeContainer.addImage(MergeImageConfig(
        image: MemoryImageSource(exportBG),
        position:
            ImagePosition(Offset(0, 0), Size(2400, 2400))));
    Uint8List centerCropSrcUInt8List;

rootMergeContainer.addImage(MergeImageConfig( image: MemoryImageSource(exportBG), position: ImagePosition( Offset(100, 200), 2200, 2200))));

    Uint8List? result = await ImageMerger.mergeToMemory(
      option: rootMergeContainer,
    );
    MemoryImage? provider = MemoryImage(result!);
    Uint8List originalBytes = provider.bytes;
    Uint8List resultBytes = Uint8List.fromList(originalBytes);
    resultBytes[13] = 1;
    resultBytes[14] = (300 >> 8);
    resultBytes[15] = (300 & 0xff);
    resultBytes[16] = (300 >> 8);
    resultBytes[17] = (300 & 0xff);

    String tempPath = await Utilities.getAppDirectoryPath(
        isPlatformAndroid: Platform.isAndroid,
        isPlatformIOS: Platform.isIOS);
    File? file;
    if (Platform.isAndroid) {
      String imgName = "IMG_AND_COLOR_TILES_" +
          DateTime.now().millisecondsSinceEpoch.toString() +
          JPEG_EXTENSION;
      print(imgName);
      file = File('$tempPath/$imgName');
    } else if (Platform.isIOS) {
      String imgName = "IMG_IOS_COLOR_TILES_" +
          DateTime.now().millisecondsSinceEpoch.toString() +
          JPEG_EXTENSION;
      print(imgName);
      file = File('$tempPath/$imgName');
    }
    file?.writeAsBytesSync(resultBytes.bytes);

page-1-image-411716467202813

Logs

No response

Example code (optional)

No response

Contact

No response

m2ahmed-exergy commented 3 months ago

Further more i have diagnosed that this issue is being produced from version 1.4.0 and onwards.