Gets or sets a value to determine how to center the image in the control's client area horizontally, when the width of the destination rectangle is smaller than the width of the client area.
public virtual RasterPaintAlignMode HorizontalAlignMode { get; set; }
public:
virtual property RasterPaintAlignMode HorizontalAlignMode {
RasterPaintAlignMode get();
void set ( RasterPaintAlignMode );
}
public:
virtual property RasterPaintAlignMode^ HorizontalAlignMode
{
RasterPaintAlignMode^ get()
void set(RasterPaintAlignMode^ value)
}
An Leadtools.RasterPaintAlignMode enumeration value that determine how to center the image in the control's client area horizontally, when the width of the destination rectangle is smaller than the width of the client area.
For example, this can be used to center a small image when it is displayed in a control that is larger than the image's dimensions (Leadtools.RasterImage.Width x Leadtools.RasterImage.Height).
This can also be used in conjunction with the VerticalAlignMode property, SizeMode property and the ScaleFactor property to center an image when the zoomed display dimensions are smaller than the control's dimensions.
Note that RasterPaintAlignMode.CenterAlways is not currently supported for this control.
using Leadtools.WinForms;
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing.Color;
using Leadtools.Drawing;
public void RasterImageViewer_RasterImageViewer()
{
MyForm1 form = new MyForm1();
form.ShowDialog();
}
class MyForm1 : Form
{
RasterImageViewer theViewer;
public MyForm1()
{
// Create the raster viewer
theViewer = new RasterImageViewer();
theViewer.Dock = DockStyle.Fill;
theViewer.DoubleBuffer = true;
theViewer.BorderStyle = BorderStyle.Fixed3D;
theViewer.AutoResetScaleFactor = true;
theViewer.AutoResetScrollPosition = true;
theViewer.HorizontalAlignMode = RasterPaintAlignMode.Center;
theViewer.VerticalAlignMode = RasterPaintAlignMode.Far;
theViewer.FrameSize = new SizeF(10, 5);
theViewer.FrameColor = Color.Red;
theViewer.FramesIsPartOfImage = true;
theViewer.FrameShadowSize = new SizeF(5, 5);
theViewer.FrameShadowColor = Color.Blue;
theViewer.AutoScroll = true;
theViewer.UseDpi = true;
// Set the paint properties
RasterPaintProperties p = new RasterPaintProperties();
p.PaintDisplayMode = RasterPaintDisplayModeFlags.Bicubic;
p.PaintEngine = RasterPaintEngine.GdiPlus;
p.UsePaintPalette = true;
theViewer.PaintProperties = p;
theViewer.AnimateRegion = true;
theViewer.EnableTimer = true;
theViewer.EnableScrollingInterface = true;
Controls.Add(theViewer);
theViewer.BringToFront();
// load an image into the viewer
RasterCodecs codecs = new RasterCodecs();
theViewer.Image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Sample1.cmp"));
codecs.Dispose();
Text = string.Format("Size mode = {0}, double click to change", theViewer.SizeMode);
theViewer.DoubleClick += new EventHandler(theViewer_DoubleClick);
}
void theViewer_DoubleClick(object sender, EventArgs e)
{
switch (theViewer.SizeMode)
{
case RasterPaintSizeMode.Normal:
theViewer.SizeMode = RasterPaintSizeMode.Stretch;
break;
case RasterPaintSizeMode.Stretch:
theViewer.SizeMode = RasterPaintSizeMode.Fit;
break;
case RasterPaintSizeMode.Fit:
theViewer.SizeMode = RasterPaintSizeMode.FitAlways;
break;
case RasterPaintSizeMode.FitAlways:
theViewer.SizeMode = RasterPaintSizeMode.FitWidth;
break;
case RasterPaintSizeMode.FitWidth:
theViewer.SizeMode = RasterPaintSizeMode.Normal;
break;
}
Text = string.Format("Size mode = {0}, double click to change", theViewer.SizeMode);
base.OnDoubleClick(e);
}
}
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