toJpeg method

Future<Uint8List> toJpeg(
  1. int quality
)

Implementation

Future<Uint8List> toJpeg(int quality) {
  final buf = malloc.call<Pointer<Uint8>>();
  buf.value = nullptr;
  final size = malloc.call<IntPtr>();
  size.value = 0;
  try {
    jpegEncode(_inst, quality, buf, size);
    final result = Uint8List.fromList(buf.value.asTypedList(size.value));
    return Future.sync(() => result);
  } finally {
    if (buf.value != nullptr) malloc.free(buf.value);
    malloc.free(size);
    malloc.free(buf);
  }
}