# decodeImageFromPixels function

void decodeImageFromPixels (Uint8List pixels, int width, int height, PixelFormat format, ImageDecoderCallback callback, { int rowBytes, double decodedCacheRatioCap: double.infinity })

Convert an array of pixel values into an Image object.

`pixels` is the pixel data in the encoding described by `format`.

`rowBytes` is the number of bytes consumed by each row of pixels in the data buffer. If unspecified, it defaults to `width` multiplied by the number of bytes per pixel in the provided `format`.

The `decodedCacheRatioCap` is the default maximum multiple of the compressed image size to cache when decoding animated image frames. For example, setting this to `2.0` means that a 400KB GIF would be allowed at most to use 800KB of memory caching unessential decoded frames. Caching decoded frames saves CPU but can result in out-of-memory crashes when decoding large (or multiple) animated images. Note that GIFs are highly compressed, and it's unlikely that a factor that low will be sufficient to cache all decoded frames. The default value is `25.0`.

## Implementation

    void decodeImageFromPixels(
      Uint8List pixels,
      int width,
      int height,
      PixelFormat format,
      ImageDecoderCallback callback,
      {int rowBytes, double decodedCacheRatioCap = double.infinity}
    ) {
      final _ImageInfo imageInfo = new _ImageInfo(width, height, format.index, rowBytes);
      final Future<Codec> codecFuture = _futurize(
        (_Callback<Codec> callback) => _instantiateImageCodec(pixels, callback, imageInfo, decodedCacheRatioCap)
      );
      codecFuture.then((Codec codec) => codec.getNextFrame())
          .then((FrameInfo frameInfo) => callback(frameInfo.image));
    }