Renders the item region.
public event EventHandler<ImageViewerRenderEventArgs> RenderItemRegion
public:
event EventHandler<Leadtools::Controls::ImageViewerRenderEventArgs^>^ RenderItemRegion
During this part of the rendering cycle, the viewer will check if the image of this item contains a valid region. If this is true and the value of ImageRegionRenderMode is other than ControlRegionRenderMode.None then the viewer will render the outline of the region on top of the image.
For more information, refer to Image Viewer Rendering.
using Leadtools;
using Leadtools.Controls;
using Leadtools.Codecs;
using Leadtools.Drawing;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Color;
public void ImageViewerPostRender_Example()
{
// Clear all the images already the viewer
_imageViewer.Items.Clear();
// Use vertical view layout
_imageViewer.ViewLayout = new ImageViewerVerticalViewLayout();
// Make sure the item size is larger than the image size (thumbnails mode)
_imageViewer.ItemSize = LeadSize.Create(200, 200);
_imageViewer.ItemPadding = new Padding(8, 8, 8, 20);
_imageViewer.ImageBorderThickness = 1;
// Add 4 items to the viewer
using (var codecs = new RasterCodecs())
{
for (var page = 1; page <= 4; page++)
{
var item = new ImageViewerItem();
var fileName = Path.Combine(LEAD_VARS.ImagesDir, string.Format("ocr{0}.tif", page));
// Create a thumbnail from the image
using (var image = codecs.Load(fileName, page))
{
item.Image = image.CreateThumbnail(180, 180, 24, RasterViewPerspective.TopLeft, RasterSizeFlags.Resample);
}
item.Text = string.Format("Item {0}", page - 1);
_imageViewer.Items.Add(item);
}
}
// Render on the view
_imageViewer.PostRender += (sender, e) =>
{
// Rendering the whole view
var graphics = e.PaintEventArgs.Graphics;
// Blue ellipse at fixed position. This will stay the same and will not scroll or zoom
using (var brush = new SolidBrush(Color.FromArgb(128, Color.Blue)))
graphics.FillEllipse(brush, new Rectangle(0, 0, 100, 100));
// Red ellipse at relative position, this will scroll and zoom with the view
var gstate = graphics.Save();
var transform = _imageViewer.ViewTransform;
using (var matrix = new System.Drawing.Drawing2D.Matrix(
(float)transform.M11, (float)transform.M12, (float)transform.M21, (float)transform.M22,
(float)transform.OffsetX, (float)transform.OffsetY))
graphics.MultiplyTransform(matrix);
graphics.FillEllipse(Brushes.Red, new Rectangle(0, 0, 100, 100));
graphics.Restore(gstate);
};
// Render on each item
_imageViewer.PostRenderItem += (sender, e) =>
{
var item = e.Item;
var graphics = e.PaintEventArgs.Graphics;
var gstate = graphics.Save();
// Get the bounding rectangle for the image
var bounds = LeadRectD.Create(0, 0, item.Image.ImageWidth, item.Image.ImageHeight);
// Add the image transform to the graphics
var transform = _imageViewer.GetItemImageTransform(item);
using (var matrix = new System.Drawing.Drawing2D.Matrix(
(float)transform.M11, (float)transform.M12, (float)transform.M21, (float)transform.M22,
(float)transform.OffsetX, (float)transform.OffsetY))
graphics.MultiplyTransform(matrix);
// Red hilight on top of each item image
using (var brush = new SolidBrush(Color.FromArgb(128, Color.Red)))
graphics.FillRectangle(brush, (float)bounds.X, (float)bounds.Y, (float)bounds.Width, (float)bounds.Height);
graphics.Restore(gstate);
};
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images";
}
Parameter | Type | Description |
---|---|---|
sender | object | The source of the event. |
e | ImageViewerRenderEventArgs | The event data. |
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