ProSlideImage.fromUrl constructor

ProSlideImage.fromUrl(
  1. String url, {
  2. dynamic version = ProVersion.six,
})

Use this Constructor when you have the UID / URL of a slide image. This is sent with the Stage Display protocol.

Implementation

ProSlideImage.fromUrl(String url, {version = ProVersion.six}) {
  Cache.getBytesCachedFirst(Uri.parse(url)).map((List<int> bytes) {
    late imglib.Decoder decoder;
    if (version.index > ProVersion.six.index) {
      decoder = imglib.TiffDecoder();
    } else {
      decoder = imglib.JpegDecoder();
    }
    var decoded = decoder.decodeImage(bytes);
    if (decoded != null) {
      slideImageBytes = imglib.encodeJpg(decoded, quality: 70);
      quality = decoded.width;
    } else {
      return bytes;
    }
    return slideImageBytes;
  }).pipe(_sc);
}