Occurs after painting the Image and the FloaterImage. Any additional painting should be done in this event.
public event PaintEventHandler PostImagePaint public:event PaintEventHandler^ PostImagePaint
public:event PaintEventHandler^ PostImagePaint
The event handler receives an argument of type PaintEventArgs containing data related to this event. The following PaintEventArgs properties provide information specific to this event.
| Property | Description |
|---|---|
| ClipRectangle | Gets the rectangle in which to paint. |
| Graphics | Gets the graphics used to paint. |
using Leadtools.WinForms;using Leadtools;using Leadtools.Codecs;using Leadtools.ImageProcessing.Color;using Leadtools.Drawing;class MyForm2 : Form{class MyPanel : Panel{protected override void OnPaintBackground(PaintEventArgs pe){// do nothing}}RasterImageViewer viewer;MyPanel panel;public MyForm2(string title){Text = title;Size = new Size(750, 450);// Create the raster viewerviewer = new RasterImageViewer();viewer.DoubleBuffer = true;viewer.Dock = DockStyle.Fill;// Load an image into the viewerRasterCodecs codecs = new RasterCodecs();viewer.Image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Sample1.cmp"));codecs.Dispose();// Create the panelpanel = new MyPanel();panel.Parent = this;panel.Width = 400;panel.Height = 400;panel.Dock = DockStyle.Right;panel.BackColor = Color.Beige;panel.BorderStyle = BorderStyle.Fixed3D;Controls.Add(panel);panel.BringToFront();Controls.Add(viewer);viewer.BringToFront();panel.Paint += new PaintEventHandler(panel_Paint);viewer.PostImagePaint += new PaintEventHandler(viewer_PostImagePaint);viewer.RedirectImagePaint += new EventHandler(viewer_RedirectImagePaint);}void viewer_RedirectImagePaint(object sender, EventArgs e){panel.Invalidate();}void panel_Paint(object sender, PaintEventArgs e){if (viewer.Image != null){int dx = viewer.Image.Width / 2;int dy = viewer.Image.Height / 2;Rectangle dest = viewer.SourceRectangle;// move center of image to originMatrix m1 = new Matrix(1, 0, 0, 1, -dx, -dy);// mirror the imageMatrix m2 = new Matrix(-1, 0, 0, 1, 0, 0);m1.Multiply(m2, MatrixOrder.Append);// move back to original locationMatrix m3 = new Matrix(1, 0, 0, 1, dx, dy);m1.Multiply(m3, MatrixOrder.Append);// scale image to fit on panelfloat scaleX = (float)panel.Width / (float)viewer.Image.Width;float scaleY = (float)panel.Height / (float)viewer.Image.Height;Matrix m4 = new Matrix(scaleX, 0, 0, scaleY, 0, 0);m1.Multiply(m4, MatrixOrder.Append);// display contents of RaserImageViewer on panelviewer.RedirectPaint(e.Graphics,Rectangle.Empty, //_viewer.SourceRectangle,Rectangle.Empty,Rectangle.Empty, //e.ClipRectangle,m1);}}private void viewer_PostImagePaint(object sender, PaintEventArgs e){Graphics graphics = e.Graphics;GraphicsState graphicsState = graphics.Save();Font font = new Font("Arial", 16);e.Graphics.DrawString("This text stays with the window", font, Brushes.Yellow, new PointF(100, 100));graphics.MultiplyTransform(viewer.Transform);e.Graphics.DrawString("This text stays with the image.", font, Brushes.White, new PointF(100, 200));graphics.Restore(graphicsState);graphics.Flush();}}public void RasterImageViewer_RedirectPaint(string title){MyForm2 form = new MyForm2(title);form.ShowDialog();}static class LEAD_VARS{public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images";}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
