LEADTOOLS WPF and Silverlight (Leadtools.Converters assembly)
LEAD Technologies, Inc

ConvertToImageSource Method






The Leadtools.RasterImage object containing the image data to convert.
Options to control the conversion operation. The following values can be ORed together:
Value Meaning
ConvertToImageSource.None No options
ConvertToImageSource.KeepAlphaValues

If the source Leadtools.RasterImage is 32 or 64-bits/pixel, then use the alpha values from this alpha if the result of the conversion is also a 32 or 64-bits/pixel Windows.UI.Xaml.Media.ImageSource.

If this flag is not specified, the resulting Windows.UI.Xaml.Media.ImageSource will always have an alpha value of all 1's (255 for 32-bit images or 65535 for 64-bit images) regardless of the alpha values in the source Leadtools.RasterImage. This can be useful when converting some 32-bit images that have 0 for the alpha (such as BMP files) which translate into a Windows.UI.Xaml.Media.ImageSource that is completely transparent.

If this flag is specified, then the source image alpha values will be used as is.

ConvertToImageSource.KeepViewPerspective

Keep the original Leadtools.RasterImage view perspective. Leadtools.RasterImage objects support having an image data orientation other than the normal top-left through the RasterImage.ViewPerspective property.

If the source Leadtools.RasterImage has a view-perspective other than RasterViewPerspective.TopLeft and this flag is specified, then the resulting Windows.UI.Xaml.Media.ImageSource can be flipped, reversed or rotated. For example, if the source view-perspective is RasterViewPerspective.BottomLeft and this flag is specified in the conversion options, then the resulting Windows.UI.Xaml.Media.ImageSource will be flipped.

If this flag is not specified, then the conversion can flip, reverse or rotate the image data as needed to provide correct (top-left) Windows.UI.Xaml.Media.ImageSource.

ConvertToImageSource.IgnoreLowHighBitsOnGrayImages

Do not use the grayscale bit window values when converting 12 or 16-bit grayscale Leadtools.RasterImage objects. The Leadtools.RasterImage object contains the RasterImage.LowBit and RasterImage.HighBit values that can be set to provide a Window into the image data. This is mostly used by medical applications during a window-leveling operations.

If this flag is specified, the RasterImage.LowBit and RasterImage.HighBit values are ignored and all of the image data is used when converting the Leadtools.RasterImage to Windows.UI.Xaml.Media.ImageSource.

If this flag is not specified, then only the image data between RasterImage.LowBit and RasterImage.HighBit is used.

Converts a LEADTOOLS for .NET Leadtools.RasterImage object into a WinRT Windows.UI.Xaml.Media.ImageSource. .NET support WinRT support
Syntax
public static WinRT_ImageSource ConvertToImageSource( 
   RasterImage image,
   ConvertToImageOptions options
)
'Declaration
 
Public Shared Function ConvertToImageSource( _
   ByVal image As RasterImage, _
   ByVal options As ConvertToImageOptions _
) As WinRT_ImageSource
'Usage
 
Dim image As RasterImage
Dim options As ConvertToImageOptions
Dim value As WinRT_ImageSource
 
value = RasterImageConverter.ConvertToImageSource(image, options)
public static WinRT_ImageSource ConvertToImageSource( 
   RasterImage image,
   ConvertToImageOptions options
)
 function Leadtools.Converters.RasterImageConverter.ConvertToImageSource( 
   image ,
   options 
)
public:
static WinRT_ImageSource^ ConvertToImageSource( 
   RasterImage^ image,
   ConvertToImageOptions options
) 

Parameters

image
The Leadtools.RasterImage object containing the image data to convert.
options
Options to control the conversion operation. The following values can be ORed together:
Value Meaning
ConvertToImageSource.None No options
ConvertToImageSource.KeepAlphaValues

If the source Leadtools.RasterImage is 32 or 64-bits/pixel, then use the alpha values from this alpha if the result of the conversion is also a 32 or 64-bits/pixel Windows.UI.Xaml.Media.ImageSource.

If this flag is not specified, the resulting Windows.UI.Xaml.Media.ImageSource will always have an alpha value of all 1's (255 for 32-bit images or 65535 for 64-bit images) regardless of the alpha values in the source Leadtools.RasterImage. This can be useful when converting some 32-bit images that have 0 for the alpha (such as BMP files) which translate into a Windows.UI.Xaml.Media.ImageSource that is completely transparent.

If this flag is specified, then the source image alpha values will be used as is.

ConvertToImageSource.KeepViewPerspective

Keep the original Leadtools.RasterImage view perspective. Leadtools.RasterImage objects support having an image data orientation other than the normal top-left through the RasterImage.ViewPerspective property.

If the source Leadtools.RasterImage has a view-perspective other than RasterViewPerspective.TopLeft and this flag is specified, then the resulting Windows.UI.Xaml.Media.ImageSource can be flipped, reversed or rotated. For example, if the source view-perspective is RasterViewPerspective.BottomLeft and this flag is specified in the conversion options, then the resulting Windows.UI.Xaml.Media.ImageSource will be flipped.

If this flag is not specified, then the conversion can flip, reverse or rotate the image data as needed to provide correct (top-left) Windows.UI.Xaml.Media.ImageSource.

ConvertToImageSource.IgnoreLowHighBitsOnGrayImages

Do not use the grayscale bit window values when converting 12 or 16-bit grayscale Leadtools.RasterImage objects. The Leadtools.RasterImage object contains the RasterImage.LowBit and RasterImage.HighBit values that can be set to provide a Window into the image data. This is mostly used by medical applications during a window-leveling operations.

If this flag is specified, the RasterImage.LowBit and RasterImage.HighBit values are ignored and all of the image data is used when converting the Leadtools.RasterImage to Windows.UI.Xaml.Media.ImageSource.

If this flag is not specified, then only the image data between RasterImage.LowBit and RasterImage.HighBit is used.

Return Value

An Windows.UI.Xaml.Media.ImageSource object representing the converted image.
Remarks

Microsoft WinRT

LEADTOOLS for .NET and WinRT 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 ConvertToImageSource method supports converting from any Leadtools.RasterImage regardless of the combination of the bits/pixel, compression, color order, or grayscale properties of the source image. The ConvertToImageSource method will always returns a valid WinRT Windows.UI.Xaml.Media.ImageSource by allocating temporary memory for the data and performing the necessary conversion on it.

In some cases, the Leadtools.RasterImage data is compatible with WinRT and no conversion takes place. Converting a compatible Leadtools.RasterImage into a WinRT Windows.UI.Xaml.Media.ImageSource is faster and takes less resources than converting a non-compatible image. Please note that currently WinRT does not allow direct access to the raw data pointers where the image data is stored. Therefore, there is always at least one copy operation regardless of whether the source data can be used directly by a WinRT image (For example, through the use of the System.Windows.Media.Imaging.BitmapSource.Create method).

For a Leadtools.RasterImage to be compatible with WinRT, it must have the following properties:

The following table lists the source Leadtools.RasterImage bits/pixel and source data properties and whether the combination is compatible with WinRT.

Source Bits/Pixel More Source Data Compatible Resulting PixelFormat

1

Black on white palette

Yes

System.Windows.Media.PixelFormats.BlackWhite

1

Any other palette

Yes

System.Windows.Media.PixelFormats.Indexed1

2

-

Yes

System.Windows.Media.PixelFormats.Indexed2

3

-

No

System.Windows.Media.PixelFormats.Indexed4

4

-

Yes

System.Windows.Media.PixelFormats.Indexed4

5

-

No

System.Windows.Media.PixelFormats.Indexed8

6

-

No

System.Windows.Media.PixelFormats.Indexed8

7

No

System.Windows.Media.PixelFormats.Indexed8

8

Grayscale palette

Yes

System.Windows.Media.PixelFormats.Gray8

8

Color palette

Yes

System.Windows.Media.PixelFormats.Gray8

12

-

No

System.Windows.Media.PixelFormats.Gray16

16

Compatible grayscale data (Refer to notes on grayscale images below)

Yes

System.Windows.Media.PixelFormats.Gray16

16

Incompatible grayscale data

No

System.Windows.Media.PixelFormats.Bgra32

16

Color data

Yes

System.Windows.Media.PixelFormats.Bgr555

24

BGR color order

Yes

System.Windows.Media.PixelFormats.Bgr24

24

RGB color order

Yes

System.Windows.Media.PixelFormats.Rgb24

32

BGR color order (Refer to notes on alpha channel below)

Yes

System.Windows.Media.PixelFormats.Bgra32

32

RGB color order

No

System.Windows.Media.PixelFormats.Bgra32

48

BGR color order

No

System.Windows.Media.PixelFormats.Rgb48

48

RGB color order

Yes

System.Windows.Media.PixelFormats.Rgb48

64

BGR color order

No

System.Windows.Media.PixelFormats.Rgba64

64

RGB color order (Refer to notes on alpha channel below)

Yes

System.Windows.Media.PixelFormats.Rgba64

Notes on grayscale images

Both LEADTOOLS and Windows Presentation Foundation support 16-bit grayscale image data. However, LEADTOOLS supports extra features such as low/high bit values and color lookup tables. For a LEADTOOLS 16-bit grayscale Leadtools.RasterImage to be compatible with a WinRT image with System.Windows.Media.PixelFormats.Gray16, the following conditions must be met:

Notes on the alpha channel

When converting images that support an alpha channel (32 or 64 bits/pixel images), the ConvertToImageSource method supports masking out the alpha channel bits to all 1's through or using the source image alpha channel bits through the use of the ConvertToImageSource.KeepAlphaValues flag. Masking out the alpha channel bits requires the source data image to be processed and as a result, the image will not be compatible with WinRT.

For more information refer to RasterImage and WinRT.

Example

For an example, refer to RasterImageConverter.

Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

RasterImageConverter Class
RasterImageConverter Members

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.