• Articles
  • API Documentation
  • SixLabors.ImageSharp
  • Image
Search Results for

    Show / Hide Table of Contents
    • SixLabors.ImageSharp
      • ByteOrder
      • Color
      • ColorMatrix
      • Configuration
      • DenseMatrix<T>
      • GeometryUtilities
      • GraphicOptionsDefaultsExtensions
      • GraphicsOptions
      • IDeepCloneable
      • IDeepCloneable<T>
      • Image
      • ImageExtensions
      • ImageFormatException
      • ImageFrame
      • ImageFrameCollection
      • ImageFrameCollectionExtensions
      • ImageFrameCollection<TPixel>
      • ImageFrame<TPixel>
      • ImageInfo
      • ImageProcessingException
      • Image<TPixel>
      • IndexedImageFrame<TPixel>
      • InvalidImageContentException
      • Matrix3x2Extensions
      • MetadataExtensions
      • Number
      • PixelAccessorAction<TPixel>
      • PixelAccessorAction<TPixel1, TPixel2>
      • PixelAccessorAction<TPixel1, TPixel2, TPixel3>
      • PixelAccessor<TPixel>
      • Point
      • PointF
      • Rational
      • ReadOrigin
      • Rectangle
      • RectangleF
      • SignedRational
      • Size
      • SizeF
      • UnknownImageFormatException
    • SixLabors.ImageSharp.Advanced
      • AdvancedImageExtensions
      • IConfigurationProvider
      • IImageVisitor
      • IImageVisitorAsync
      • IRowIntervalOperation
      • IRowIntervalOperation<TBuffer>
      • IRowOperation
      • IRowOperation<TBuffer>
      • ParallelExecutionSettings
      • ParallelRowIterator
    • SixLabors.ImageSharp.ColorSpaces
      • CieLab
      • CieLch
      • CieLchuv
      • CieLuv
      • CieXyy
      • CieXyz
      • Cmyk
      • Hsl
      • Hsv
      • HunterLab
      • Illuminants
      • LinearRgb
      • Lms
      • Rgb
      • RgbWorkingSpaces
      • YCbCr
    • SixLabors.ImageSharp.ColorSpaces.Companding
      • GammaCompanding
      • LCompanding
      • Rec2020Companding
      • Rec709Companding
      • SRgbCompanding
    • SixLabors.ImageSharp.ColorSpaces.Conversion
      • CieXyChromaticityCoordinates
      • ColorSpaceConverter
      • ColorSpaceConverterOptions
      • GammaWorkingSpace
      • IChromaticAdaptation
      • LWorkingSpace
      • LmsAdaptationMatrix
      • Rec2020WorkingSpace
      • Rec709WorkingSpace
      • RgbPrimariesChromaticityCoordinates
      • RgbWorkingSpace
      • SRgbWorkingSpace
      • VonKriesChromaticAdaptation
    • SixLabors.ImageSharp.Compression.Zlib
      • DeflateCompressionLevel
    • SixLabors.ImageSharp.Diagnostics
      • MemoryDiagnostics
      • UndisposedAllocationDelegate
    • SixLabors.ImageSharp.Formats
      • DecoderOptions
      • IImageDecoder
      • IImageEncoder
      • IImageFormat
      • IImageFormatConfigurationModule
      • IImageFormatDetector
      • IImageFormat<TFormatMetadata>
      • IImageFormat<TFormatMetadata, TFormatFrameMetadata>
      • ISpecializedDecoderOptions
      • ISpecializedImageDecoder<T>
      • ImageDecoder
      • ImageEncoder
      • ImageFormatManager
      • PixelTypeInfo
      • QuantizingImageEncoder
      • SpecializedImageDecoder<T>
    • SixLabors.ImageSharp.Formats.Bmp
      • BmpBitsPerPixel
      • BmpConfigurationModule
      • BmpDecoder
      • BmpDecoderOptions
      • BmpEncoder
      • BmpFileMarkerType
      • BmpFormat
      • BmpImageFormatDetector
      • BmpInfoHeaderType
      • BmpMetadata
      • RleSkippedPixelHandling
    • SixLabors.ImageSharp.Formats.Gif
      • GifColorTableMode
      • GifConfigurationModule
      • GifDecoder
      • GifDisposalMethod
      • GifEncoder
      • GifFormat
      • GifFrameMetadata
      • GifImageFormatDetector
      • GifMetadata
      • IGifExtension
    • SixLabors.ImageSharp.Formats.Jpeg
      • JpegConfigurationModule
      • JpegDecoder
      • JpegDecoderOptions
      • JpegDecoderResizeMode
      • JpegEncoder
      • JpegEncodingColor
      • JpegFormat
      • JpegImageFormatDetector
      • JpegMetadata
    • SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder
      • HuffmanSpec
    • SixLabors.ImageSharp.Formats.Pbm
      • PbmColorType
      • PbmComponentType
      • PbmConfigurationModule
      • PbmDecoder
      • PbmEncoder
      • PbmEncoding
      • PbmFormat
      • PbmImageFormatDetector
      • PbmMetadata
    • SixLabors.ImageSharp.Formats.Png
      • PngBitDepth
      • PngBlendMethod
      • PngChunkFilter
      • PngColorType
      • PngConfigurationModule
      • PngCrcChunkHandling
      • PngDecoder
      • PngDecoderOptions
      • PngDisposalMethod
      • PngEncoder
      • PngFilterMethod
      • PngFormat
      • PngFrameMetadata
      • PngImageFormatDetector
      • PngInterlaceMode
      • PngMetadata
      • PngTransparentColorMode
    • SixLabors.ImageSharp.Formats.Png.Chunks
      • PngTextData
    • SixLabors.ImageSharp.Formats.Qoi
      • QoiChannels
      • QoiColorSpace
      • QoiConfigurationModule
      • QoiEncoder
      • QoiFormat
      • QoiImageFormatDetector
      • QoiMetadata
    • SixLabors.ImageSharp.Formats.Tga
      • TgaBitsPerPixel
      • TgaCompression
      • TgaConfigurationModule
      • TgaDecoder
      • TgaEncoder
      • TgaFormat
      • TgaImageFormatDetector
      • TgaImageType
      • TgaImageTypeExtensions
      • TgaMetadata
    • SixLabors.ImageSharp.Formats.Tiff
      • TiffBitsPerPixel
      • TiffBitsPerSample
      • TiffConfigurationModule
      • TiffDecoder
      • TiffEncoder
      • TiffFormat
      • TiffFormatType
      • TiffFrameMetadata
      • TiffImageFormatDetector
      • TiffMetadata
    • SixLabors.ImageSharp.Formats.Tiff.Compression
      • FaxCompressionOptions
    • SixLabors.ImageSharp.Formats.Tiff.Compression.Decompressors
      • LzwString
    • SixLabors.ImageSharp.Formats.Tiff.Constants
      • TiffCompression
      • TiffInkSet
      • TiffNewSubfileType
      • TiffPhotometricInterpretation
      • TiffPlanarConfiguration
      • TiffPredictor
      • TiffSampleFormat
      • TiffSubfileType
    • SixLabors.ImageSharp.Formats.Webp
      • BackgroundColorHandling
      • WebpBitsPerPixel
      • WebpBlendMethod
      • WebpConfigurationModule
      • WebpDecoder
      • WebpDecoderOptions
      • WebpDisposalMethod
      • WebpEncoder
      • WebpEncodingMethod
      • WebpFileFormatType
      • WebpFormat
      • WebpFrameMetadata
      • WebpImageFormatDetector
      • WebpMetadata
      • WebpTransparentColorMode
    • SixLabors.ImageSharp.Memory
      • AllocationOptions
      • Buffer2DExtensions
      • Buffer2DRegion<T>
      • Buffer2D<T>
      • IMemoryGroup<T>
      • InvalidMemoryOperationException
      • MemoryAllocator
      • MemoryAllocatorExtensions
      • MemoryAllocatorOptions
      • RowInterval
      • SimpleGcMemoryAllocator
    • SixLabors.ImageSharp.Metadata
      • ImageFrameMetadata
      • ImageMetadata
      • PixelResolutionUnit
    • SixLabors.ImageSharp.Metadata.Profiles.Cicp
      • CicpColorPrimaries
      • CicpMatrixCoefficients
      • CicpProfile
      • CicpTransferCharacteristics
    • SixLabors.ImageSharp.Metadata.Profiles.Exif
      • EncodedString
      • EncodedString.CharacterCode
      • ExifDataType
      • ExifOrientationMode
      • ExifParts
      • ExifProfile
      • ExifTag
      • ExifTag<TValueType>
      • IExifValue
      • IExifValue<TValueType>
    • SixLabors.ImageSharp.Metadata.Profiles.Icc
      • IccColorSpaceType
      • IccDeviceAttribute
      • IccPrimaryPlatformType
      • IccProfile
      • IccProfileClass
      • IccProfileFlag
      • IccProfileHeader
      • IccProfileId
      • IccProfileTag
      • IccRenderingIntent
      • IccTagDataEntry
      • IccTypeSignature
      • IccVersion
      • InvalidIccProfileException
    • SixLabors.ImageSharp.Metadata.Profiles.Iptc
      • IptcProfile
      • IptcTag
      • IptcTagExtensions
      • IptcValue
    • SixLabors.ImageSharp.Metadata.Profiles.Xmp
      • XmpProfile
    • SixLabors.ImageSharp.PixelFormats
      • A8
      • Abgr32
      • Argb32
      • Bgr24
      • Bgr565
      • Bgra32
      • Bgra4444
      • Bgra5551
      • Byte4
      • HalfSingle
      • HalfVector2
      • HalfVector4
      • IPackedVector<TPacked>
      • IPixel
      • IPixel<TSelf>
      • L16
      • L8
      • La16
      • La32
      • NormalizedByte2
      • NormalizedByte4
      • NormalizedShort2
      • NormalizedShort4
      • PixelAlphaCompositionMode
      • PixelAlphaRepresentation
      • PixelBlender<TPixel>
      • PixelColorBlendingMode
      • PixelConversionModifiers
      • PixelOperations<TPixel>
      • Rg32
      • Rgb24
      • Rgb48
      • Rgba1010102
      • Rgba32
      • Rgba64
      • RgbaVector
      • Short2
      • Short4
    • SixLabors.ImageSharp.Processing
      • AdaptiveThresholdExtensions
      • AffineTransformBuilder
      • AnchorPositionMode
      • AutoOrientExtensions
      • BackgroundColorExtensions
      • BinaryDitherExtensions
      • BinaryThresholdExtensions
      • BinaryThresholdMode
      • BlackWhiteExtensions
      • BokehBlurExtensions
      • BoxBlurExtensions
      • BrightnessExtensions
      • ColorBlindnessExtensions
      • ColorBlindnessMode
      • ContrastExtensions
      • CropExtensions
      • DetectEdgesExtensions
      • DitherExtensions
      • DrawImageExtensions
      • EntropyCropExtensions
      • FilterExtensions
      • FlipExtensions
      • FlipMode
      • GaussianBlurExtensions
      • GaussianSharpenExtensions
      • GlowExtensions
      • GrayscaleExtensions
      • GrayscaleMode
      • HistogramEqualizationExtensions
      • HueExtensions
      • IImageProcessingContext
      • InvertExtensions
      • KnownDitherings
      • KnownEdgeDetectorKernels
      • KnownFilterMatrices
      • KnownQuantizers
      • KnownResamplers
      • KodachromeExtensions
      • LightnessExtensions
      • LomographExtensions
      • MedianBlurExtensions
      • OilPaintExtensions
      • OpacityExtensions
      • PadExtensions
      • PixelRowDelegateExtensions
      • PixelRowOperation
      • PixelRowOperation<T>
      • PixelateExtensions
      • PolaroidExtensions
      • ProcessingExtensions
      • ProjectiveTransformBuilder
      • QuantizeExtensions
      • ResizeExtensions
      • ResizeMode
      • ResizeOptions
      • RotateExtensions
      • RotateFlipExtensions
      • RotateMode
      • SaturateExtensions
      • SepiaExtensions
      • SkewExtensions
      • SwizzleExtensions
      • TaperCorner
      • TaperSide
      • TransformExtensions
      • TransformSpace
      • VignetteExtensions
    • SixLabors.ImageSharp.Processing.Processors
      • CloningImageProcessor
      • CloningImageProcessor<TPixel>
      • ICloningImageProcessor
      • ICloningImageProcessor<TPixel>
      • IImageProcessor
      • IImageProcessor<TPixel>
      • ImageProcessor<TPixel>
    • SixLabors.ImageSharp.Processing.Processors.Binarization
      • AdaptiveThresholdProcessor
      • BinaryThresholdProcessor
    • SixLabors.ImageSharp.Processing.Processors.Convolution
      • BokehBlurProcessor
      • BorderWrappingMode
      • BoxBlurProcessor
      • EdgeDetector2DKernel
      • EdgeDetector2DProcessor
      • EdgeDetectorCompassKernel
      • EdgeDetectorCompassProcessor
      • EdgeDetectorKernel
      • EdgeDetectorProcessor
      • GaussianBlurProcessor
      • GaussianSharpenProcessor
      • MedianBlurProcessor
    • SixLabors.ImageSharp.Processing.Processors.Dithering
      • ErrorDither
      • IDither
      • IPaletteDitherImageProcessor<TPixel>
      • OrderedDither
      • PaletteDitherProcessor
    • SixLabors.ImageSharp.Processing.Processors.Drawing
      • DrawImageProcessor
    • SixLabors.ImageSharp.Processing.Processors.Effects
      • IPixelRowDelegate
      • OilPaintingProcessor
      • PixelateProcessor
    • SixLabors.ImageSharp.Processing.Processors.Filters
      • AchromatomalyProcessor
      • AchromatopsiaProcessor
      • BlackWhiteProcessor
      • BrightnessProcessor
      • ContrastProcessor
      • DeuteranomalyProcessor
      • DeuteranopiaProcessor
      • FilterProcessor
      • GrayscaleBt601Processor
      • GrayscaleBt709Processor
      • HueProcessor
      • InvertProcessor
      • KodachromeProcessor
      • LightnessProcessor
      • LomographProcessor
      • OpacityProcessor
      • PolaroidProcessor
      • ProtanomalyProcessor
      • ProtanopiaProcessor
      • SaturateProcessor
      • SepiaProcessor
      • TritanomalyProcessor
      • TritanopiaProcessor
    • SixLabors.ImageSharp.Processing.Processors.Normalization
      • AdaptiveHistogramEqualizationProcessor
      • AdaptiveHistogramEqualizationSlidingWindowProcessor
      • AutoLevelProcessor
      • GlobalHistogramEqualizationProcessor
      • HistogramEqualizationMethod
      • HistogramEqualizationOptions
      • HistogramEqualizationProcessor
    • SixLabors.ImageSharp.Processing.Processors.Overlays
      • BackgroundColorProcessor
      • GlowProcessor
      • VignetteProcessor
    • SixLabors.ImageSharp.Processing.Processors.Quantization
      • ColorMatchingMode
      • DefaultPixelSamplingStrategy
      • ExtensivePixelSamplingStrategy
      • IPixelSamplingStrategy
      • IQuantizer
      • IQuantizer<TPixel>
      • OctreeQuantizer
      • OctreeQuantizer<TPixel>
      • PaletteQuantizer
      • QuantizeProcessor
      • QuantizerConstants
      • QuantizerOptions
      • QuantizerUtilities
      • WebSafePaletteQuantizer
      • WernerPaletteQuantizer
      • WuQuantizer
    • SixLabors.ImageSharp.Processing.Processors.Transforms
      • AffineTransformProcessor
      • AutoOrientProcessor
      • BicubicResampler
      • BoxResampler
      • CropProcessor
      • CubicResampler
      • DegenerateTransformException
      • EntropyCropProcessor
      • FlipProcessor
      • IResampler
      • IResamplingTransformImageProcessor<TPixel>
      • ISwizzler
      • LanczosResampler
      • NearestNeighborResampler
      • ProjectiveTransformProcessor
      • ResizeProcessor
      • RotateProcessor
      • SkewProcessor
      • SwizzleProcessor<TSwizzler>
      • TriangleResampler
      • WelchResampler

    Class Image

    Encapsulates an image, which consists of the pixel data for a graphics image and its attributes. For the non-generic Image type, the pixel type is only known at runtime. Image is always implemented by a pixel-specific Image<TPixel> instance.

    Inheritance
    object
    Image
    Image<TPixel>
    Implements
    IDisposable
    IConfigurationProvider
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: SixLabors.ImageSharp
    Assembly: SixLabors.ImageSharp.dll
    Syntax
    public abstract class Image : IDisposable, IConfigurationProvider

    Constructors

    | Edit this page View Source

    Image(Configuration, PixelTypeInfo, ImageMetadata, Size)

    Initializes a new instance of the Image class.

    Declaration
    protected Image(Configuration configuration, PixelTypeInfo pixelType, ImageMetadata metadata, Size size)
    Parameters
    Type Name Description
    Configuration configuration

    The global configuration..

    PixelTypeInfo pixelType

    The pixel type information.

    ImageMetadata metadata

    The image metadata.

    Size size

    The size in px units.

    Properties

    | Edit this page View Source

    Bounds

    Gets the bounds of the image.

    Declaration
    public Rectangle Bounds { get; }
    Property Value
    Type Description
    Rectangle
    | Edit this page View Source

    Configuration

    Gets the configuration which allows altering default behaviour or extending the library.

    Declaration
    public Configuration Configuration { get; }
    Property Value
    Type Description
    Configuration
    | Edit this page View Source

    Frames

    Gets the frames of the image as (non-generic) ImageFrameCollection.

    Declaration
    public ImageFrameCollection Frames { get; }
    Property Value
    Type Description
    ImageFrameCollection
    | Edit this page View Source

    Height

    Gets the image height in px units.

    Declaration
    public int Height { get; }
    Property Value
    Type Description
    int
    | Edit this page View Source

    Metadata

    Gets any metadata associated with the image.

    Declaration
    public ImageMetadata Metadata { get; }
    Property Value
    Type Description
    ImageMetadata
    | Edit this page View Source

    NonGenericFrameCollection

    Gets the ImageFrameCollection implementing the public Frames property.

    Declaration
    protected abstract ImageFrameCollection NonGenericFrameCollection { get; }
    Property Value
    Type Description
    ImageFrameCollection
    | Edit this page View Source

    PixelType

    Gets information about the image pixels.

    Declaration
    public PixelTypeInfo PixelType { get; }
    Property Value
    Type Description
    PixelTypeInfo
    | Edit this page View Source

    Size

    Gets the size of the image in px units.

    Declaration
    public Size Size { get; }
    Property Value
    Type Description
    Size
    | Edit this page View Source

    Width

    Gets the image width in px units.

    Declaration
    public int Width { get; }
    Property Value
    Type Description
    int

    Methods

    | Edit this page View Source

    CloneAs<TPixel2>()

    Returns a copy of the image in the given pixel format.

    Declaration
    public Image<TPixel2> CloneAs<TPixel2>() where TPixel2 : unmanaged, IPixel<TPixel2>
    Returns
    Type Description
    Image<TPixel2>

    The Image<TPixel>

    Type Parameters
    Name Description
    TPixel2

    The pixel format.

    | Edit this page View Source

    CloneAs<TPixel2>(Configuration)

    Returns a copy of the image in the given pixel format.

    Declaration
    public abstract Image<TPixel2> CloneAs<TPixel2>(Configuration configuration) where TPixel2 : unmanaged, IPixel<TPixel2>
    Parameters
    Type Name Description
    Configuration configuration

    The configuration providing initialization code which allows extending the library.

    Returns
    Type Description
    Image<TPixel2>

    The Image<TPixel>.

    Type Parameters
    Name Description
    TPixel2

    The pixel format.

    | Edit this page View Source

    DetectFormat(DecoderOptions, Stream)

    Detects the encoded image format type from the specified stream.

    Declaration
    public static IImageFormat DetectFormat(DecoderOptions options, Stream stream)
    Parameters
    Type Name Description
    DecoderOptions options

    The general decoder options.

    Stream stream

    The image stream to read the header from.

    Returns
    Type Description
    IImageFormat

    The IImageFormat.

    Exceptions
    Type Condition
    ArgumentNullException

    The options are null.

    ArgumentNullException

    The stream is null.

    NotSupportedException

    The stream is not readable or the image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    DetectFormat(DecoderOptions, ReadOnlySpan<byte>)

    By reading the header on the provided byte span this calculates the images format.

    Declaration
    public static IImageFormat DetectFormat(DecoderOptions options, ReadOnlySpan<byte> buffer)
    Parameters
    Type Name Description
    DecoderOptions options

    The general decoder options.

    ReadOnlySpan<byte> buffer

    The byte span containing encoded image data to read the header from.

    Returns
    Type Description
    IImageFormat

    The IImageFormat.

    Exceptions
    Type Condition
    ArgumentNullException

    The options are null.

    NotSupportedException

    The image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    DetectFormat(DecoderOptions, string)

    Detects the encoded image format type from the specified file.

    Declaration
    public static IImageFormat DetectFormat(DecoderOptions options, string path)
    Parameters
    Type Name Description
    DecoderOptions options

    The general decoder options.

    string path

    The image file to open and to read the header from.

    Returns
    Type Description
    IImageFormat

    The IImageFormat.

    Exceptions
    Type Condition
    ArgumentNullException

    The options are null.

    ArgumentNullException

    The path is null.

    NotSupportedException

    The file stream is not readable or the image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    DetectFormat(Stream)

    Detects the encoded image format type from the specified stream.

    Declaration
    public static IImageFormat DetectFormat(Stream stream)
    Parameters
    Type Name Description
    Stream stream

    The image stream to read the header from.

    Returns
    Type Description
    IImageFormat

    The IImageFormat.

    Exceptions
    Type Condition
    ArgumentNullException

    The stream is null.

    NotSupportedException

    The stream is not readable or the image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    DetectFormat(ReadOnlySpan<byte>)

    By reading the header on the provided byte span this calculates the images format.

    Declaration
    public static IImageFormat DetectFormat(ReadOnlySpan<byte> buffer)
    Parameters
    Type Name Description
    ReadOnlySpan<byte> buffer

    The byte span containing encoded image data to read the header from.

    Returns
    Type Description
    IImageFormat

    The IImageFormat.

    Exceptions
    Type Condition
    NotSupportedException

    The image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    DetectFormat(string)

    Detects the encoded image format type from the specified file.

    Declaration
    public static IImageFormat DetectFormat(string path)
    Parameters
    Type Name Description
    string path

    The image file to open and to read the header from.

    Returns
    Type Description
    IImageFormat

    The IImageFormat.

    Exceptions
    Type Condition
    ArgumentNullException

    The path is null.

    NotSupportedException

    The file stream is not readable or the image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    DetectFormatAsync(DecoderOptions, Stream, CancellationToken)

    Detects the encoded image format type from the specified stream.

    Declaration
    public static Task<IImageFormat> DetectFormatAsync(DecoderOptions options, Stream stream, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    DecoderOptions options

    The general decoder options.

    Stream stream

    The image stream to read the header from.

    CancellationToken cancellationToken

    The token to monitor for cancellation requests.

    Returns
    Type Description
    Task<IImageFormat>

    A Task<TResult> representing the asynchronous operation.

    Exceptions
    Type Condition
    ArgumentNullException

    The options are null.

    ArgumentNullException

    The stream is null.

    NotSupportedException

    The stream is not readable or the image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    DetectFormatAsync(DecoderOptions, string, CancellationToken)

    Detects the encoded image format type from the specified file.

    Declaration
    public static Task<IImageFormat> DetectFormatAsync(DecoderOptions options, string path, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    DecoderOptions options

    The general decoder options.

    string path

    The image file to open and to read the header from.

    CancellationToken cancellationToken

    The token to monitor for cancellation requests.

    Returns
    Type Description
    Task<IImageFormat>

    A Task<TResult> representing the asynchronous operation.

    Exceptions
    Type Condition
    ArgumentNullException

    The options are null.

    ArgumentNullException

    The path is null.

    NotSupportedException

    The file stream is not readable or the image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    DetectFormatAsync(Stream, CancellationToken)

    Detects the encoded image format type from the specified stream.

    Declaration
    public static Task<IImageFormat> DetectFormatAsync(Stream stream, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    Stream stream

    The image stream to read the header from.

    CancellationToken cancellationToken

    The token to monitor for cancellation requests.

    Returns
    Type Description
    Task<IImageFormat>

    A Task<TResult> representing the asynchronous operation.

    Exceptions
    Type Condition
    ArgumentNullException

    The stream is null.

    NotSupportedException

    The stream is not readable or the image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    DetectFormatAsync(string, CancellationToken)

    Detects the encoded image format type from the specified file.

    Declaration
    public static Task<IImageFormat> DetectFormatAsync(string path, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    string path

    The image file to open and to read the header from.

    CancellationToken cancellationToken

    The token to monitor for cancellation requests.

    Returns
    Type Description
    Task<IImageFormat>

    A Task<TResult> representing the asynchronous operation.

    | Edit this page View Source

    Dispose()

    Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

    Declaration
    public void Dispose()
    | Edit this page View Source

    Dispose(bool)

    Disposes the object and frees resources for the Garbage Collector.

    Declaration
    protected abstract void Dispose(bool disposing)
    Parameters
    Type Name Description
    bool disposing

    Whether to dispose of managed and unmanaged objects.

    | Edit this page View Source

    Identify(DecoderOptions, Stream)

    Reads the raw image information from the specified stream without fully decoding it.

    Declaration
    public static ImageInfo Identify(DecoderOptions options, Stream stream)
    Parameters
    Type Name Description
    DecoderOptions options

    The general decoder options.

    Stream stream

    The image stream to read the information from.

    Returns
    Type Description
    ImageInfo

    The ImageInfo.

    Exceptions
    Type Condition
    ArgumentNullException

    The options are null.

    ArgumentNullException

    The stream is null.

    NotSupportedException

    The stream is not readable or the image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    Identify(DecoderOptions, ReadOnlySpan<byte>)

    Reads the raw image information from the specified span of bytes without fully decoding it.

    Declaration
    public static ImageInfo Identify(DecoderOptions options, ReadOnlySpan<byte> buffer)
    Parameters
    Type Name Description
    DecoderOptions options

    The general decoder options.

    ReadOnlySpan<byte> buffer

    The byte span containing encoded image data to read the header from.

    Returns
    Type Description
    ImageInfo

    The ImageInfo.

    Exceptions
    Type Condition
    ArgumentNullException

    The options are null.

    NotSupportedException

    The image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    Identify(DecoderOptions, string)

    Reads the raw image information from the specified file path without fully decoding it.

    Declaration
    public static ImageInfo Identify(DecoderOptions options, string path)
    Parameters
    Type Name Description
    DecoderOptions options

    The general decoder options.

    string path

    The image file to open and to read the header from.

    Returns
    Type Description
    ImageInfo

    The ImageInfo.

    Exceptions
    Type Condition
    ArgumentNullException

    The options are null.

    ArgumentNullException

    The path is null.

    NotSupportedException

    The file stream is not readable or the image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    Identify(Stream)

    Reads the raw image information from the specified stream without fully decoding it.

    Declaration
    public static ImageInfo Identify(Stream stream)
    Parameters
    Type Name Description
    Stream stream

    The image stream to read the header from.

    Returns
    Type Description
    ImageInfo

    The ImageInfo.

    Exceptions
    Type Condition
    ArgumentNullException

    The stream is null.

    NotSupportedException

    The stream is not readable or the image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    Identify(ReadOnlySpan<byte>)

    Reads the raw image information from the specified stream without fully decoding it.

    Declaration
    public static ImageInfo Identify(ReadOnlySpan<byte> buffer)
    Parameters
    Type Name Description
    ReadOnlySpan<byte> buffer

    The byte array containing encoded image data to read the header from.

    Returns
    Type Description
    ImageInfo

    The ImageInfo.

    Exceptions
    Type Condition
    NotSupportedException

    The image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    Identify(string)

    Reads the raw image information from the specified file path without fully decoding it. A return value indicates whether the operation succeeded.

    Declaration
    public static ImageInfo Identify(string path)
    Parameters
    Type Name Description
    string path

    The image file to open and to read the header from.

    Returns
    Type Description
    ImageInfo

    The ImageInfo.

    Exceptions
    Type Condition
    ArgumentNullException

    The path is null.

    NotSupportedException

    The file stream is not readable or the image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    IdentifyAsync(DecoderOptions, Stream, CancellationToken)

    Reads the raw image information from the specified stream without fully decoding it.

    Declaration
    public static Task<ImageInfo> IdentifyAsync(DecoderOptions options, Stream stream, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    DecoderOptions options

    The general decoder options.

    Stream stream

    The image stream to read the information from.

    CancellationToken cancellationToken

    The token to monitor for cancellation requests.

    Returns
    Type Description
    Task<ImageInfo>

    The Task<TResult> representing the asynchronous operation.

    Exceptions
    Type Condition
    ArgumentNullException

    The options are null.

    ArgumentNullException

    The stream is null.

    NotSupportedException

    The stream is not readable or the image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    IdentifyAsync(DecoderOptions, string, CancellationToken)

    Reads the raw image information from the specified stream without fully decoding it.

    Declaration
    public static Task<ImageInfo> IdentifyAsync(DecoderOptions options, string path, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    DecoderOptions options

    The general decoder options.

    string path

    The image file to open and to read the header from.

    CancellationToken cancellationToken

    The token to monitor for cancellation requests.

    Returns
    Type Description
    Task<ImageInfo>

    The Task<TResult> representing the asynchronous operation.

    Exceptions
    Type Condition
    ArgumentNullException

    The options are null.

    ArgumentNullException

    The path is null.

    NotSupportedException

    The file stream is not readable or the image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    IdentifyAsync(Stream, CancellationToken)

    Reads the raw image information from the specified stream without fully decoding it.

    Declaration
    public static Task<ImageInfo> IdentifyAsync(Stream stream, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    Stream stream

    The image stream to read the information from.

    CancellationToken cancellationToken

    The token to monitor for cancellation requests.

    Returns
    Type Description
    Task<ImageInfo>

    The Task<TResult> representing the asynchronous operation.

    Exceptions
    Type Condition
    ArgumentNullException

    The stream is null.

    NotSupportedException

    The stream is not readable or the image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    IdentifyAsync(string, CancellationToken)

    Reads the raw image information from the specified stream without fully decoding it.

    Declaration
    public static Task<ImageInfo> IdentifyAsync(string path, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    string path

    The image file to open and to read the header from.

    CancellationToken cancellationToken

    The token to monitor for cancellation requests.

    Returns
    Type Description
    Task<ImageInfo>

    The Task<TResult> representing the asynchronous operation.

    Exceptions
    Type Condition
    ArgumentNullException

    The options are null.

    ArgumentNullException

    The path is null.

    NotSupportedException

    The file stream is not readable or the image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    Load(DecoderOptions, Stream)

    Creates a new instance of the Image class from the given stream. The pixel format is automatically determined by the decoder.

    Declaration
    public static Image Load(DecoderOptions options, Stream stream)
    Parameters
    Type Name Description
    DecoderOptions options

    The general decoder options.

    Stream stream

    The stream containing image information.

    Returns
    Type Description
    Image

    Image.

    Exceptions
    Type Condition
    ArgumentNullException

    The options are null.

    ArgumentNullException

    The stream is null.

    NotSupportedException

    The stream is not readable or the image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    Load(DecoderOptions, ReadOnlySpan<byte>)

    Creates a new instance of the Image class from the given byte span. The pixel format is automatically determined by the decoder.

    Declaration
    public static Image Load(DecoderOptions options, ReadOnlySpan<byte> buffer)
    Parameters
    Type Name Description
    DecoderOptions options

    The general decoder options.

    ReadOnlySpan<byte> buffer

    The byte span containing encoded image data.

    Returns
    Type Description
    Image

    Image.

    Exceptions
    Type Condition
    ArgumentNullException

    The options are null.

    NotSupportedException

    The image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    Load(DecoderOptions, string)

    Creates a new instance of the Image class from the given file path. The pixel format is automatically determined by the decoder.

    Declaration
    public static Image Load(DecoderOptions options, string path)
    Parameters
    Type Name Description
    DecoderOptions options

    The general decoder options.

    string path

    The file path to the image.

    Returns
    Type Description
    Image

    Image.

    Exceptions
    Type Condition
    ArgumentNullException

    The options are null.

    ArgumentNullException

    The path is null.

    NotSupportedException

    The file stream is not readable or the image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    Load(Stream)

    Creates a new instance of the Image class from the given stream. The pixel format is automatically determined by the decoder.

    Declaration
    public static Image Load(Stream stream)
    Parameters
    Type Name Description
    Stream stream

    The stream containing image information.

    Returns
    Type Description
    Image

    Image.

    Exceptions
    Type Condition
    ArgumentNullException

    The stream is null.

    NotSupportedException

    The stream is not readable or the image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    Load(ReadOnlySpan<byte>)

    Creates a new instance of the Image class from the given byte span. The pixel format is automatically determined by the decoder.

    Declaration
    public static Image Load(ReadOnlySpan<byte> buffer)
    Parameters
    Type Name Description
    ReadOnlySpan<byte> buffer

    The byte span containing encoded image data.

    Returns
    Type Description
    Image

    Image.

    Exceptions
    Type Condition
    NotSupportedException

    The image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    Load(string)

    Creates a new instance of the Image class from the given file path. The pixel format is automatically determined by the decoder.

    Declaration
    public static Image Load(string path)
    Parameters
    Type Name Description
    string path

    The file path to the image.

    Returns
    Type Description
    Image

    Image.

    Exceptions
    Type Condition
    ArgumentNullException

    The path is null.

    NotSupportedException

    The file stream is not readable or the image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    LoadAsync(DecoderOptions, Stream, CancellationToken)

    Creates a new instance of the Image class from the given stream. The pixel format is automatically determined by the decoder.

    Declaration
    public static Task<Image> LoadAsync(DecoderOptions options, Stream stream, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    DecoderOptions options

    The general decoder options.

    Stream stream

    The stream containing image information.

    CancellationToken cancellationToken

    The token to monitor for cancellation requests.

    Returns
    Type Description
    Task<Image>

    A Task<TResult> representing the asynchronous operation.

    Exceptions
    Type Condition
    ArgumentNullException

    The options are null.

    ArgumentNullException

    The stream is null.

    NotSupportedException

    The stream is not readable or the image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    LoadAsync(DecoderOptions, string, CancellationToken)

    Creates a new instance of the Image class from the given file path. The pixel format is automatically determined by the decoder.

    Declaration
    public static Task<Image> LoadAsync(DecoderOptions options, string path, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    DecoderOptions options

    The general decoder options.

    string path

    The file path to the image.

    CancellationToken cancellationToken

    The token to monitor for cancellation requests.

    Returns
    Type Description
    Task<Image>

    A Task<TResult> representing the asynchronous operation.

    Exceptions
    Type Condition
    ArgumentNullException

    The options are null.

    ArgumentNullException

    The path is null.

    NotSupportedException

    The file stream is not readable or the image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    LoadAsync(Stream, CancellationToken)

    Creates a new instance of the Image class from the given stream. The pixel format is automatically determined by the decoder.

    Declaration
    public static Task<Image> LoadAsync(Stream stream, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    Stream stream

    The stream containing image information.

    CancellationToken cancellationToken

    The token to monitor for cancellation requests.

    Returns
    Type Description
    Task<Image>

    A Task<TResult> representing the asynchronous operation.

    Exceptions
    Type Condition
    ArgumentNullException

    The stream is null.

    NotSupportedException

    The stream is not readable or the image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    LoadAsync(string, CancellationToken)

    Creates a new instance of the Image class from the given file path. The pixel format is automatically determined by the decoder.

    Declaration
    public static Task<Image> LoadAsync(string path, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    string path

    The file path to the image.

    CancellationToken cancellationToken

    The token to monitor for cancellation requests.

    Returns
    Type Description
    Task<Image>

    A Task<TResult> representing the asynchronous operation.

    Exceptions
    Type Condition
    ArgumentNullException

    The path is null.

    NotSupportedException

    The file stream is not readable or the image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    LoadAsync<TPixel>(DecoderOptions, Stream, CancellationToken)

    Creates a new instance of the Image<TPixel> class from the given stream.

    Declaration
    public static Task<Image<TPixel>> LoadAsync<TPixel>(DecoderOptions options, Stream stream, CancellationToken cancellationToken = default) where TPixel : unmanaged, IPixel<TPixel>
    Parameters
    Type Name Description
    DecoderOptions options

    The general decoder options.

    Stream stream

    The stream containing image information.

    CancellationToken cancellationToken

    The token to monitor for cancellation requests.

    Returns
    Type Description
    Task<Image<TPixel>>

    A Task<TResult> representing the asynchronous operation.

    Type Parameters
    Name Description
    TPixel

    The pixel format.

    Exceptions
    Type Condition
    ArgumentNullException

    The options are null.

    ArgumentNullException

    The stream is null.

    NotSupportedException

    The stream is not readable or the image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    LoadAsync<TPixel>(DecoderOptions, string, CancellationToken)

    Creates a new instance of the Image<TPixel> class from the given file path.

    Declaration
    public static Task<Image<TPixel>> LoadAsync<TPixel>(DecoderOptions options, string path, CancellationToken cancellationToken = default) where TPixel : unmanaged, IPixel<TPixel>
    Parameters
    Type Name Description
    DecoderOptions options

    The general decoder options.

    string path

    The file path to the image.

    CancellationToken cancellationToken

    The token to monitor for cancellation requests.

    Returns
    Type Description
    Task<Image<TPixel>>

    A Task<TResult> representing the asynchronous operation.

    Type Parameters
    Name Description
    TPixel

    The pixel format.

    Exceptions
    Type Condition
    ArgumentNullException

    The options are null.

    ArgumentNullException

    The path is null.

    NotSupportedException

    The file stream is not readable or the image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    LoadAsync<TPixel>(Stream, CancellationToken)

    Creates a new instance of the Image<TPixel> class from the given stream.

    Declaration
    public static Task<Image<TPixel>> LoadAsync<TPixel>(Stream stream, CancellationToken cancellationToken = default) where TPixel : unmanaged, IPixel<TPixel>
    Parameters
    Type Name Description
    Stream stream

    The stream containing image information.

    CancellationToken cancellationToken

    The token to monitor for cancellation requests.

    Returns
    Type Description
    Task<Image<TPixel>>

    A Task<TResult> representing the asynchronous operation.

    Type Parameters
    Name Description
    TPixel

    The pixel format.

    Exceptions
    Type Condition
    ArgumentNullException

    The stream is null.

    NotSupportedException

    The stream is not readable or the image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    LoadAsync<TPixel>(string, CancellationToken)

    Creates a new instance of the Image<TPixel> class from the given file path.

    Declaration
    public static Task<Image<TPixel>> LoadAsync<TPixel>(string path, CancellationToken cancellationToken = default) where TPixel : unmanaged, IPixel<TPixel>
    Parameters
    Type Name Description
    string path

    The file path to the image.

    CancellationToken cancellationToken

    The token to monitor for cancellation requests.

    Returns
    Type Description
    Task<Image<TPixel>>

    A Task<TResult> representing the asynchronous operation.

    Type Parameters
    Name Description
    TPixel

    The pixel format.

    Exceptions
    Type Condition
    ArgumentNullException

    The path is null.

    NotSupportedException

    The file stream is not readable or the image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    LoadPixelData<TPixel>(Configuration, ReadOnlySpan<byte>, int, int)

    Create a new instance of the Image<TPixel> class from the given readonly span of bytes in TPixel format.

    Declaration
    public static Image<TPixel> LoadPixelData<TPixel>(Configuration configuration, ReadOnlySpan<byte> data, int width, int height) where TPixel : unmanaged, IPixel<TPixel>
    Parameters
    Type Name Description
    Configuration configuration

    The configuration for the decoder.

    ReadOnlySpan<byte> data

    The readonly span of bytes containing image data.

    int width

    The width of the final image.

    int height

    The height of the final image.

    Returns
    Type Description
    Image<TPixel>

    A new Image<TPixel>.

    Type Parameters
    Name Description
    TPixel

    The pixel format.

    Exceptions
    Type Condition
    ArgumentNullException

    The configuration is null.

    ArgumentException

    The data length is incorrect.

    | Edit this page View Source

    LoadPixelData<TPixel>(Configuration, ReadOnlySpan<TPixel>, int, int)

    Create a new instance of the Image<TPixel> class from the raw TPixel data.

    Declaration
    public static Image<TPixel> LoadPixelData<TPixel>(Configuration configuration, ReadOnlySpan<TPixel> data, int width, int height) where TPixel : unmanaged, IPixel<TPixel>
    Parameters
    Type Name Description
    Configuration configuration

    The configuration for the decoder.

    ReadOnlySpan<TPixel> data

    The readonly span containing the image pixel data.

    int width

    The width of the final image.

    int height

    The height of the final image.

    Returns
    Type Description
    Image<TPixel>

    A new Image<TPixel>.

    Type Parameters
    Name Description
    TPixel

    The pixel format.

    Exceptions
    Type Condition
    ArgumentNullException

    The configuration is null.

    ArgumentException

    The data length is incorrect.

    | Edit this page View Source

    LoadPixelData<TPixel>(ReadOnlySpan<byte>, int, int)

    Create a new instance of the Image<TPixel> class from the given readonly span of bytes in TPixel format.

    Declaration
    public static Image<TPixel> LoadPixelData<TPixel>(ReadOnlySpan<byte> data, int width, int height) where TPixel : unmanaged, IPixel<TPixel>
    Parameters
    Type Name Description
    ReadOnlySpan<byte> data

    The readonly span of bytes containing image data.

    int width

    The width of the final image.

    int height

    The height of the final image.

    Returns
    Type Description
    Image<TPixel>

    A new Image<TPixel>.

    Type Parameters
    Name Description
    TPixel

    The pixel format.

    Exceptions
    Type Condition
    ArgumentException

    The data length is incorrect.

    | Edit this page View Source

    LoadPixelData<TPixel>(ReadOnlySpan<TPixel>, int, int)

    Create a new instance of the Image<TPixel> class from the raw TPixel data.

    Declaration
    public static Image<TPixel> LoadPixelData<TPixel>(ReadOnlySpan<TPixel> data, int width, int height) where TPixel : unmanaged, IPixel<TPixel>
    Parameters
    Type Name Description
    ReadOnlySpan<TPixel> data

    The readonly span of bytes containing image data.

    int width

    The width of the final image.

    int height

    The height of the final image.

    Returns
    Type Description
    Image<TPixel>

    A new Image<TPixel>.

    Type Parameters
    Name Description
    TPixel

    The pixel format.

    Exceptions
    Type Condition
    ArgumentException

    The data length is incorrect.

    | Edit this page View Source

    Load<TPixel>(DecoderOptions, Stream)

    Creates a new instance of the Image<TPixel> class from the given stream.

    Declaration
    public static Image<TPixel> Load<TPixel>(DecoderOptions options, Stream stream) where TPixel : unmanaged, IPixel<TPixel>
    Parameters
    Type Name Description
    DecoderOptions options

    The general decoder options.

    Stream stream

    The stream containing image information.

    Returns
    Type Description
    Image<TPixel>

    Image<TPixel>.

    Type Parameters
    Name Description
    TPixel

    The pixel format.

    Exceptions
    Type Condition
    ArgumentNullException

    The options are null.

    ArgumentNullException

    The stream is null.

    NotSupportedException

    The stream is not readable or the image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    Load<TPixel>(DecoderOptions, ReadOnlySpan<byte>)

    Creates a new instance of the Image<TPixel> class from the given byte span.

    Declaration
    public static Image<TPixel> Load<TPixel>(DecoderOptions options, ReadOnlySpan<byte> data) where TPixel : unmanaged, IPixel<TPixel>
    Parameters
    Type Name Description
    DecoderOptions options

    The general decoder options.

    ReadOnlySpan<byte> data

    The byte span containing encoded image data.

    Returns
    Type Description
    Image<TPixel>

    Image<TPixel>.

    Type Parameters
    Name Description
    TPixel

    The pixel format.

    Exceptions
    Type Condition
    ArgumentNullException

    The options are null.

    NotSupportedException

    The image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    Load<TPixel>(DecoderOptions, string)

    Creates a new instance of the Image<TPixel> class from the given file path.

    Declaration
    public static Image<TPixel> Load<TPixel>(DecoderOptions options, string path) where TPixel : unmanaged, IPixel<TPixel>
    Parameters
    Type Name Description
    DecoderOptions options

    The general decoder options.

    string path

    The file path to the image.

    Returns
    Type Description
    Image<TPixel>

    Image<TPixel>.

    Type Parameters
    Name Description
    TPixel

    The pixel format.

    Exceptions
    Type Condition
    ArgumentNullException

    The options are null.

    ArgumentNullException

    The path is null.

    NotSupportedException

    The file stream is not readable or the image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    Load<TPixel>(Stream)

    Creates a new instance of the Image<TPixel> class from the given stream.

    Declaration
    public static Image<TPixel> Load<TPixel>(Stream stream) where TPixel : unmanaged, IPixel<TPixel>
    Parameters
    Type Name Description
    Stream stream

    The stream containing image information.

    Returns
    Type Description
    Image<TPixel>

    Image<TPixel>.

    Type Parameters
    Name Description
    TPixel

    The pixel format.

    Exceptions
    Type Condition
    ArgumentNullException

    The stream is null.

    NotSupportedException

    The stream is not readable or the image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    Load<TPixel>(ReadOnlySpan<byte>)

    Creates a new instance of the Image<TPixel> class from the given byte span.

    Declaration
    public static Image<TPixel> Load<TPixel>(ReadOnlySpan<byte> data) where TPixel : unmanaged, IPixel<TPixel>
    Parameters
    Type Name Description
    ReadOnlySpan<byte> data

    The byte span containing encoded image data.

    Returns
    Type Description
    Image<TPixel>

    Image<TPixel>.

    Type Parameters
    Name Description
    TPixel

    The pixel format.

    Exceptions
    Type Condition
    NotSupportedException

    The image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    Load<TPixel>(string)

    Creates a new instance of the Image<TPixel> class from the given file path.

    Declaration
    public static Image<TPixel> Load<TPixel>(string path) where TPixel : unmanaged, IPixel<TPixel>
    Parameters
    Type Name Description
    string path

    The file path to the image.

    Returns
    Type Description
    Image<TPixel>

    Image<TPixel>.

    Type Parameters
    Name Description
    TPixel

    The pixel format.

    Exceptions
    Type Condition
    ArgumentNullException

    The path is null.

    NotSupportedException

    The file stream is not readable or the image format is not supported.

    InvalidImageContentException

    The encoded image contains invalid content.

    UnknownImageFormatException

    The encoded image format is unknown.

    | Edit this page View Source

    Save(Stream, IImageEncoder)

    Saves the image to the given stream using the given image encoder.

    Declaration
    public void Save(Stream stream, IImageEncoder encoder)
    Parameters
    Type Name Description
    Stream stream

    The stream to save the image to.

    IImageEncoder encoder

    The encoder to save the image with.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown if the stream or encoder is null.

    | Edit this page View Source

    SaveAsync(Stream, IImageEncoder, CancellationToken)

    Saves the image to the given stream using the given image encoder.

    Declaration
    public Task SaveAsync(Stream stream, IImageEncoder encoder, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    Stream stream

    The stream to save the image to.

    IImageEncoder encoder

    The encoder to save the image with.

    CancellationToken cancellationToken

    The token to monitor for cancellation requests.

    Returns
    Type Description
    Task

    A Task representing the asynchronous operation.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown if the stream or encoder is null.

    | Edit this page View Source

    UpdateSize(Size)

    Update the size of the image after mutation.

    Declaration
    protected void UpdateSize(Size size)
    Parameters
    Type Name Description
    Size size

    The Size.

    | Edit this page View Source

    WrapMemory<TPixel>(Configuration, IMemoryOwner<byte>, int, int)

    Wraps an existing contiguous memory area of at least 'width' x 'height' pixels, allowing to view/manipulate it as an Image<TPixel> instance. The ownership of the byteMemoryOwner is being transferred to the new Image<TPixel> instance, meaning that the caller is not allowed to dispose byteMemoryOwner. It will be disposed together with the result image.

    Declaration
    public static Image<TPixel> WrapMemory<TPixel>(Configuration configuration, IMemoryOwner<byte> byteMemoryOwner, int width, int height) where TPixel : unmanaged, IPixel<TPixel>
    Parameters
    Type Name Description
    Configuration configuration

    The Configuration

    IMemoryOwner<byte> byteMemoryOwner

    The IMemoryOwner<T> that is being transferred to the image.

    int width

    The width of the memory image.

    int height

    The height of the memory image.

    Returns
    Type Description
    Image<TPixel>

    An Image<TPixel> instance

    Type Parameters
    Name Description
    TPixel

    The pixel type.

    Exceptions
    Type Condition
    ArgumentNullException

    The configuration is null.

    | Edit this page View Source

    WrapMemory<TPixel>(Configuration, IMemoryOwner<byte>, int, int, ImageMetadata)

    Wraps an existing contiguous memory area of at least 'width' x 'height' pixels, allowing to view/manipulate it as an Image<TPixel> instance. The ownership of the byteMemoryOwner is being transferred to the new Image<TPixel> instance, meaning that the caller is not allowed to dispose byteMemoryOwner. It will be disposed together with the result image.

    Declaration
    public static Image<TPixel> WrapMemory<TPixel>(Configuration configuration, IMemoryOwner<byte> byteMemoryOwner, int width, int height, ImageMetadata metadata) where TPixel : unmanaged, IPixel<TPixel>
    Parameters
    Type Name Description
    Configuration configuration

    The Configuration

    IMemoryOwner<byte> byteMemoryOwner

    The IMemoryOwner<T> that is being transferred to the image

    int width

    The width of the memory image.

    int height

    The height of the memory image.

    ImageMetadata metadata

    The ImageMetadata

    Returns
    Type Description
    Image<TPixel>

    An Image<TPixel> instance

    Type Parameters
    Name Description
    TPixel

    The pixel type

    Exceptions
    Type Condition
    ArgumentNullException

    The configuration is null.

    ArgumentNullException

    The metadata is null.

    | Edit this page View Source

    WrapMemory<TPixel>(Configuration, IMemoryOwner<TPixel>, int, int)

    Wraps an existing contiguous memory area of at least 'width' x 'height' pixels, allowing to view/manipulate it as an Image<TPixel> instance. The ownership of the pixelMemoryOwner is being transferred to the new Image<TPixel> instance, meaning that the caller is not allowed to dispose pixelMemoryOwner. It will be disposed together with the result image.

    Declaration
    public static Image<TPixel> WrapMemory<TPixel>(Configuration configuration, IMemoryOwner<TPixel> pixelMemoryOwner, int width, int height) where TPixel : unmanaged, IPixel<TPixel>
    Parameters
    Type Name Description
    Configuration configuration

    The Configuration

    IMemoryOwner<TPixel> pixelMemoryOwner

    The IMemoryOwner<T> that is being transferred to the image.

    int width

    The width of the memory image.

    int height

    The height of the memory image.

    Returns
    Type Description
    Image<TPixel>

    An Image<TPixel> instance

    Type Parameters
    Name Description
    TPixel

    The pixel type.

    Exceptions
    Type Condition
    ArgumentNullException

    The configuration is null.

    | Edit this page View Source

    WrapMemory<TPixel>(Configuration, IMemoryOwner<TPixel>, int, int, ImageMetadata)

    Wraps an existing contiguous memory area of at least 'width' x 'height' pixels, allowing to view/manipulate it as an Image<TPixel> instance. The ownership of the pixelMemoryOwner is being transferred to the new Image<TPixel> instance, meaning that the caller is not allowed to dispose pixelMemoryOwner. It will be disposed together with the result image.

    Declaration
    public static Image<TPixel> WrapMemory<TPixel>(Configuration configuration, IMemoryOwner<TPixel> pixelMemoryOwner, int width, int height, ImageMetadata metadata) where TPixel : unmanaged, IPixel<TPixel>
    Parameters
    Type Name Description
    Configuration configuration

    The Configuration

    IMemoryOwner<TPixel> pixelMemoryOwner

    The IMemoryOwner<T> that is being transferred to the image

    int width

    The width of the memory image.

    int height

    The height of the memory image.

    ImageMetadata metadata

    The ImageMetadata

    Returns
    Type Description
    Image<TPixel>

    An Image<TPixel> instance

    Type Parameters
    Name Description
    TPixel

    The pixel type

    Exceptions
    Type Condition
    ArgumentNullException

    The configuration is null.

    ArgumentNullException

    The metadata is null.

    | Edit this page View Source

    WrapMemory<TPixel>(Configuration, Memory<byte>, int, int)

    Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as an Image<TPixel> instance.

    Please note: using this method does not transfer the ownership of the underlying buffer of the input Memory<T> to the new Image<TPixel> instance. This means that consumers of this method must ensure that the input buffer is either self-contained, (for example, a Memory<T> instance wrapping a new array that was created), or that the owning object is not disposed until the returned Image<TPixel> is disposed.

    If the input Memory<T> instance is one retrieved from an IMemoryOwner<T> instance rented from a memory pool (such as MemoryPool<T>), and that owning instance is disposed while the image is still in use, this will lead to undefined behavior and possibly runtime crashes (as the same buffer might then be modified by other consumers while the returned image is still working on it). Make sure to control the lifetime of the input buffers appropriately.

    Declaration
    public static Image<TPixel> WrapMemory<TPixel>(Configuration configuration, Memory<byte> byteMemory, int width, int height) where TPixel : unmanaged, IPixel<TPixel>
    Parameters
    Type Name Description
    Configuration configuration

    The Configuration

    Memory<byte> byteMemory

    The byte memory representing the pixel data.

    int width

    The width of the memory image.

    int height

    The height of the memory image.

    Returns
    Type Description
    Image<TPixel>

    An Image<TPixel> instance.

    Type Parameters
    Name Description
    TPixel

    The pixel type

    Exceptions
    Type Condition
    ArgumentNullException

    The configuration is null.

    | Edit this page View Source

    WrapMemory<TPixel>(Configuration, Memory<byte>, int, int, ImageMetadata)

    Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as an Image<TPixel> instance.

    Please note: using this method does not transfer the ownership of the underlying buffer of the input Memory<T> to the new Image<TPixel> instance. This means that consumers of this method must ensure that the input buffer is either self-contained, (for example, a Memory<T> instance wrapping a new array that was created), or that the owning object is not disposed until the returned Image<TPixel> is disposed.

    If the input Memory<T> instance is one retrieved from an IMemoryOwner<T> instance rented from a memory pool (such as MemoryPool<T>), and that owning instance is disposed while the image is still in use, this will lead to undefined behavior and possibly runtime crashes (as the same buffer might then be modified by other consumers while the returned image is still working on it). Make sure to control the lifetime of the input buffers appropriately.

    Declaration
    public static Image<TPixel> WrapMemory<TPixel>(Configuration configuration, Memory<byte> byteMemory, int width, int height, ImageMetadata metadata) where TPixel : unmanaged, IPixel<TPixel>
    Parameters
    Type Name Description
    Configuration configuration

    The Configuration

    Memory<byte> byteMemory

    The byte memory representing the pixel data.

    int width

    The width of the memory image.

    int height

    The height of the memory image.

    ImageMetadata metadata

    The ImageMetadata.

    Returns
    Type Description
    Image<TPixel>

    An Image<TPixel> instance

    Type Parameters
    Name Description
    TPixel

    The pixel type

    Exceptions
    Type Condition
    ArgumentNullException

    The configuration is null.

    ArgumentNullException

    The metadata is null.

    | Edit this page View Source

    WrapMemory<TPixel>(Configuration, Memory<TPixel>, int, int)

    Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as an Image<TPixel> instance.

    Please note: using this method does not transfer the ownership of the underlying buffer of the input Memory<T> to the new Image<TPixel> instance. This means that consumers of this method must ensure that the input buffer is either self-contained, (for example, a Memory<T> instance wrapping a new array that was created), or that the owning object is not disposed until the returned Image<TPixel> is disposed.

    If the input Memory<T> instance is one retrieved from an IMemoryOwner<T> instance rented from a memory pool (such as MemoryPool<T>), and that owning instance is disposed while the image is still in use, this will lead to undefined behavior and possibly runtime crashes (as the same buffer might then be modified by other consumers while the returned image is still working on it). Make sure to control the lifetime of the input buffers appropriately.

    Declaration
    public static Image<TPixel> WrapMemory<TPixel>(Configuration configuration, Memory<TPixel> pixelMemory, int width, int height) where TPixel : unmanaged, IPixel<TPixel>
    Parameters
    Type Name Description
    Configuration configuration

    The Configuration

    Memory<TPixel> pixelMemory

    The pixel memory.

    int width

    The width of the memory image.

    int height

    The height of the memory image.

    Returns
    Type Description
    Image<TPixel>

    An Image<TPixel> instance.

    Type Parameters
    Name Description
    TPixel

    The pixel type

    Exceptions
    Type Condition
    ArgumentNullException

    The configuration is null.

    | Edit this page View Source

    WrapMemory<TPixel>(Configuration, Memory<TPixel>, int, int, ImageMetadata)

    Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as an Image<TPixel> instance.

    Please note: using this method does not transfer the ownership of the underlying buffer of the input Memory<T> to the new Image<TPixel> instance. This means that consumers of this method must ensure that the input buffer is either self-contained, (for example, a Memory<T> instance wrapping a new array that was created), or that the owning object is not disposed until the returned Image<TPixel> is disposed.

    If the input Memory<T> instance is one retrieved from an IMemoryOwner<T> instance rented from a memory pool (such as MemoryPool<T>), and that owning instance is disposed while the image is still in use, this will lead to undefined behavior and possibly runtime crashes (as the same buffer might then be modified by other consumers while the returned image is still working on it). Make sure to control the lifetime of the input buffers appropriately.

    Declaration
    public static Image<TPixel> WrapMemory<TPixel>(Configuration configuration, Memory<TPixel> pixelMemory, int width, int height, ImageMetadata metadata) where TPixel : unmanaged, IPixel<TPixel>
    Parameters
    Type Name Description
    Configuration configuration

    The Configuration

    Memory<TPixel> pixelMemory

    The pixel memory.

    int width

    The width of the memory image.

    int height

    The height of the memory image.

    ImageMetadata metadata

    The ImageMetadata.

    Returns
    Type Description
    Image<TPixel>

    An Image<TPixel> instance

    Type Parameters
    Name Description
    TPixel

    The pixel type

    Exceptions
    Type Condition
    ArgumentNullException

    The configuration is null.

    ArgumentNullException

    The metadata is null.

    | Edit this page View Source

    WrapMemory<TPixel>(Configuration, void*, int, int, int)

    Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as an Image<TPixel> instance.

    Please note: this method relies on callers to carefully manage the target memory area being referenced by the pointer and that the lifetime of such a memory area is at least equal to that of the returned Image<TPixel> instance. For example, if the input pointer references an unmanaged memory area, callers must ensure that the memory area is not freed as long as the returned Image<TPixel> is in use and not disposed. The same applies if the input memory area points to a pinned managed object, as callers must ensure that objects will remain pinned as long as the Image<TPixel> instance is in use. Failing to do so constitutes undefined behavior and will likely lead to memory corruption and runtime crashes.

    Note also that if you have a Memory<T> or an array (which can be cast to Memory<T>) of either byte or TPixel values, it is highly recommended to use one of the other available overloads of this method instead (such as WrapMemory<TPixel>(Configuration, Memory<byte>, int, int) or WrapMemory<TPixel>(Configuration, Memory<TPixel>, int, int), to make the resulting code less error prone and avoid having to pin the underlying memory buffer in use. This method is primarily meant to be used when doing interop or working with buffers that are located in unmanaged memory.

    Declaration
    public static Image<TPixel> WrapMemory<TPixel>(Configuration configuration, void* pointer, int bufferSizeInBytes, int width, int height) where TPixel : unmanaged, IPixel<TPixel>
    Parameters
    Type Name Description
    Configuration configuration

    The Configuration

    void* pointer

    The pointer to the target memory buffer to wrap.

    int bufferSizeInBytes

    The byte length of the memory allocated.

    int width

    The width of the memory image.

    int height

    The height of the memory image.

    Returns
    Type Description
    Image<TPixel>

    An Image<TPixel> instance.

    Type Parameters
    Name Description
    TPixel

    The pixel type

    Exceptions
    Type Condition
    ArgumentNullException

    The configuration is null.

    | Edit this page View Source

    WrapMemory<TPixel>(Configuration, void*, int, int, int, ImageMetadata)

    Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as an Image<TPixel> instance.

    Please note: this method relies on callers to carefully manage the target memory area being referenced by the pointer and that the lifetime of such a memory area is at least equal to that of the returned Image<TPixel> instance. For example, if the input pointer references an unmanaged memory area, callers must ensure that the memory area is not freed as long as the returned Image<TPixel> is in use and not disposed. The same applies if the input memory area points to a pinned managed object, as callers must ensure that objects will remain pinned as long as the Image<TPixel> instance is in use. Failing to do so constitutes undefined behavior and will likely lead to memory corruption and runtime crashes.

    Note also that if you have a Memory<T> or an array (which can be cast to Memory<T>) of either byte or TPixel values, it is highly recommended to use one of the other available overloads of this method instead (such as WrapMemory<TPixel>(Configuration, Memory<byte>, int, int) or WrapMemory<TPixel>(Configuration, Memory<TPixel>, int, int), to make the resulting code less error prone and avoid having to pin the underlying memory buffer in use. This method is primarily meant to be used when doing interop or working with buffers that are located in unmanaged memory.

    Declaration
    public static Image<TPixel> WrapMemory<TPixel>(Configuration configuration, void* pointer, int bufferSizeInBytes, int width, int height, ImageMetadata metadata) where TPixel : unmanaged, IPixel<TPixel>
    Parameters
    Type Name Description
    Configuration configuration

    The Configuration

    void* pointer

    The pointer to the target memory buffer to wrap.

    int bufferSizeInBytes

    The byte length of the memory allocated.

    int width

    The width of the memory image.

    int height

    The height of the memory image.

    ImageMetadata metadata

    The ImageMetadata.

    Returns
    Type Description
    Image<TPixel>

    An Image<TPixel> instance

    Type Parameters
    Name Description
    TPixel

    The pixel type

    Exceptions
    Type Condition
    ArgumentNullException

    The configuration is null.

    ArgumentNullException

    The metadata is null.

    | Edit this page View Source

    WrapMemory<TPixel>(IMemoryOwner<byte>, int, int)

    Wraps an existing contiguous memory area of at least 'width' x 'height' pixels, allowing to view/manipulate it as an Image<TPixel> instance. The ownership of the byteMemoryOwner is being transferred to the new Image<TPixel> instance, meaning that the caller is not allowed to dispose byteMemoryOwner. It will be disposed together with the result image.

    Declaration
    public static Image<TPixel> WrapMemory<TPixel>(IMemoryOwner<byte> byteMemoryOwner, int width, int height) where TPixel : unmanaged, IPixel<TPixel>
    Parameters
    Type Name Description
    IMemoryOwner<byte> byteMemoryOwner

    The IMemoryOwner<T> that is being transferred to the image.

    int width

    The width of the memory image.

    int height

    The height of the memory image.

    Returns
    Type Description
    Image<TPixel>

    An Image<TPixel> instance.

    Type Parameters
    Name Description
    TPixel

    The pixel type

    | Edit this page View Source

    WrapMemory<TPixel>(IMemoryOwner<TPixel>, int, int)

    Wraps an existing contiguous memory area of at least 'width' x 'height' pixels, allowing to view/manipulate it as an Image<TPixel> instance. The ownership of the pixelMemoryOwner is being transferred to the new Image<TPixel> instance, meaning that the caller is not allowed to dispose pixelMemoryOwner. It will be disposed together with the result image.

    Declaration
    public static Image<TPixel> WrapMemory<TPixel>(IMemoryOwner<TPixel> pixelMemoryOwner, int width, int height) where TPixel : unmanaged, IPixel<TPixel>
    Parameters
    Type Name Description
    IMemoryOwner<TPixel> pixelMemoryOwner

    The IMemoryOwner<T> that is being transferred to the image.

    int width

    The width of the memory image.

    int height

    The height of the memory image.

    Returns
    Type Description
    Image<TPixel>

    An Image<TPixel> instance.

    Type Parameters
    Name Description
    TPixel

    The pixel type

    | Edit this page View Source

    WrapMemory<TPixel>(Memory<byte>, int, int)

    Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as an Image<TPixel> instance.

    Please note: using this method does not transfer the ownership of the underlying buffer of the input Memory<T> to the new Image<TPixel> instance. This means that consumers of this method must ensure that the input buffer is either self-contained, (for example, a Memory<T> instance wrapping a new array that was created), or that the owning object is not disposed until the returned Image<TPixel> is disposed.

    If the input Memory<T> instance is one retrieved from an IMemoryOwner<T> instance rented from a memory pool (such as MemoryPool<T>), and that owning instance is disposed while the image is still in use, this will lead to undefined behavior and possibly runtime crashes (as the same buffer might then be modified by other consumers while the returned image is still working on it). Make sure to control the lifetime of the input buffers appropriately.

    Declaration
    public static Image<TPixel> WrapMemory<TPixel>(Memory<byte> byteMemory, int width, int height) where TPixel : unmanaged, IPixel<TPixel>
    Parameters
    Type Name Description
    Memory<byte> byteMemory

    The byte memory representing the pixel data.

    int width

    The width of the memory image.

    int height

    The height of the memory image.

    Returns
    Type Description
    Image<TPixel>

    An Image<TPixel> instance.

    Type Parameters
    Name Description
    TPixel

    The pixel type.

    | Edit this page View Source

    WrapMemory<TPixel>(Memory<TPixel>, int, int)

    Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as an Image<TPixel> instance.

    Please note: using this method does not transfer the ownership of the underlying buffer of the input Memory<T> to the new Image<TPixel> instance. This means that consumers of this method must ensure that the input buffer is either self-contained, (for example, a Memory<T> instance wrapping a new array that was created), or that the owning object is not disposed until the returned Image<TPixel> is disposed.

    If the input Memory<T> instance is one retrieved from an IMemoryOwner<T> instance rented from a memory pool (such as MemoryPool<T>), and that owning instance is disposed while the image is still in use, this will lead to undefined behavior and possibly runtime crashes (as the same buffer might then be modified by other consumers while the returned image is still working on it). Make sure to control the lifetime of the input buffers appropriately.

    Declaration
    public static Image<TPixel> WrapMemory<TPixel>(Memory<TPixel> pixelMemory, int width, int height) where TPixel : unmanaged, IPixel<TPixel>
    Parameters
    Type Name Description
    Memory<TPixel> pixelMemory

    The pixel memory.

    int width

    The width of the memory image.

    int height

    The height of the memory image.

    Returns
    Type Description
    Image<TPixel>

    An Image<TPixel> instance.

    Type Parameters
    Name Description
    TPixel

    The pixel type.

    | Edit this page View Source

    WrapMemory<TPixel>(void*, int, int, int)

    Wraps an existing contiguous memory area of at least 'width' x 'height' pixels allowing viewing/manipulation as an Image<TPixel> instance.

    Please note: this method relies on callers to carefully manage the target memory area being referenced by the pointer and that the lifetime of such a memory area is at least equal to that of the returned Image<TPixel> instance. For example, if the input pointer references an unmanaged memory area, callers must ensure that the memory area is not freed as long as the returned Image<TPixel> is in use and not disposed. The same applies if the input memory area points to a pinned managed object, as callers must ensure that objects will remain pinned as long as the Image<TPixel> instance is in use. Failing to do so constitutes undefined behavior and will likely lead to memory corruption and runtime crashes.

    Note also that if you have a Memory<T> or an array (which can be cast to Memory<T>) of either byte or TPixel values, it is highly recommended to use one of the other available overloads of this method instead (such as WrapMemory<TPixel>(Configuration, Memory<byte>, int, int) or WrapMemory<TPixel>(Configuration, Memory<TPixel>, int, int), to make the resulting code less error prone and avoid having to pin the underlying memory buffer in use. This method is primarily meant to be used when doing interop or working with buffers that are located in unmanaged memory.

    Declaration
    public static Image<TPixel> WrapMemory<TPixel>(void* pointer, int bufferSizeInBytes, int width, int height) where TPixel : unmanaged, IPixel<TPixel>
    Parameters
    Type Name Description
    void* pointer

    The pointer to the target memory buffer to wrap.

    int bufferSizeInBytes

    The byte length of the memory allocated.

    int width

    The width of the memory image.

    int height

    The height of the memory image.

    Returns
    Type Description
    Image<TPixel>

    An Image<TPixel> instance.

    Type Parameters
    Name Description
    TPixel

    The pixel type.

    Implements

    IDisposable
    IConfigurationProvider

    Extension Methods

    AdvancedImageExtensions.AcceptVisitor(Image, IImageVisitor)
    AdvancedImageExtensions.AcceptVisitorAsync(Image, IImageVisitorAsync, CancellationToken)
    AdvancedImageExtensions.DetectEncoder(Image, string)
    ImageExtensions.Save(Image, Stream, IImageFormat)
    ImageExtensions.Save(Image, string)
    ImageExtensions.Save(Image, string, IImageEncoder)
    ImageExtensions.SaveAsBmp(Image, Stream)
    ImageExtensions.SaveAsBmp(Image, Stream, BmpEncoder)
    ImageExtensions.SaveAsBmp(Image, string)
    ImageExtensions.SaveAsBmp(Image, string, BmpEncoder)
    ImageExtensions.SaveAsBmpAsync(Image, Stream, BmpEncoder, CancellationToken)
    ImageExtensions.SaveAsBmpAsync(Image, Stream, CancellationToken)
    ImageExtensions.SaveAsBmpAsync(Image, string)
    ImageExtensions.SaveAsBmpAsync(Image, string, BmpEncoder, CancellationToken)
    ImageExtensions.SaveAsBmpAsync(Image, string, CancellationToken)
    ImageExtensions.SaveAsGif(Image, Stream)
    ImageExtensions.SaveAsGif(Image, Stream, GifEncoder)
    ImageExtensions.SaveAsGif(Image, string)
    ImageExtensions.SaveAsGif(Image, string, GifEncoder)
    ImageExtensions.SaveAsGifAsync(Image, Stream, GifEncoder, CancellationToken)
    ImageExtensions.SaveAsGifAsync(Image, Stream, CancellationToken)
    ImageExtensions.SaveAsGifAsync(Image, string)
    ImageExtensions.SaveAsGifAsync(Image, string, GifEncoder, CancellationToken)
    ImageExtensions.SaveAsGifAsync(Image, string, CancellationToken)
    ImageExtensions.SaveAsJpeg(Image, Stream)
    ImageExtensions.SaveAsJpeg(Image, Stream, JpegEncoder)
    ImageExtensions.SaveAsJpeg(Image, string)
    ImageExtensions.SaveAsJpeg(Image, string, JpegEncoder)
    ImageExtensions.SaveAsJpegAsync(Image, Stream, JpegEncoder, CancellationToken)
    ImageExtensions.SaveAsJpegAsync(Image, Stream, CancellationToken)
    ImageExtensions.SaveAsJpegAsync(Image, string)
    ImageExtensions.SaveAsJpegAsync(Image, string, JpegEncoder, CancellationToken)
    ImageExtensions.SaveAsJpegAsync(Image, string, CancellationToken)
    ImageExtensions.SaveAsPbm(Image, Stream)
    ImageExtensions.SaveAsPbm(Image, Stream, PbmEncoder)
    ImageExtensions.SaveAsPbm(Image, string)
    ImageExtensions.SaveAsPbm(Image, string, PbmEncoder)
    ImageExtensions.SaveAsPbmAsync(Image, Stream, PbmEncoder, CancellationToken)
    ImageExtensions.SaveAsPbmAsync(Image, Stream, CancellationToken)
    ImageExtensions.SaveAsPbmAsync(Image, string)
    ImageExtensions.SaveAsPbmAsync(Image, string, PbmEncoder, CancellationToken)
    ImageExtensions.SaveAsPbmAsync(Image, string, CancellationToken)
    ImageExtensions.SaveAsPng(Image, Stream)
    ImageExtensions.SaveAsPng(Image, Stream, PngEncoder)
    ImageExtensions.SaveAsPng(Image, string)
    ImageExtensions.SaveAsPng(Image, string, PngEncoder)
    ImageExtensions.SaveAsPngAsync(Image, Stream, PngEncoder, CancellationToken)
    ImageExtensions.SaveAsPngAsync(Image, Stream, CancellationToken)
    ImageExtensions.SaveAsPngAsync(Image, string)
    ImageExtensions.SaveAsPngAsync(Image, string, PngEncoder, CancellationToken)
    ImageExtensions.SaveAsPngAsync(Image, string, CancellationToken)
    ImageExtensions.SaveAsQoi(Image, Stream)
    ImageExtensions.SaveAsQoi(Image, Stream, QoiEncoder)
    ImageExtensions.SaveAsQoi(Image, string)
    ImageExtensions.SaveAsQoi(Image, string, QoiEncoder)
    ImageExtensions.SaveAsQoiAsync(Image, Stream, QoiEncoder, CancellationToken)
    ImageExtensions.SaveAsQoiAsync(Image, Stream, CancellationToken)
    ImageExtensions.SaveAsQoiAsync(Image, string)
    ImageExtensions.SaveAsQoiAsync(Image, string, QoiEncoder, CancellationToken)
    ImageExtensions.SaveAsQoiAsync(Image, string, CancellationToken)
    ImageExtensions.SaveAsTga(Image, Stream)
    ImageExtensions.SaveAsTga(Image, Stream, TgaEncoder)
    ImageExtensions.SaveAsTga(Image, string)
    ImageExtensions.SaveAsTga(Image, string, TgaEncoder)
    ImageExtensions.SaveAsTgaAsync(Image, Stream, TgaEncoder, CancellationToken)
    ImageExtensions.SaveAsTgaAsync(Image, Stream, CancellationToken)
    ImageExtensions.SaveAsTgaAsync(Image, string)
    ImageExtensions.SaveAsTgaAsync(Image, string, TgaEncoder, CancellationToken)
    ImageExtensions.SaveAsTgaAsync(Image, string, CancellationToken)
    ImageExtensions.SaveAsTiff(Image, Stream)
    ImageExtensions.SaveAsTiff(Image, Stream, TiffEncoder)
    ImageExtensions.SaveAsTiff(Image, string)
    ImageExtensions.SaveAsTiff(Image, string, TiffEncoder)
    ImageExtensions.SaveAsTiffAsync(Image, Stream, TiffEncoder, CancellationToken)
    ImageExtensions.SaveAsTiffAsync(Image, Stream, CancellationToken)
    ImageExtensions.SaveAsTiffAsync(Image, string)
    ImageExtensions.SaveAsTiffAsync(Image, string, TiffEncoder, CancellationToken)
    ImageExtensions.SaveAsTiffAsync(Image, string, CancellationToken)
    ImageExtensions.SaveAsWebp(Image, Stream)
    ImageExtensions.SaveAsWebp(Image, Stream, WebpEncoder)
    ImageExtensions.SaveAsWebp(Image, string)
    ImageExtensions.SaveAsWebp(Image, string, WebpEncoder)
    ImageExtensions.SaveAsWebpAsync(Image, Stream, WebpEncoder, CancellationToken)
    ImageExtensions.SaveAsWebpAsync(Image, Stream, CancellationToken)
    ImageExtensions.SaveAsWebpAsync(Image, string)
    ImageExtensions.SaveAsWebpAsync(Image, string, WebpEncoder, CancellationToken)
    ImageExtensions.SaveAsWebpAsync(Image, string, CancellationToken)
    ImageExtensions.SaveAsync(Image, Stream, IImageFormat, CancellationToken)
    ImageExtensions.SaveAsync(Image, string, IImageEncoder, CancellationToken)
    ImageExtensions.SaveAsync(Image, string, CancellationToken)
    ImageExtensions.ToBase64String(Image, IImageFormat)
    ProcessingExtensions.Clone(Image, Configuration, Action<IImageProcessingContext>)
    ProcessingExtensions.Clone(Image, Action<IImageProcessingContext>)
    ProcessingExtensions.Mutate(Image, Configuration, Action<IImageProcessingContext>)
    ProcessingExtensions.Mutate(Image, Action<IImageProcessingContext>)
    • Edit this page
    • View Source
    In this article
    • Constructors
      • Image(Configuration, PixelTypeInfo, ImageMetadata, Size)
    • Properties
      • Bounds
      • Configuration
      • Frames
      • Height
      • Metadata
      • NonGenericFrameCollection
      • PixelType
      • Size
      • Width
    • Methods
      • CloneAs<TPixel2>()
      • CloneAs<TPixel2>(Configuration)
      • DetectFormat(DecoderOptions, Stream)
      • DetectFormat(DecoderOptions, ReadOnlySpan<byte>)
      • DetectFormat(DecoderOptions, string)
      • DetectFormat(Stream)
      • DetectFormat(ReadOnlySpan<byte>)
      • DetectFormat(string)
      • DetectFormatAsync(DecoderOptions, Stream, CancellationToken)
      • DetectFormatAsync(DecoderOptions, string, CancellationToken)
      • DetectFormatAsync(Stream, CancellationToken)
      • DetectFormatAsync(string, CancellationToken)
      • Dispose()
      • Dispose(bool)
      • Identify(DecoderOptions, Stream)
      • Identify(DecoderOptions, ReadOnlySpan<byte>)
      • Identify(DecoderOptions, string)
      • Identify(Stream)
      • Identify(ReadOnlySpan<byte>)
      • Identify(string)
      • IdentifyAsync(DecoderOptions, Stream, CancellationToken)
      • IdentifyAsync(DecoderOptions, string, CancellationToken)
      • IdentifyAsync(Stream, CancellationToken)
      • IdentifyAsync(string, CancellationToken)
      • Load(DecoderOptions, Stream)
      • Load(DecoderOptions, ReadOnlySpan<byte>)
      • Load(DecoderOptions, string)
      • Load(Stream)
      • Load(ReadOnlySpan<byte>)
      • Load(string)
      • LoadAsync(DecoderOptions, Stream, CancellationToken)
      • LoadAsync(DecoderOptions, string, CancellationToken)
      • LoadAsync(Stream, CancellationToken)
      • LoadAsync(string, CancellationToken)
      • LoadAsync<TPixel>(DecoderOptions, Stream, CancellationToken)
      • LoadAsync<TPixel>(DecoderOptions, string, CancellationToken)
      • LoadAsync<TPixel>(Stream, CancellationToken)
      • LoadAsync<TPixel>(string, CancellationToken)
      • LoadPixelData<TPixel>(Configuration, ReadOnlySpan<byte>, int, int)
      • LoadPixelData<TPixel>(Configuration, ReadOnlySpan<TPixel>, int, int)
      • LoadPixelData<TPixel>(ReadOnlySpan<byte>, int, int)
      • LoadPixelData<TPixel>(ReadOnlySpan<TPixel>, int, int)
      • Load<TPixel>(DecoderOptions, Stream)
      • Load<TPixel>(DecoderOptions, ReadOnlySpan<byte>)
      • Load<TPixel>(DecoderOptions, string)
      • Load<TPixel>(Stream)
      • Load<TPixel>(ReadOnlySpan<byte>)
      • Load<TPixel>(string)
      • Save(Stream, IImageEncoder)
      • SaveAsync(Stream, IImageEncoder, CancellationToken)
      • UpdateSize(Size)
      • WrapMemory<TPixel>(Configuration, IMemoryOwner<byte>, int, int)
      • WrapMemory<TPixel>(Configuration, IMemoryOwner<byte>, int, int, ImageMetadata)
      • WrapMemory<TPixel>(Configuration, IMemoryOwner<TPixel>, int, int)
      • WrapMemory<TPixel>(Configuration, IMemoryOwner<TPixel>, int, int, ImageMetadata)
      • WrapMemory<TPixel>(Configuration, Memory<byte>, int, int)
      • WrapMemory<TPixel>(Configuration, Memory<byte>, int, int, ImageMetadata)
      • WrapMemory<TPixel>(Configuration, Memory<TPixel>, int, int)
      • WrapMemory<TPixel>(Configuration, Memory<TPixel>, int, int, ImageMetadata)
      • WrapMemory<TPixel>(Configuration, void*, int, int, int)
      • WrapMemory<TPixel>(Configuration, void*, int, int, int, ImageMetadata)
      • WrapMemory<TPixel>(IMemoryOwner<byte>, int, int)
      • WrapMemory<TPixel>(IMemoryOwner<TPixel>, int, int)
      • WrapMemory<TPixel>(Memory<byte>, int, int)
      • WrapMemory<TPixel>(Memory<TPixel>, int, int)
      • WrapMemory<TPixel>(void*, int, int, int)
    • Implements
    • Extension Methods
    Back to top Generated by DocFX