←Select platform

Transform Property


Transformation of the item.

public LeadMatrix Transform { get; set; } 
   property LeadMatrix^ Transform 
      LeadMatrix^ get() 
      void set(LeadMatrix^ value) 

Property Value

The transformation of the item. Default value is Identity.


Transform will be used by ViewLayout during the calculation. The rectangle from 0,0 to ImageSize is multiplied by this value apply custom translation, scale and rotation on the item.

Modifying the state values will update this matrix automatically and setting the value of Transform manually will reset the state values to their default values. For more information, for more information, refer Image Viewer Transformation.

For more information, refer Image Viewer Items.

using Leadtools; 
using Leadtools.Controls; 
using Leadtools.Codecs; 
using Leadtools.Drawing; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
public ImageViewerForm _form = new ImageViewerForm(); 
public ImageViewer _imageViewer; 
public void ImageViewerItemTransformExample() 
   // Get the Form's ImageViewer control 
   _imageViewer = _form.ImageViewer; 
   // Load an image 
   using (var codecs = new RasterCodecs()) 
      _imageViewer.Image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp")); 
   int dy = 1; 
   LeadPoint position = LeadPoint.Create(0, 0); 
   double total = _imageViewer.GetItemViewBounds(_imageViewer.ActiveItem, ImageViewerItemPart.Item, false).Height; 
   double factor; 
   LeadPointD[] points = new LeadPointD[2]; 
   points[0] = LeadPointD.Create(position.X, position.Y); 
   points[1] = LeadPointD.Create(position.X * .5, position.Y * .5); 
   LeadRect rect = new LeadRect(position.X, position.Y, _imageViewer.Height, _imageViewer.Width); 
   if (total > 0) 
      factor = 1.0 - (dy * 2.0) / total; 
      factor = 1.0; 
   // Get the origin in image coordinate 
   var origin = _imageViewer.ConvertPoint(_imageViewer.ActiveItem, ImageViewerCoordinateType.Control, ImageViewerCoordinateType.Image, position).ToLeadPointD(); 
   // Convert it to whatever the current transform is 
   origin = _imageViewer.ActiveItem.Transform.Transform(origin); 
   Debug.WriteLine(origin.X.ToString() + " " + origin.Y.ToString()); 
   _imageViewer.ConvertPoints(_imageViewer.ActiveItem, ImageViewerCoordinateType.Control, ImageViewerCoordinateType.Image, points); 
   _imageViewer.ConvertRect(_imageViewer.ActiveItem, ImageViewerCoordinateType.Control, ImageViewerCoordinateType.Image, rect); 
   var transform = LeadMatrix.Identity; 
   transform.ScaleAt(1 / factor, 1 / factor, origin.X, origin.Y); 
   _imageViewer.ActiveItem.Transform = LeadMatrix.Multiply(_imageViewer.ActiveItem.Transform, transform); 
static class LEAD_VARS 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Controls Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.