• 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 ImageBufferExtensionsSystemWindowsMedia

    Contains extension methods for ImageBuffer for interop with the System.Windows.Media library.

    Inheritance
    object
    ImageBufferExtensionsSystemWindowsMedia
    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.Windows.Media.dll
    Syntax
    public static class ImageBufferExtensionsSystemWindowsMedia
    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 BitmapSource object System.Windows.Media.Imaging.BitmapSource bmp = imageBuffer.CreateBitmapSourceCopy();

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

    // Get image buffer from somewhere
    ImageBuffer imageBuffer = GetImageBuffer();
    // Create copy in a BitmapSource object
    System.Windows.Media.Imaging.BitmapSource bmp = ImageBufferExtensionsSystemWindowsMedia.CreateBitmapSourceCopy(imageBuffer);

    Methods

    CopyTo(ImageBuffer, WriteableBitmap)

    Copies the contents of the passed ImageBuffer into the passed WriteableBitmap.

    Declaration
    public static void CopyTo(this ImageBuffer buffer, WriteableBitmap bmp)
    Parameters
    Type Name Description
    ImageBuffer buffer

    An image buffer

    WriteableBitmap bmp

    A destination bitmap

    The Format of the bitmap must be one of the following:

    • Bgr24
    • Bgra32
    • Gray8
    • Gray16
    Remarks

    If the pixel format of the source image buffer and the format of the destination bitmap is not a perfect match, a conversion operation occurs. For example, bayer raw data can be converted to RGB.

    Exceptions
    Type Condition
    ArgumentNullException

    buffer is null or bmp is null

    ArgumentException

    The passed image buffer and bitmap did not have the same dimensions

    NotSupportedException

    The pixel format of the bitmap specified by bmp is not supported.

    CreateBitmapSourceCopy(ImageBuffer, double, double)

    Creates a new BitmapSource containing a copy of the image data of the passed image buffer.

    Declaration
    public static BitmapSource CreateBitmapSourceCopy(this ImageBuffer buffer, double dpiX = 96, double dpiY = 96)
    Parameters
    Type Name Description
    ImageBuffer buffer

    An image buffer

    double dpiX

    The value to be set in DpiX

    double dpiY

    The value to be set in DpiY

    Returns
    Type Description
    BitmapSource

    A BitmapSource containing a copy of the image data of the passed image buffer.

    Exceptions
    Type Condition
    ArgumentNullException

    buffer is null

    NotSupportedException

    The pixel format of the passed image buffer is not supported.

    CreateCompatibleWritableBitmap(ImageBuffer, double, double)

    Creates a WriteableBitmap with a format that the image buffer's contents can be copied or converted into.

    Declaration
    public static WriteableBitmap CreateCompatibleWritableBitmap(this ImageBuffer buffer, double dpiX = 96, double dpiY = 96)
    Parameters
    Type Name Description
    ImageBuffer buffer

    An image buffer

    double dpiX

    The value to be set in DpiX

    double dpiY

    The value to be set in DpiY

    Returns
    Type Description
    WriteableBitmap

    A WriteableBitmap that can be used as the target of a CopyTo(ImageBuffer, WriteableBitmap) operation.

    Exceptions
    Type Condition
    ArgumentNullException

    buffer is null

    NotSupportedException

    The pixel format of the passed image buffer is not supported.

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