fromBytes static method

PixImage fromBytes(
  1. Uint8List imageBytes
)

Implementation

static PixImage fromBytes(Uint8List imageBytes) {
  ffi.Pointer<ffi.Uint8> imageBytesPtr =
      calloc.allocate<ffi.Uint8>(imageBytes.length);

  try {
    imageBytesPtr.asTypedList(imageBytes.length).setAll(0, imageBytes);
    return PixImage._(
      imageBytes: imageBytesPtr,
      length: imageBytes.length,
    );
  } finally {
    calloc.free(imageBytesPtr);
  }
}