Browse Source

Use ScaleToTargetSize

pull/2301/head
James Jackson-South 3 years ago
parent
commit
afa204b139
  1. 2
      src/ImageSharp/Formats/Bmp/BmpDecoder.cs
  2. 2
      src/ImageSharp/Formats/Gif/GifDecoder.cs
  3. 4
      src/ImageSharp/Formats/ImageDecoder.cs
  4. 2
      src/ImageSharp/Formats/Jpeg/JpegDecoder.cs
  5. 2
      src/ImageSharp/Formats/Pbm/PbmDecoder.cs
  6. 2
      src/ImageSharp/Formats/Png/PngDecoder.cs
  7. 2
      src/ImageSharp/Formats/Tga/TgaDecoder.cs
  8. 2
      src/ImageSharp/Formats/Tiff/TiffDecoder.cs
  9. 2
      src/ImageSharp/Formats/Webp/WebpDecoder.cs

2
src/ImageSharp/Formats/Bmp/BmpDecoder.cs

@ -27,7 +27,7 @@ public sealed class BmpDecoder : SpecializedImageDecoder<BmpDecoderOptions>
Image<TPixel> image = new BmpDecoderCore(options).Decode<TPixel>(options.GeneralOptions.Configuration, stream, cancellationToken);
Resize(options.GeneralOptions, image);
ScaleToTargetSize(options.GeneralOptions, image);
return image;
}

2
src/ImageSharp/Formats/Gif/GifDecoder.cs

@ -28,7 +28,7 @@ public sealed class GifDecoder : ImageDecoder
GifDecoderCore decoder = new(options);
Image<TPixel> image = decoder.Decode<TPixel>(options.Configuration, stream, cancellationToken);
Resize(options, image);
ScaleToTargetSize(options, image);
return image;
}

4
src/ImageSharp/Formats/ImageDecoder.cs

@ -102,12 +102,12 @@ public abstract class ImageDecoder : IImageDecoder
protected abstract IImageInfo Identify(DecoderOptions options, Stream stream, CancellationToken cancellationToken);
/// <summary>
/// Performs a resize operation against the decoded image. If the target size is not set, or the image size
/// Performs a scaling operation against the decoded image. If the target size is not set, or the image size
/// already matches the target size, the image is untouched.
/// </summary>
/// <param name="options">The decoder options.</param>
/// <param name="image">The decoded image.</param>
protected static void Resize(DecoderOptions options, Image image)
protected static void ScaleToTargetSize(DecoderOptions options, Image image)
{
if (ShouldResize(options, image))
{

2
src/ImageSharp/Formats/Jpeg/JpegDecoder.cs

@ -31,7 +31,7 @@ public sealed class JpegDecoder : SpecializedImageDecoder<JpegDecoderOptions>
if (options.ResizeMode != JpegDecoderResizeMode.IdctOnly)
{
Resize(options.GeneralOptions, image);
ScaleToTargetSize(options.GeneralOptions, image);
}
return image;

2
src/ImageSharp/Formats/Pbm/PbmDecoder.cs

@ -44,7 +44,7 @@ public sealed class PbmDecoder : ImageDecoder
PbmDecoderCore decoder = new(options);
Image<TPixel> image = decoder.Decode<TPixel>(options.Configuration, stream, cancellationToken);
Resize(options, image);
ScaleToTargetSize(options, image);
return image;
}

2
src/ImageSharp/Formats/Png/PngDecoder.cs

@ -28,7 +28,7 @@ public sealed class PngDecoder : ImageDecoder
PngDecoderCore decoder = new(options);
Image<TPixel> image = decoder.Decode<TPixel>(options.Configuration, stream, cancellationToken);
Resize(options, image);
ScaleToTargetSize(options, image);
return image;
}

2
src/ImageSharp/Formats/Tga/TgaDecoder.cs

@ -28,7 +28,7 @@ public sealed class TgaDecoder : ImageDecoder
TgaDecoderCore decoder = new(options);
Image<TPixel> image = decoder.Decode<TPixel>(options.Configuration, stream, cancellationToken);
Resize(options, image);
ScaleToTargetSize(options, image);
return image;
}

2
src/ImageSharp/Formats/Tiff/TiffDecoder.cs

@ -28,7 +28,7 @@ public class TiffDecoder : ImageDecoder
TiffDecoderCore decoder = new(options);
Image<TPixel> image = decoder.Decode<TPixel>(options.Configuration, stream, cancellationToken);
Resize(options, image);
ScaleToTargetSize(options, image);
return image;
}

2
src/ImageSharp/Formats/Webp/WebpDecoder.cs

@ -29,7 +29,7 @@ public sealed class WebpDecoder : ImageDecoder
using WebpDecoderCore decoder = new(options);
Image<TPixel> image = decoder.Decode<TPixel>(options.Configuration, stream, cancellationToken);
Resize(options, image);
ScaleToTargetSize(options, image);
return image;
}

Loading…
Cancel
Save