Closed kekland closed 1 year ago
have you tried using compute to make the cropping off the main thread?
@talamaska I'm worried about the overhead of copying an entire image Uint8List
to a separate isolate. I will try both approaches (with compute
and dart:ffi
) and see which one would work better
@talamaska nvm, seems like an approach with Canvas and PictureRecorder seems to work the best, as we just delegate everything to Flutter. This also results in better images as it will use a bicubic interpolation instead of a bilinear one. See https://github.com/kekland/croppy/commit/b45f04f21b9d1826c0a4c2f9e171ed3fbe3d240f
Seems to work fine on Web now. Closing this, but if anything pops up, feel free to reopen.
On web, clicking "Done" takes a long time until the image is cropped. This is due to the cropping function running in Dart, that has a complexity of O(W*H) (which gets compiled to JS, and it's even worse there). A potential solution would be to rewrite the cropping function in C/C++, and use
dart:ffi
to call it.