getImageScaled method

CanvasImageSource? getImageScaled(
  1. double scale
)

Returns a cached image in scale.

Implementation

CanvasImageSource? getImageScaled(double scale) {
  if (scale <= 0) return null;
  if (scale == 1.0) return _image;

  var scaledImage = _scaleCache[scale];

  if (scaledImage == null) {
    scaledImage = createScaledImage(_image, _width, _height, scale);

    limitEntries(_scaleCache, _maxScaleCacheEntries - 1);

    _scaleCache[scale] = scaledImage;
  }

  return scaledImage;
}