←Select platform

RasterImageConverter Class

Summary

Converts a LEADTOOLS RasterImage to and from a WinRT image object.

Syntax

C#
VB
Java
Objective-C
WinRT C#
C++
public static class RasterImageConverter
Public MustInherit NotInheritable Class RasterImageConverter
public sealed static class RasterImageConverter
@interface LTRasterImageConverter : NSObject
public 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 RasterImage to and from a WinRT image object.

The RasterImageConverter class contains the following functionality:

Method Description
ConvertToImageSource

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

ConvertFromImageSource

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

TestCompatible

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

For more information refer to RasterImage and WinRT.

Example

WinRT C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Converters; 
 
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

Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
Click or drag to resize