crop method

void crop(
  1. int imageCropX,
  2. int imageCropY,
  3. int imageCropWidth,
  4. int imageCropHeight,
  5. dynamic onImageLoaded(
    1. Image,
    2. Uint8List
    ),
)

Image cropping will be done by crop method

Implementation

void crop(int imageCropX, int imageCropY, int imageCropWidth, int imageCropHeight,
    Function(Image, Uint8List) onImageLoaded) async {
  worker.postMessage([
    1,
    libraryImage.getBytes(),
    libraryImage.width.toInt(),
    libraryImage.height.toInt(),
    imageCropX,
    imageCropY,
    imageCropWidth,
    imageCropHeight,
    encodingQuality,
    outputImageFormat.index
  ]);
  final event = await worker.onMessage.first;
  onImageLoaded.call(
      Image.fromBytes(width: imageCropWidth, height: imageCropHeight, bytes: event.data[0], order: ChannelOrder.rgb),
      event.data[1]);
}