Closed jwbrown closed 6 months ago
you can use this method ,but it's slow.
Thanks for the suggestion. Strangely it is giving me the same data as the originally loaded image, not the data from after a flip() or rotate() call...
i.e. get the same return after various edits (that show perfectly on the screen) as i got when i first loaded the image... It feels like this is the cached data i am getting back, and not the current image.
This is the function i am using:
Future<Uint8List?> getImageFromNew() async { final state = editorKey.currentState; if (state == null || state.image == null) { return null; } Uint8List result = (await state.image!.toByteData(format: ui.ImageByteFormat.png))!.buffer.asUint8List(); return result; }
is there something i am doing wrong?
you can the data after fip at this place
Thank you very, very much.... this has solved the problem for me :)
Platforms
dart, Android
Description
The editing works perfectly, i am testing with a Flip at the moment. However, when extracting the data to save the image to a file, I am getting the original file data and not the edited data.
My code
final GlobalKey editorKey = GlobalKey();
ExtendedImage img = ExtendedImage.file( File(widget.filePath), fit: BoxFit.contain, mode: ExtendedImageMode.editor, extendedImageEditorKey: editorKey, cacheRawData: true, initEditorConfigHandler: (state) => EditorConfig( maxScale: 8.0, cropRectPadding: EdgeInsets.all(20.0), hitTestSize: 20.0, ), );
// in an icon button editorKey.currentState?.flip();
// the image is flipped perfectly on screen // for saving the current code i am trying is final state = editorKey.currentState; if (state == null) { return; } Uint8List? editedImage = state.rawImageData; File imgFile = File(widget.filePath); imgFile.writeAsBytesSync(editedImage!); // with testing for null editedImage code left out
Try do it
I can see that the image data that is provided in the original file load, is identical to that returned from the
Uint8List? editedImage = state.rawImageData;
I have also attempted going to the ImageProvider logic with an ImageStreamListener but could not get that to work either.
Any help/direction will be appreciated