• 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
      • ImageBufferExtensionsHalconDotNet
      • ImageBufferExtensionsOpenCvSharp
      • ImageBufferExtensionsSystemDrawing
      • ImageBufferExtensionsSystemWindowsMedia
      • 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
    • ic4.WinForms
      • Dialogs
      • Display
      • PropertyDialogFlags

    Class ImageBufferExtensionsSystemDrawing

    Contains extension methods for ImageBuffer for interop with the System.Drawing library.

    Inheritance
    object
    ImageBufferExtensionsSystemDrawing
    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.System.Drawing.dll
    Syntax
    public static class ImageBufferExtensionsSystemDrawing
    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(); // Create copy in a System.Drawing.Bitmap object System.Drawing.Bitmap bmp = imageBuffer.CreateBitmapCopy();

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

    // Get image buffer from somewhere
    ImageBuffer imageBuffer = GetImageBuffer();
    // Create copy in a System.Drawing.Bitmap object
    System.Drawing.Bitmap bmp = imageBuffer.CreateBitmapCopy(imageBuffer);

    Methods

    CreateBitmapCopy(ImageBuffer)

    Creates a copy of the image buffer and stores it in a Bitmap.

    Declaration
    public static Bitmap CreateBitmapCopy(this ImageBuffer buffer)
    Parameters
    Type Name Description
    ImageBuffer buffer

    An image buffer

    Returns
    Type Description
    Bitmap

    A Bitmap containing a copy of the image data in the passed image buffer.

    Exceptions
    Type Condition
    ArgumentNullException

    buffer is null

    NotSupportedException

    The pixel format of the image buffer is not supported.

    CreateBitmapWrap(ImageBuffer)

    Wraps the passed image buffer in a Bitmap.

    Declaration
    public static Bitmap CreateBitmapWrap(this ImageBuffer buffer)
    Parameters
    Type Name Description
    ImageBuffer buffer

    An image buffer

    Returns
    Type Description
    Bitmap

    A Bitmap using the image buffer's memory as pixel storage.

    Remarks

    The returned bitmap becomes invalid when the image buffer is disposed.

    Exceptions
    Type Condition
    ArgumentNullException

    buffer is null

    NotSupportedException

    Data of the image buffer's pixel format cannot be wrapped in a Bitmap

    IsBitmapWrapSupported(ImageBuffer)

    Checks whether CreateBitmapWrap(ImageBuffer) can work on the image buffer's pixel format.

    Declaration
    public static bool IsBitmapWrapSupported(this ImageBuffer buffer)
    Parameters
    Type Name Description
    ImageBuffer buffer

    An image buffer

    Returns
    Type Description
    bool

    true, if the contents of the image buffer can be wrapped in a Bitmap, otherwise false.

    Remarks

    Wrapping the contents of an image buffer in a Bitmap is only possible if the pixel format is one of the following:

    • Mono8
    • BGR8
    • BGRa8
    Exceptions
    Type Condition
    ArgumentNullException

    buffer is null

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