←Select platform

RasterImageRenderProperties Class

Summary

Controls the speed, quality, and style used when rendering a RasterRenderBuffer object into a RasterImage.

Syntax

C#
VB
WinRT C#
C++
public class RasterImageRenderProperties
Public Class RasterImageRenderProperties
public sealed class RasterImageRenderProperties
function Leadtools.Converters.RasterImageRenderProperties()
public ref class RasterImageRenderProperties

Remarks

The various RasterImageRenderer.Render method overloads require an instance of RasterImageRenderProperties to be passed. The members of the RasterImageRenderProperties controls the speed, quality, and style used when painting. If a value of null is passed to these methods, then a default instance of RasterImageRenderProperties is created and used.

Example

The following example shows how to use RasterImageRenderProperties to render a RasterImage into the surface of a Windows Runtime WriteableBitmap using a few of the options specified.

WinRT C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Converters; 
 
public async void RasterImageRenderPropertiesExample() 
{ 
   RasterCodecs codecs = new RasterCodecs(); 
   string srcFileName = @"Assets\Ocr1.tif"; 
   string[] destFileNames =  
   { 
      @"Ocr1_Normal.png", 
      @"Ocr1_ScaleToGrary.png" 
   }; 
 
   // Load the source image 
   RasterImage srcRasterImage; 
   StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName); 
   ILeadStream loadStream = LeadStreamFactory.Create(loadFile); 
   using (IDisposable leadStreamDisposable = loadStream as IDisposable) 
   { 
      srcRasterImage = await codecs.LoadAsync(loadStream); 
   } 
 
   // Create writeable bitmaps that fit inside 300 by 300 pixels keeping the image aspect ratio 
   LeadRect destRect = LeadRectHelper.Create(0, 0, 300, 300); 
   destRect = RasterImage.CalculatePaintModeRectangle( 
      srcRasterImage.ImageWidth, 
      srcRasterImage.ImageHeight, 
      destRect, 
      RasterPaintSizeMode.Fit, 
      RasterPaintAlignMode.Near, 
      RasterPaintAlignMode.Near); 
 
   // Create the writeable bitmaps 
   for (int i = 0; i < 2; i++) 
   { 
      WriteableBitmap bitmap = new WriteableBitmap(destRect.Width, destRect.Height); 
 
      // Create a RasterRenderBuffer object for the bitmap 
      RasterRenderBuffer renderBuffer = RasterRenderBuffer.CreateFromWriteableBitmap(bitmap.PixelWidth, bitmap.PixelHeight, bitmap.PixelBuffer); 
 
      // Render the image into the buffer using scale to gray and without 
      RasterImageRenderProperties properties = new RasterImageRenderProperties(); 
 
      if (i == 0) 
         properties.RenderDisplayMode = RasterImageRenderDisplayModeFlags.None; 
      else 
         properties.RenderDisplayMode = RasterImageRenderDisplayModeFlags.ScaleToGray; 
 
      RasterImageRenderer.Render(srcRasterImage, renderBuffer, destRect, properties); 
      bitmap.Invalidate(); 
 
      // Save the image using LEAD as PNG 
      using (RasterImage saveImage = RasterImageConverter.ConvertFromImageSource(bitmap, ConvertFromImageOptions.None)) 
      { 
         StorageFile saveFile = await Tools.AppLocalFolder.CreateFileAsync(destFileNames[i], CreationCollisionOption.ReplaceExisting); 
         ILeadStream saveStream = LeadStreamFactory.Create(saveFile); 
         using (IDisposable leadStreamDisposable = saveStream as IDisposable) 
         { 
            await codecs.SaveAsync(saveImage, saveStream, RasterImageFormat.Png, 32); 
         } 
      } 
   } 
 
   // Clean up 
   srcRasterImage.Dispose(); 
   codecs.Dispose(); 
} 

Requirements

Target Platforms

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