Gets the display matrix for the viewer.
public Matrix Transform { get; }
[BrowsableAttribute(false)]
public:
property Matrix^ Transform {
Matrix^ get();
}
public:
property Matrix^ Transform
{
Matrix^ get()
}
The display matrix for the viewer.
Use the Transform property to get the current matrix which is used to transform the image display. The matrix is used to transform from physical to logical coordinates and vice versa.
using Leadtools.WinForms;
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing.Color;
using Leadtools.Drawing;
///
// center the loaded image in the middle of rasterImageViewer if the image smaller than the viewer size
private void centerImage(RasterImageViewer viewer)
{
// do center only when RasterViewerSizeMode == Normal
if (viewer.SizeMode == RasterPaintSizeMode.Normal)
{
if (viewer.IsImageAvailable == true)
{
if (viewer.Image != null)
{
int viewerWidth = viewer.Right - viewer.Left;
int viewerHeight = viewer.Bottom - viewer.Top;
int imageWidth = (int)(viewer.LogicalViewRectangle.Width * viewer.ScaleFactor);
int imageHeight = (int)(viewer.LogicalViewRectangle.Height * viewer.ScaleFactor);
if (imageWidth < viewerWidth)
viewer.BorderPadding.Left = (viewerWidth - imageWidth) / 2;
else
viewer.BorderPadding.Left = 0;
if (imageHeight < viewerHeight)
viewer.BorderPadding.Top = (viewerHeight - imageHeight) / 2;
else
viewer.BorderPadding.Top = 0;
}
}
}
}
private void viewer_TransformedChanged(object sender, EventArgs e)
{
RasterImageViewer viewer = sender as RasterImageViewer;
string s = string.Format("Transform: {0} {1} {2} {3} {4} {5}",
viewer.Transform.Elements[0],
viewer.Transform.Elements[1],
viewer.Transform.Elements[2],
viewer.Transform.Elements[3],
viewer.Transform.Elements[4],
viewer.Transform.Elements[5]);
Console.WriteLine(s);
}
public void RasterImageViewer_BeginUpdate(RasterImageViewer viewer)
{
viewer.TransformChanged += new EventHandler(viewer_TransformedChanged);
viewer.BeginUpdate(); // suspend painting of the image
viewer.ScaleFactor = viewer.ScaleFactor * 0.9F;
centerImage(viewer);
viewer.EndUpdate(); // start painting of the image
viewer.TransformChanged -= new EventHandler(viewer_TransformedChanged);
}
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