/// <summary> /// Encodes the image to the specified stream from the <see cref="Image{TColor}"/>. /// </summary> /// <typeparam name="TColor">The pixel format.</typeparam> /// <param name="image">The <see cref="Image{TColor}"/> to encode from.</param> /// <param name="stream">The <see cref="Stream"/> to encode the image data to.</param> /// <param name="options">The options for the encoder.</param> public void Encode <TColor>(Image <TColor> image, Stream stream, IJpegEncoderOptions options) where TColor : struct, IPixel <TColor> { JpegEncoderCore encode = new JpegEncoderCore(options); encode.Encode(image, stream); }
/// <inheritdoc/> public void Encode <TColor>(Image <TColor> image, Stream stream, IEncoderOptions options) where TColor : struct, IPixel <TColor> { IJpegEncoderOptions gifOptions = JpegEncoderOptions.Create(options); this.Encode(image, stream, gifOptions); }
public HomeController(IFileProvider fileProvider, IJpegEncoderOptions encoderOptions, IDistributedCache cache, ILogger <HomeController> logger) { _logger = logger; _encoderOptions = encoderOptions; _fileProvider = fileProvider; _cache = cache; }
/// <summary> /// Initializes a new instance of the <see cref="JpegEncoderCore"/> class. /// </summary> /// <param name="options">The options</param> public JpegEncoderCore(IJpegEncoderOptions options) { // System.Drawing produces identical output for jpegs with a quality parameter of 0 and 1. this.quality = options.Quality.Clamp(1, 100); this.subsample = options.Subsample ?? (this.quality >= 91 ? JpegSubsample.Ratio444 : JpegSubsample.Ratio420); this.ignoreMetadata = options.IgnoreMetadata; }
/// <summary> /// Initializes a new instance of the <see cref="JpegEncoderCore"/> class. /// </summary> /// <param name="options">The options.</param> public JpegEncoderCore(IJpegEncoderOptions options) { this.quality = options.Quality; if (IsSupportedColorType(options.ColorType)) { this.colorType = options.ColorType; } }
/// <summary> /// Initializes a new instance of the <see cref="JpegEncoderCore"/> class. /// </summary> /// <param name="options">The options</param> public JpegEncoderCore(IJpegEncoderOptions options) { int quality = options.Quality; if (quality == 0) { quality = 75; } this.quality = quality; this.subsample = options.Subsample ?? (quality >= 91 ? JpegSubsample.Ratio444 : JpegSubsample.Ratio420); this.ignoreMetadata = options.IgnoreMetadata; }
/// <summary> /// Initializes a new instance of the <see cref="JpegEncoderCore"/> class. /// </summary> /// <param name="options">The options</param> public JpegEncoderCore(IJpegEncoderOptions options) { this.quality = options.Quality; this.subsample = options.Subsample; }
public HomeController(IHostingEnvironment env, IJpegEncoderOptions encoderOptions) { _encoderOptions = encoderOptions; _fileProvider = env.WebRootFileProvider; }
/// <summary> /// Saves the image to the given stream with the jpeg format. /// </summary> /// <typeparam name="TPixel">The pixel format.</typeparam> /// <param name="source">The image this method extends.</param> /// <param name="stream">The stream to save the image to.</param> /// <param name="options">The options for the encoder.</param> /// <exception cref="System.ArgumentNullException">Thrown if the stream is null.</exception> /// <returns> /// The <see cref="Image{TPixel}"/>. /// </returns> public static Image <TPixel> SaveAsJpeg <TPixel>(this Image <TPixel> source, Stream stream, IJpegEncoderOptions options) where TPixel : struct, IPixel <TPixel> { JpegEncoder encoder = new JpegEncoder(); encoder.Encode(source, stream, options); return(source); }
/// <summary> /// Initializes a new instance of the <see cref="JpegEncoderCore"/> class. /// </summary> /// <param name="options">The options for the encoder.</param> public JpegEncoderCore(IJpegEncoderOptions options) { this.options = options ?? new JpegEncoderOptions(); }