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

RasterImageConverter Class

Example 





Members 
Converts a LEADTOOLS Leadtools.RasterImage to and from a WinRT image object. .NET support WinRT support
Object Model
RasterImageConverter Class
Syntax
public static class RasterImageConverter 
'Declaration
 
Public MustInherit NotInheritable Class RasterImageConverter 
'Usage
 
Dim instance As RasterImageConverter
public sealed static class RasterImageConverter 
function Leadtools.Converters.RasterImageConverter()
public ref class RasterImageConverter abstract sealed 
Remarks

The LEADTOOLS RasterImage class provides a platform-independent representation of an image. It serves as a working area for image manipulation and conversion. LEADTOOLS functions use this class for accessing the image in memory and for maintaining the characteristics of the image. This class contains the functionality needed to convert a LEADTOOLS Leadtools.RasterImage to and from a WinRT image object.

The RasterImageConverter class contains the following functionality:

Method Description
ConvertToImageSource

Converts a LEADTOOLS Leadtools.RasterImage to a WinRT Windows.UI.Xaml.Media.ImageSource.

ConvertFromImageSource

Converts a WinRT Windows.UI.Xaml.Media.ImageSource to a LEADTOOLS Leadtools.RasterImage.

TestCompatible

Utility methods for testing whether a LEADTOOLS Leadtools.RasterImage is WinRT compatible.

For more information refer to RasterImage and WinRT.

Example
Copy CodeCopy Code  
public async void RasterImageConverterExample()
{
   string srcFileName = @"Assets\Ocr1.tif";
   string destFileName = @"saved.png";
   RasterCodecs codecs = new RasterCodecs();

   ImageSource imageSource;

   // Load the source image image
   StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName);
   ILeadStream loadStream = LeadStreamFactory.Create(loadFile);
   using (IDisposable leadStreamDisposable = loadStream as IDisposable)
   {
      using (RasterImage rasterImage = await codecs.LoadAsync(loadStream))
      {
         // Convert it to an image source
         imageSource = RasterImageConverter.ConvertToImageSource(rasterImage, ConvertToImageOptions.None);
      }
   }

   // Convert the imageSource back to a raster image and save it
   using (RasterImage rasterImage = RasterImageConverter.ConvertFromImageSource(imageSource, ConvertFromImageOptions.None))
   {
      StorageFile saveFile = await Tools.AppLocalFolder.CreateFileAsync(destFileName, CreationCollisionOption.ReplaceExisting);
      ILeadStream saveStream = LeadStreamFactory.Create(saveFile);
      using (IDisposable leadStreamDisposable = saveStream as IDisposable)
      {
         await codecs.SaveAsync(rasterImage, saveStream, RasterImageFormat.Png, 32);
      }
   }

   codecs.Dispose();
}
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 Members
Leadtools.Converters Namespace

 

 


Products | Support | Contact Us | Copyright Notices

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