Leadtools.Windows.Media Send comments on this topic. | Back to Introduction - All Topics | Help Version 15.8.31
ConvertFrom Method
See Also 
Leadtools.Windows.Media Namespace > RasterImageMediaConverter Class : ConvertFrom Method




srcImage
The RasterImage object containing the image data to convert.
flags
Options to control the conversion operation. The following values can be ORed together:
ValueMeaning
RasterImageMediaConverterFromFlags.NoneNo options
RasterImageMediaConverterFromFlags.KeepAlphaValues Use srcImage alpha values when converting from and to a pixel format that supports an alpha channel. If this flag is not set, the alpha values in srcImage will be ignored (if present) and an alpha value of all 1's (opaque) will be used instead. If the destination pixel format does not support alpha, this value is ignored.
RasterImageMediaConverterFromFlags.KeepViewPerspective Do not rotate or flip the destination image if srcImage has a view perspective other than RasterViewPerspective.TopLeft/>. For example, if srcImage has a view perspective of RasterViewPerspective.BottomLeft, the result destination image will be flipped. If this flag is not present, the conversion method will rotate/flip the scanlines as needed.
RasterImageMediaConverterFromFlags.IgnoreLowHighBitsOnGrayImages Ignore the LowBit and HighBit values if srcImage is a grayscale image with bits per pixel value of 12 or 16. If this flag is not present, the low/high bit values will be used when converting the scanlines of the destination image.
Converts a LEADTOOLS for .NET RasterImage object to Windows Presentation Foundation (WPF) ImageSource.

Syntax

Visual Basic (Declaration) 
Public Shared Function ConvertFrom( _
   ByVal srcImage As RasterImage, _
   ByVal flags As RasterImageMediaConverterFromFlags _
) As ImageSource
Visual Basic (Usage)Copy Code
Dim srcImage As RasterImage
Dim flags As RasterImageMediaConverterFromFlags
Dim value As ImageSource
 
value = RasterImageMediaConverter.ConvertFrom(srcImage, flags)
C# 
public static ImageSource ConvertFrom( 
   RasterImage srcImage,
   RasterImageMediaConverterFromFlags flags
)
Managed Extensions for C++ 
public: static ImageSource ConvertFrom( 
   RasterImage srcImage,
   RasterImageMediaConverterFromFlags flags
) 
C++/CLI 
public:
static ImageSource ConvertFrom( 
   RasterImage srcImage,
   RasterImageMediaConverterFromFlags flags
) 

Parameters

srcImage
The RasterImage object containing the image data to convert.
flags
Options to control the conversion operation. The following values can be ORed together:
ValueMeaning
RasterImageMediaConverterFromFlags.NoneNo options
RasterImageMediaConverterFromFlags.KeepAlphaValues Use srcImage alpha values when converting from and to a pixel format that supports an alpha channel. If this flag is not set, the alpha values in srcImage will be ignored (if present) and an alpha value of all 1's (opaque) will be used instead. If the destination pixel format does not support alpha, this value is ignored.
RasterImageMediaConverterFromFlags.KeepViewPerspective Do not rotate or flip the destination image if srcImage has a view perspective other than RasterViewPerspective.TopLeft/>. For example, if srcImage has a view perspective of RasterViewPerspective.BottomLeft, the result destination image will be flipped. If this flag is not present, the conversion method will rotate/flip the scanlines as needed.
RasterImageMediaConverterFromFlags.IgnoreLowHighBitsOnGrayImages Ignore the LowBit and HighBit values if srcImage is a grayscale image with bits per pixel value of 12 or 16. If this flag is not present, the low/high bit values will be used when converting the scanlines of the destination image.

Return Value

An ImageSource object representing the converted image.

Example

For an example, refer to RasterImageMediaConverter

Remarks

LEADTOOLS for .NET and Windows Presentation Foundation support different pixel formats. These pixel formats may not be identical in some cases. The conversion process takes care of converting scanlines to a suitable format that best matches the source data. The following table shows the result pixel format achieved when passing images with different bits/pixel values:
Source Bits/PixelResult PixelFormat
1 bits/pixel with black on white paletteBlackWhite
1 bits/pixel with any other paletteIndexed1
2 bits/pixelIndexed2
3 or 4 bits/pixelIndexed4
5, 6, 7 or 8 bits/pixelIndexed8
16 bits/pixel with byte order value of RasterByteOrder.BgrBgr555
16 bits/pixel with byte order value of RasterByteOrder.GrayBgra32
12, 24, 32, 48 or 64 bits/pixelBgra32

Use the ConvertTo method to convert a WPF ImageSource to LEADTOOLS for .NET RasterImage object.

The conversion works by copying the image data over to the new destination. Currently, there is no support for sharing memory between a RasterImage and an ImageSource.

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also