instantiateImageCodec function

Future<Codec> instantiateImageCodec (Uint8List list, { int targetWidth int targetHeight })

Instantiates an image codec Codec object.

list is the binary image data (e.g a PNG or GIF binary data). The data can be for either static or animated images. The following image formats are supported: JPEG, PNG, GIF, Animated GIF, WebP, Animated WebP, BMP, and WBMP

The targetWidth and targetHeight arguments specify the size of the output image, in image pixels. If they are not equal to the intrinsic dimensions of the image, then the image will be scaled after being decoded. If only one dimension is specified, the omitted dimension will remain its original size. If both are not specified, then the image maintains its real size.

The returned future can complete with an error if the image decoding has failed.

Implementation

Future<Codec> instantiateImageCodec(Uint8List list, {
  int targetWidth,
  int targetHeight,
}) {
  return _futurize(
    (_Callback<Codec> callback) => _instantiateImageCodec(list, callback, null, targetWidth ?? _kDoNotResizeDimension, targetHeight ?? _kDoNotResizeDimension)
  );
}