instantiateImageCodecFromBuffer method

  1. @Deprecated('Use instantiateImageCodecWithSize instead. ' 'This feature was deprecated after v3.7.0-1.4.pre.')
Future<Codec> instantiateImageCodecFromBuffer(
  1. ImmutableBuffer buffer, {
  2. int? cacheWidth,
  3. int? cacheHeight,
  4. bool allowUpscaling = false,
})

Calls through to dart:ui.instantiateImageCodecFromBuffer from ImageCache.

The buffer parameter should be an ui.ImmutableBuffer instance which can be acquired from ui.ImmutableBuffer.fromUint8List or ui.ImmutableBuffer.fromAsset.

The cacheWidth and cacheHeight parameters, when specified, indicate the size to decode the image to.

Both cacheWidth and cacheHeight must be positive values greater than or equal to 1, or null. It is valid to specify only one of cacheWidth and cacheHeight with the other remaining null, in which case the omitted dimension will be scaled to maintain the aspect ratio of the original dimensions. When both are null or omitted, the image will be decoded at its native resolution.

The allowUpscaling parameter determines whether the cacheWidth or cacheHeight parameters are clamped to the intrinsic width and height of the original image. By default, the dimensions are clamped to avoid unnecessary memory usage for images. Callers that wish to display an image above its native resolution should prefer scaling the canvas the image is drawn into.

Implementation

@Deprecated(
  'Use instantiateImageCodecWithSize instead. '
  'This feature was deprecated after v3.7.0-1.4.pre.',
)
Future<ui.Codec> instantiateImageCodecFromBuffer(
  ui.ImmutableBuffer buffer, {
  int? cacheWidth,
  int? cacheHeight,
  bool allowUpscaling = false,
}) {
  assert(cacheWidth == null || cacheWidth > 0);
  assert(cacheHeight == null || cacheHeight > 0);
  return ui.instantiateImageCodecFromBuffer(
    buffer,
    targetWidth: cacheWidth,
    targetHeight: cacheHeight,
    allowUpscaling: allowUpscaling,
  );
}