←Select platform

ToRasterImage Method

Summary

Converts the data inside this buffer into a RasterImage.

Syntax

C#
VB
WinRT C#
C++
public Leadtools.RasterImage ToRasterImage()
Public Function ToRasterImage() As Leadtools.RasterImage
public Leadtools.RasterImage ToRasterImage()
function Leadtools.Converters.RasterRenderBuffer.ToRasterImage()
public: 
Leadtools.RasterImage^ ToRasterImage(); 

Return Value

The RasterImage object created.

Remarks

The RasterImage returned will have the same width, height, color order and bits per pixel specified in Width, Height, Order and BitsPerPixel.

The image data are copied into the RasterImage.

You can use this method to quickly convert a Windows Runtime WriteableBitmap or HTML ImageData to a LEADTOOLS RasterImage object.

Example

WinRT C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Converters; 
 
public async void RasterRenderBufferToRasterImageExample() 
{ 
   string srcFileName = @"Assets\Ocr1.tif"; 
   string destFileName = @"ToRasterImage.png"; 
   // Load the source image 
   StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName); 
   IRandomAccessStream loadStream = await loadFile.OpenReadAsync(); 
   WriteableBitmap bitmap = new WriteableBitmap(1, 1); 
   bitmap.SetSource(loadStream); 
 
   // Create a RasterRenderBuffer object for the bitmap 
   RasterRenderBuffer renderBuffer = RasterRenderBuffer.CreateFromWriteableBitmap(bitmap.PixelWidth, bitmap.PixelHeight, bitmap.PixelBuffer); 
 
   // Create a raster image from it and save it 
   using (RasterImage rasterImage = renderBuffer.ToRasterImage()) 
   { 
      StorageFile saveFile = await Tools.AppLocalFolder.CreateFileAsync(destFileName, CreationCollisionOption.ReplaceExisting); 
      ILeadStream saveStream = LeadStreamFactory.Create(saveFile); 
      using (IDisposable leadStreamDisposable = saveStream as IDisposable) 
      { 
         using (RasterCodecs codecs = new RasterCodecs()) 
         { 
            await codecs.SaveAsync(rasterImage, saveStream, RasterImageFormat.Png, 32); 
         } 
      } 
   } 
} 

Requirements

Target Platforms

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