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;
  Uint8List byteData = Uint8List.fromList(event.data[0]);
  Uint8List byteData2 = Uint8List.fromList(event.data[1]);
  onImageLoaded.call(
      Image.fromBytes(width: imageCropWidth, height: imageCropHeight, bytes: byteData.buffer, numChannels: 3),
      byteData2);
}