←Select platform

Is this page helpful?

In this page

RasterImagePainter Class

Summary
Support for painting a LEADTOOLS Leadtools.RasterImage using GDI and GDI+ platforms.
Syntax
C#
C++/CLI
Python
public static class RasterImagePainter 
public ref class RasterImagePainter abstract sealed  
class RasterImagePainter: 
Remarks

The LEADTOOLS RasterImage class provides 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 topic discusses how to use the LEADTOOLS RasterImage class with the Windows GDI and GDI+ (System.Drawing) platforms.

For more information refer to RasterImage and GDI/GDI+.

Example
C#
Copied to clipboard
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Drawing; 
using Leadtools.ImageProcessing; 
 
 
public void PaintExample() 
{ 
   PaintForm f = new PaintForm(); 
   f.ShowDialog(); 
} 
 
class PaintForm : Form 
{ 
   private RasterImage image; 
   private RasterPaintProperties props; 
 
   public PaintForm() 
   { 
      // Load the image 
      RasterCodecs codecs = new RasterCodecs(); 
 
      string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.tif"); 
      image = codecs.Load(srcFileName); 
 
      Text = "Normal - doubleclick to change."; 
      props = RasterPaintProperties.Default; 
      props.PaintDisplayMode = RasterPaintDisplayModeFlags.None; 
   } 
 
   protected override void Dispose(bool disposing) 
   { 
      // Clean up 
      if (disposing) 
      { 
         image.Dispose(); 
      } 
 
      base.Dispose(disposing); 
   } 
 
   protected override void OnDoubleClick(EventArgs e) 
   { 
      if ((props.PaintDisplayMode & RasterPaintDisplayModeFlags.ScaleToGray) == RasterPaintDisplayModeFlags.ScaleToGray) 
      { 
         Text = "Normal - doubleclick to change."; 
         props.PaintDisplayMode &= ~RasterPaintDisplayModeFlags.ScaleToGray; 
      } 
      else 
      { 
         Text = "ScaleToGray - doubleclick to change."; 
         props.PaintDisplayMode |= RasterPaintDisplayModeFlags.ScaleToGray; 
      } 
 
      Invalidate(); 
 
      base.OnDoubleClick(e); 
   } 
 
   protected override void OnPaint(PaintEventArgs e) 
   { 
      // Draw the image fit and center on this form 
      LeadRect destRect = LeadRect.FromLTRB(ClientRectangle.Left, ClientRectangle.Top, ClientRectangle.Right, ClientRectangle.Bottom); 
      destRect = RasterImage.CalculatePaintModeRectangle( 
         image.ImageWidth, 
         image.ImageHeight, 
         destRect, 
         RasterPaintSizeMode.Fit, 
         RasterPaintAlignMode.Center, 
         RasterPaintAlignMode.Center); 
      RasterImagePainter.Paint(image, e.Graphics, LeadRect.Empty, destRect, props); 
 
      base.OnPaint(e); 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Drawing Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.