public static ProcessImageResult ProcessImage(string imgPath, Stream outStream, ProcessImageSettings settings) { using var ctx = new PipelineContext(settings); ctx.ImageContainer = WicImageDecoder.Load(imgPath, ctx); return(processImage(ctx, outStream)); }
public static ProcessImageResult ProcessImage(Stream imgStream, Stream outStream, ProcessImageSettings settings) { using var ctx = new PipelineContext(settings); ctx.ImageContainer = ctx.AddDispose(WicImageDecoder.Load(imgStream)); return(processImage(ctx, outStream)); }
public static unsafe ProcessImageResult ProcessImage(ReadOnlySpan <byte> imgBuffer, Stream outStream, ProcessImageSettings settings) { fixed(byte *pbBuffer = imgBuffer) { using var ctx = new PipelineContext(settings); ctx.ImageContainer = ctx.AddDispose(WicImageDecoder.Load(pbBuffer, imgBuffer.Length)); return(processImage(ctx, outStream)); } }
/// <summary>Constructs a new <see cref="ImageFileInfo" /> instance by reading the metadata from an image file header.</summary> /// <param name="imgPath">The path to the image file.</param> public static ImageFileInfo Load(string imgPath) { var fi = new FileInfo(imgPath); if (!fi.Exists) { throw new FileNotFoundException("File not found", imgPath); } using var ctx = new PipelineContext(new ProcessImageSettings()); ctx.ImageContainer = WicImageDecoder.Load(imgPath, ctx); return(fromWicImage(ctx, fi.Length, fi.LastWriteTimeUtc)); }
/// <summary>Constructs a new <see cref="ImageFileInfo" /> instance by reading the metadata from an image file contained in a <see cref="ReadOnlySpan{T}" />.</summary> /// <param name="imgBuffer">The buffer containing the image data.</param> /// <param name="lastModified">The last modified date of the image container.</param> unsafe public static ImageFileInfo Load(ReadOnlySpan <byte> imgBuffer, DateTime lastModified) { if (imgBuffer == default) { throw new ArgumentNullException(nameof(imgBuffer)); fixed(byte *pbBuffer = imgBuffer) { using var ctx = new PipelineContext(new ProcessImageSettings()); ctx.ImageContainer = WicImageDecoder.Load(pbBuffer, imgBuffer.Length, ctx); return(fromWicImage(ctx, imgBuffer.Length, lastModified)); } }
/// <inheritdoc cref="BuildPipeline(string, ProcessImageSettings)" /> /// <param name="imgStream">A stream containing a supported input image container. The stream must allow Seek and Read.</param> public static ProcessingPipeline BuildPipeline(Stream imgStream, ProcessImageSettings settings) { if (settings is null) { throw new ArgumentNullException(nameof(settings)); } checkInStream(imgStream); var ctx = new PipelineContext(settings); ctx.ImageContainer = WicImageDecoder.Load(imgStream, ctx); buildPipeline(ctx, false); return(new ProcessingPipeline(ctx)); }
/// <inheritdoc cref="ProcessImage(string, Stream, ProcessImageSettings)" /> /// <param name="imgStream">A stream containing a supported input image container. The stream must allow Seek and Read.</param> public static ProcessImageResult ProcessImage(Stream imgStream, Stream outStream, ProcessImageSettings settings) { if (settings is null) { throw new ArgumentNullException(nameof(settings)); } checkInStream(imgStream); checkOutStream(outStream); using var ctx = new PipelineContext(settings); ctx.ImageContainer = WicImageDecoder.Load(imgStream, ctx); buildPipeline(ctx); return(WriteOutput(ctx, outStream)); }
/// <summary>Constructs a new <see cref="ImageFileInfo" /> instance by reading the metadata from an image file header.</summary> /// <param name="imgPath">The path to the image file.</param> public static ImageFileInfo Load(string imgPath) { var fi = new FileInfo(imgPath); if (!fi.Exists) { throw new FileNotFoundException("File not found", imgPath); } using var fs = File.OpenRead(imgPath); using var stb = new StreamBufferInjector(fs); using var ctx = new PipelineContext(new ProcessImageSettings()); ctx.ImageContainer = ctx.AddDispose(WicImageDecoder.Load(fs)); return(fromWicImage(ctx, fi.Length, fi.LastWriteTimeUtc)); }
/// <summary>Constructs a new processing pipeline from which pixels can be retrieved.</summary> /// <param name="imgPath">The path to a file containing the input image.</param> /// <param name="settings">The settings for this processing operation.</param> /// <returns>A <see cref="ProcessingPipeline" /> containing the <see cref="IPixelSource" />, settings used, and basic instrumentation for the pipeline.</returns> public static ProcessingPipeline BuildPipeline(string imgPath, ProcessImageSettings settings) { if (imgPath is null) { throw new ArgumentNullException(nameof(imgPath)); } if (settings is null) { throw new ArgumentNullException(nameof(settings)); } var ctx = new PipelineContext(settings); ctx.ImageContainer = WicImageDecoder.Load(imgPath, ctx); buildPipeline(ctx, false); return(new ProcessingPipeline(ctx)); }
/// <inheritdoc cref="BuildPipeline(string, ProcessImageSettings)" /> /// <param name="imgBuffer">A buffer containing a supported input image container.</param> unsafe public static ProcessingPipeline BuildPipeline(ReadOnlySpan <byte> imgBuffer, ProcessImageSettings settings) { if (imgBuffer == default) { throw new ArgumentNullException(nameof(imgBuffer)); } if (settings is null) { throw new ArgumentNullException(nameof(settings)); fixed(byte *pbBuffer = imgBuffer) { var ctx = new PipelineContext(settings); ctx.ImageContainer = WicImageDecoder.Load(pbBuffer, imgBuffer.Length, ctx, true); buildPipeline(ctx, false); return(new ProcessingPipeline(ctx)); } }
/// <summary>All-in-one processing of an image according to the specified <paramref name="settings" />.</summary> /// <param name="imgPath">The path to a file containing the input image.</param> /// <param name="outStream">The stream to which the output image will be written. The stream must allow Seek and Write.</param> /// <param name="settings">The settings for this processing operation.</param> /// <returns>A <see cref="ProcessImageResult" /> containing the settings used and basic instrumentation for the pipeline.</returns> public static ProcessImageResult ProcessImage(string imgPath, Stream outStream, ProcessImageSettings settings) { if (imgPath is null) { throw new ArgumentNullException(nameof(imgPath)); } if (settings is null) { throw new ArgumentNullException(nameof(settings)); } checkOutStream(outStream); using var fs = File.OpenRead(imgPath); using var stb = new StreamBufferInjector(fs); using var ctx = new PipelineContext(settings); ctx.ImageContainer = ctx.AddDispose(WicImageDecoder.Load(fs)); buildPipeline(ctx); return(WriteOutput(ctx, outStream)); }
#pragma warning disable 1573 // not all params have docs /// <inheritdoc cref="ProcessImage(string, Stream, ProcessImageSettings)" /> /// <param name="imgBuffer">A buffer containing a supported input image container.</param> unsafe public static ProcessImageResult ProcessImage(ReadOnlySpan <byte> imgBuffer, Stream outStream, ProcessImageSettings settings) { if (imgBuffer == default) { throw new ArgumentNullException(nameof(imgBuffer)); } if (settings is null) { throw new ArgumentNullException(nameof(settings)); } checkOutStream(outStream); fixed(byte *pbBuffer = imgBuffer) { using var ctx = new PipelineContext(settings); ctx.ImageContainer = WicImageDecoder.Load(pbBuffer, imgBuffer.Length, ctx); buildPipeline(ctx); return(WriteOutput(ctx, outStream)); } }
/// <summary>Constructs a new processing pipeline from which pixels can be retrieved.</summary> /// <param name="imgPath">The path to a file containing the input image.</param> /// <param name="settings">The settings for this processing operation.</param> /// <returns>A <see cref="ProcessingPipeline" /> containing the <see cref="IPixelSource" />, settings used, and basic instrumentation for the pipeline.</returns> public static ProcessingPipeline BuildPipeline(string imgPath, ProcessImageSettings settings) { if (imgPath is null) { throw new ArgumentNullException(nameof(imgPath)); } if (settings is null) { throw new ArgumentNullException(nameof(settings)); } var ctx = new PipelineContext(settings); var fs = ctx.AddDispose(File.OpenRead(imgPath)); ctx.AddDispose(new StreamBufferInjector(fs)); ctx.ImageContainer = ctx.AddDispose(WicImageDecoder.Load(fs)); buildPipeline(ctx, false); return(new ProcessingPipeline(ctx)); }