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

RasterImageRenderProperties Class

Example 





Members 
Controls the speed, quality, and style used when rendering a RasterRenderBuffer object into a Leadtools.RasterImage. .NET support WinRT support
Object Model
RasterImageRenderProperties Class
Syntax
public class RasterImageRenderProperties 
'Declaration
 
Public Class RasterImageRenderProperties 
'Usage
 
Dim instance As 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
Copy CodeCopy Code  
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: 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

RasterImageRenderProperties Members
Leadtools.Converters Namespace

 

 


Products | Support | Contact Us | Copyright Notices

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