• Introduction
  • Programmer's Guide
  • Technical Articles
  • API Documentation
Search Results for

    Show / Hide Table of Contents
    • ic4
      • BufferPool
      • DeviceEnum
      • DeviceInfo
      • Display
      • DisplayNotation
      • DisplayRenderPosition
      • DisplayStatistics
      • DisplayType
      • EmbeddedDisplay
      • ErrorCode
      • ExternalOpenGLDisplay
      • FloatRepresentation
      • FloatingDisplay
      • FrameMetaData
      • Grabber
      • HandleObject
      • IBufferAllocator
      • IC4Exception
      • IDisplay
      • ImageBuffer
      • ImageBuffer.CopyOptions
      • ImageBufferExtensions
      • ImageBufferExtensionsOpenCvSharp
      • ImageType
      • IntRepresentation
      • Interface
      • Library
      • LogLevel
      • LogTarget
      • PixelFormat
      • PixelFormatExtensions
      • PngCompressionLevel
      • PropBoolean
      • PropCategory
      • PropCommand
      • PropEnumEntry
      • PropEnumeration
      • PropFloat
      • PropId
      • PropIdBoolean
      • PropIdCommand
      • PropIdEnumeration
      • PropIdFloat
      • PropIdInteger
      • PropIdRegister
      • PropIdString
      • PropInteger
      • PropRegister
      • PropString
      • Property
      • PropertyIncrementMode
      • PropertyMap
      • PropertyType
      • PropertyVisibility
      • QueueSink
      • QueueSinkConnectedEventArgs
      • QueueSinkEventArgs
      • QueueSinkQueueSizes
      • Sink
      • SinkMode
      • SinkType
      • SnapSink
      • SnapSinkAllocationStrategy
      • StreamSetupOption
      • StreamStatistics
      • TransportLayerType
      • VersionInfoFlags
      • VideoWriter
      • VideoWriterType

    Class ImageBufferExtensions

    Contains extension methods for ImageBuffer that allow saving image buffer contents into files of various file formats.

    Inheritance
    object
    ImageBufferExtensions
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: ic4
    Assembly: ic4dotnet.dll
    Syntax
    public static class ImageBufferExtensions
    Examples

    Since the members are extension methods, they can be called both explicitly and on image buffers directly, as if they were member functions.

    To call it as a member function, a using directive has to exist for the ic4 namespace:

    using ic4;
    

    // (...) // Get image buffer from somewhere ImageBuffer imageBuffer = GetImageBuffer(); // Save image buffer as bitmap file imageBuffer.SaveAsbitmap("test.bmp");

    Although not preferred, the function can also be called explicitly:

    // Get image buffer from somewhere
    ImageBuffer imageBuffer = GetImageBuffer();
    // Save image buffer as bitmap file
    ImageBufferExtensions.SaveAsbitmap(imageBuffer, "test.bmp");

    Methods

    SaveAsBitmap(ImageBuffer, string, bool)

    Saves an image buffer as a Bitmap file.

    Declaration
    public static void SaveAsBitmap(this ImageBuffer buffer, string filename, bool storeBayerRawDataAsMonochrome = false)
    Parameters
    Type Name Description
    ImageBuffer buffer

    An image buffer

    string filename

    Path of the image file

    bool storeBayerRawDataAsMonochrome

    If true, and the image buffer's pixel format is a bayer format, interpret the pixel data as monochrome and store the raw data as a monochrome image.

    Remarks

    Depending on the pixel format of the image buffer, a transformation is applied before saving the image:

    • Monochrome pixel formats are converted to Mono8 and stored as a 8-bit monochrome bitmap file.
    • Bayer, RGB and YUV pixel formats are converted to BGR8 and stored as a 24-bit color bitmap file.
    Exceptions
    Type Condition
    ArgumentNullException

    buffer is null, or filename is null

    IC4Exception

    Check ErrorCode and ToString() for details.

    SaveAsJpeg(ImageBuffer, string, int)

    Saves an image buffer as a Jpeg file

    Declaration
    public static void SaveAsJpeg(this ImageBuffer buffer, string filename, int qualityPercent = 75)
    Parameters
    Type Name Description
    ImageBuffer buffer

    An image buffer

    string filename

    Path of the image file

    int qualityPercent

    Specifies the Jpeg image quality in percent.

    High quality images will take more disk space, low quality images are smaller.

    Remarks

    Depending on the pixel format of the image buffer, a transformation is applied before saving the image:

    • Monochrome pixel formats are converted to Mono8 and stored as a monochrome Jpeg file.
    • Bayer, RGB and YUV pixel formats are converted to BGR8 stored as a color Jpeg file.
    Exceptions
    Type Condition
    ArgumentNullException

    buffer is null, or filename is null

    IC4Exception

    Check ErrorCode and ToString() for details.

    SaveAsPng(ImageBuffer, string, bool, PngCompressionLevel)

    Saves an image buffer as a PNG file.

    Declaration
    public static void SaveAsPng(this ImageBuffer buffer, string filename, bool storeBayerRawDataAsMonochrome = false, PngCompressionLevel compressionLevel = PngCompressionLevel.Auto)
    Parameters
    Type Name Description
    ImageBuffer buffer

    An image buffer

    string filename

    Path of the image file

    bool storeBayerRawDataAsMonochrome

    If true, and the image buffer's pixel format is a bayer format, interpret the pixel data as monochrome and store the raw data as a monochrome image.

    PngCompressionLevel compressionLevel

    Specifies the PNG compression level.

    Remarks

    Depending on the pixel format of the image buffer, a transformation is applied before saving the image:

    • Monochrome pixel formats with a bit depth higher than 8bpp are converted to Mono16 and stored as a monochrome PNG file with 16 bits per channel.
    • Mono8 image buffers are stored as a monochrome PNG file with 8 bits per channel.
    • Bayer format with a bit depth higher than 8bpp are converted to BGRa16 and stored as a 4-channel PNG with 16 bits per channel.
    • 8-bit Bayer, RGB and YUV pixel formats are converted to BGR8 stored as a 3-channel PNG file with 8 bits per channel.
    Exceptions
    Type Condition
    ArgumentNullException

    buffer is null, or filename is null

    IC4Exception

    Check ErrorCode and ToString() for details.

    SaveAsTiff(ImageBuffer, string, bool)

    Saves an image buffer as a Tiff file.

    Declaration
    public static void SaveAsTiff(this ImageBuffer buffer, string filename, bool storeBayerRawDataAsMonochrome = false)
    Parameters
    Type Name Description
    ImageBuffer buffer

    An image buffer

    string filename

    Path of the image file

    bool storeBayerRawDataAsMonochrome

    If true, and the image buffer's pixel format is a bayer format, interpret the pixel data as monochrome and store the raw data as a monochrome image.

    Remarks

    Depending on the pixel format of the image buffer, a transformation is applied before saving the image:

    • Monochrome pixel formats with a bit depth higher than 8bpp are converted to Mono16 and stored as a monochrome Tiff file with 16 bits per channel.
    • Mono8 image buffers are stored as a monochrome Tiff file with 8 bits per channel.
    • Bayer formats with a bit depth higher than 8bpp are converted to BGRa16 and stored as a 4-channel Tiff file with 16 bits per channel.
    • 8-bit Bayer, RGB and YUV pixel formats are converted to BGR8 stored as a 3-channel Tiff file with 8 bits per channel.
    Exceptions
    Type Condition
    ArgumentNullException

    buffer is null, or filename is null

    IC4Exception

    Check ErrorCode and ToString() for details.

    In this article
    Copyright ©️ 2024 The Imaging Source Europe GmbH www.theimagingsource.com