Leadtools.Converters Namespace : RasterImageConverter Class |
public static class RasterImageConverter
'Declaration Public MustInherit NotInheritable Class RasterImageConverter
'Usage Dim instance As RasterImageConverter
public sealed static class RasterImageConverter
@interface LTRasterImageConverter : NSObject
public class RasterImageConverter
function Leadtools.Converters.RasterImageConverter()
public ref class RasterImageConverter abstract sealed
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.
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(); }