RasterImagePainter Class (original) (raw)

Syntax

public static class RasterImagePainter 
public ref class RasterImagePainter abstract sealed  
class RasterImagePainter: 

Example

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:\LEADTOOLS22\Resources\Images"; }