VintaSoft Imaging .NET SDK 14.0: Documentation for .NET developer
Vintasoft.Imaging.ImageProcessing.Transforms Namespace / ImageTransformationBasedCommand Class
Members Object Syntax Example Hierarchy Requirements SeeAlso
In This Topic
    ImageTransformationBasedCommand Class
    In This Topic
    Provides the abstract base class for the image processing command that transforms an image.
    Object Model
    ColorBase RegionOfInterest ProcessingCommandResults ImageTransformationBasedCommand
    Syntax
    'Declaration
    
    Public MustInherit Class ImageTransformationBasedCommand
       Inherits Vintasoft.Imaging.ImageProcessing.ProcessingCommandWithRegion
    
    
    public abstract class ImageTransformationBasedCommand : Vintasoft.Imaging.ImageProcessing.ProcessingCommandWithRegion
    
    
    public __gc abstract class ImageTransformationBasedCommand : public Vintasoft.Imaging.ImageProcessing.ProcessingCommandWithRegion*
    
    
    public ref class ImageTransformationBasedCommand abstract : public Vintasoft.Imaging.ImageProcessing.ProcessingCommandWithRegion^
    
    
    Example

    This C#/VB.NET code shows how to create custom image transformation based command:

    
    ''' <summary>
    ''' Rotates an image by 90 degrees clockwise.
    ''' </summary>
    Public Class ImageOrthogonalClockwiseRotationCommand
        Inherits Vintasoft.Imaging.ImageProcessing.Transforms.ImageTransformationBasedCommand
    
        ''' <summary>
        ''' Initializes a new instance of the <see cref="ImageOrthogonalClockwiseRotationCommand"/> class.
        ''' </summary>
        Public Sub New()
            MyBase.New()
        End Sub
    
    
    
        ''' <summary>
        ''' Gets the name of the command.
        ''' </summary>
        Public Overrides ReadOnly Property Name() As String
            Get
                Return "Rotate image orthogonal clockwise."
            End Get
        End Property
    
    
    
        ''' <summary>
        ''' Creates a new <see cref="ImageOrthogonalClockwiseRotationCommand"/> that is a copy of the current instance.
        ''' </summary>
        ''' <returns>A new <see cref="ImageOrthogonalClockwiseRotationCommand"/> that is a copy of this instance.</returns>
        Public Overrides Function Clone() As Object
            Dim command As New ImageOrthogonalClockwiseRotationCommand()
            CopyTo(command)
            Return command
        End Function
    
    
        ''' <summary>
        ''' Creates the point transformation that is used for transforming points from
        ''' the destination image space to the source image space.
        ''' </summary>
        ''' <param name="sourceImageSize">Size of source image.</param>
        ''' <returns>The point transformation that is used for transforming points from
        ''' the destination image space to the source image space.</returns>
        Protected Overrides Function CreateTransform(sourceImageSize As Vintasoft.Imaging.VintasoftIntSize) As Vintasoft.Imaging.VintasoftPointTransform
            ' create transform, that defines image transformation
            Return New ClockwiseOrthogonalRotationTransform(sourceImageSize)
        End Function
    
        ''' <summary>
        ''' Returns size of result image.
        ''' </summary>
        ''' <param name="sourceImageSize">Size of source image.</param>
        ''' <returns>Size of result image.</returns>
        Protected Overrides Function GetResultImageSize(sourceImageSize As Vintasoft.Imaging.VintasoftIntSize) As Vintasoft.Imaging.VintasoftIntSize
            ' calculate transformed image size
            ' for this example it is just image width and heigth swap
            Return New Vintasoft.Imaging.VintasoftIntSize(sourceImageSize.Height, sourceImageSize.Width)
        End Function
    
    End Class
    
    ''' <summary>
    ''' Rotates the point, which is represented by <see cref="Vintasoft.Imaging.VintasoftPoint"/>
    ''' structure, by 90 degrees clockwise.
    ''' </summary>
    ''' <remarks>
    ''' For this example we need only one transform method, so other methods are not implemented.
    ''' </remarks>
    Public Class ClockwiseOrthogonalRotationTransform
        Inherits Vintasoft.Imaging.VintasoftPointTransform
    
        ''' <summary>
        ''' Coordinate system size.
        ''' </summary>
        Private _size As Vintasoft.Imaging.VintasoftIntSize
    
    
    
        ''' <summary>
        ''' Initializes a new instance of the <see cref="ClockwiseOrthogonalRotationTransform"/> class.
        ''' </summary>
        ''' <param name="size">Coordinate system size.</param>
        Public Sub New(size As Vintasoft.Imaging.VintasoftIntSize)
            _size = size
        End Sub
    
    
    
        ''' <summary>
        ''' Gets a value indicating whether this transform is invertible.
        ''' </summary>
        ''' <value>
        ''' <b>true</b> if this transform is invertible; otherwise, <b>false</b>.
        ''' </value>
        ''' <remarks>
        ''' Implementations of the <see cref="GetInverseTransform" /> method should throw an exception
        ''' if this transform is not invertible.
        ''' </remarks>
        ''' <seealso cref="GetInverseTransform" />
        Public Overrides ReadOnly Property IsInvertible() As Boolean
            Get
                Return False
            End Get
        End Property
    
    
    
        ''' <summary>
        ''' Returns the inverse transform.
        ''' </summary>
        Public Overrides Function GetInverseTransform() As Vintasoft.Imaging.VintasoftPointTransform
            Throw New System.NotImplementedException()
        End Function
    
        ''' <summary>
        ''' Transforms the specified point coordinates by this <see cref="Vintasoft.Imaging.VintasoftPointTransform"/>.
        ''' </summary>
        ''' <param name="x">The X coordinate to transform.</param>
        ''' <param name="y">The Y coordinate to transform.</param>
        Public Overrides Sub TransformPoint(ByRef x As Double, ByRef y As Double)
            Dim oldX As Double = x
            x = y
            y = _size.Height - oldX
        End Sub
    
        ''' <summary>
        ''' Transforms the specified point by this <see cref="Vintasoft.Imaging.VintasoftPointScaleTransform"/> and
        ''' returns the result.
        ''' </summary>
        ''' <param name="point">The point to transform.</param>
        ''' <returns>
        ''' The result of transforming <i>point</i> by this <see cref="Vintasoft.Imaging.PointFScaleTransform"/>.
        ''' </returns>
        Public Overrides Function TransformPoint(point As Vintasoft.Imaging.VintasoftPoint) As Vintasoft.Imaging.VintasoftPoint
            Throw New System.NotImplementedException()
        End Function
    
        ''' <summary>
        ''' Transforms the specified points by this <see cref="Vintasoft.Imaging.VintasoftPointScaleTransform"/>.
        ''' </summary>
        ''' <param name="points">The <i>points</i> to transform.
        ''' The original points in the array are replaced by their transformed values.</param>
        Public Overrides Sub TransformPoints(points As Vintasoft.Imaging.VintasoftPoint())
            Throw New System.NotImplementedException()
        End Sub
    
        ''' <summary>
        ''' Transforms the specified vector coordinates by this <see cref="Vintasoft.Imaging.VintasoftPointTransform"/>.
        ''' </summary>
        ''' <param name="x">The X coordinate to transform.</param>
        ''' <param name="y">The Y coordinate to transform.</param>
        Public Overrides Sub TransformVector(ByRef x As Double, ByRef y As Double)
            Throw New System.NotImplementedException()
        End Sub
    
        ''' <summary>
        ''' Transforms the specified vector by this <see cref="Vintasoft.Imaging.VintasoftPointScaleTransform"/>.
        ''' </summary>
        ''' <param name="vector">The vector to transform.</param>
        ''' <returns>
        ''' The result of transforming <i>vector</i> by this <see cref="Vintasoft.Imaging.VintasoftPointScaleTransform"/>.
        ''' </returns>
        Public Overrides Function TransformVector(vector As Vintasoft.Imaging.VintasoftPoint) As Vintasoft.Imaging.VintasoftPoint
            Throw New System.NotImplementedException()
        End Function
    
        ''' <summary>
        ''' Transforms the specified vectors by this <see cref="Vintasoft.Imaging.VintasoftPointScaleTransform"/>.
        ''' </summary>
        ''' <param name="vectors">The <i>vectors</i> to transform.
        ''' The original vectors in the array are replaced by their transformed values.</param>
        Public Overrides Sub TransformVectors(vectors As Vintasoft.Imaging.VintasoftPoint())
            Throw New System.NotImplementedException()
        End Sub
    
    End Class
    
    
    
    /// <summary>
    /// Rotates an image by 90 degrees clockwise.
    /// </summary>
    public class ImageOrthogonalClockwiseRotationCommand : 
        Vintasoft.Imaging.ImageProcessing.Transforms.ImageTransformationBasedCommand
    {
    
        /// <summary>
        /// Initializes a new instance of the <see cref="ImageOrthogonalClockwiseRotationCommand"/> class.
        /// </summary>
        public ImageOrthogonalClockwiseRotationCommand()
            : base()
        {
        }
        
        
        
        /// <summary>
         /// Gets the name of the command.
         /// </summary>
        public override string Name
        {
            get
            {
                return "Rotate image orthogonal clockwise.";
            }
        }
    
    
    
        /// <summary>
        /// Creates a new <see cref="ImageOrthogonalClockwiseRotationCommand"/> that is a copy of the current instance.
        /// </summary>
        /// <returns>A new <see cref="ImageOrthogonalClockwiseRotationCommand"/> that is a copy of this instance.</returns>
        public override object Clone()
        {
            ImageOrthogonalClockwiseRotationCommand command = new ImageOrthogonalClockwiseRotationCommand();
            CopyTo(command);
            return command;
        }
    
    
        /// <summary>
        /// Creates the point transformation that is used for transforming points from
        /// the destination image space to the source image space.
        /// </summary>
        /// <param name="sourceImageSize">Size of source image.</param>
        /// <returns>The point transformation that is used for transforming points from
        /// the destination image space to the source image space.</returns>
        protected override Vintasoft.Imaging.VintasoftPointTransform CreateTransform(Vintasoft.Imaging.VintasoftIntSize sourceImageSize)
        {
            // create transform, that defines image transformation
            return new ClockwiseOrthogonalRotationTransform(sourceImageSize);
        }
    
        /// <summary>
        /// Returns size of result image.
        /// </summary>
        /// <param name="sourceImageSize">Size of source image.</param>
        /// <returns>Size of result image.</returns>
        protected override Vintasoft.Imaging.VintasoftIntSize GetResultImageSize(Vintasoft.Imaging.VintasoftIntSize sourceImageSize)
        {
            // calculate transformed image size
            // for this example it is just image width and heigth swap
            return new Vintasoft.Imaging.VintasoftIntSize(sourceImageSize.Height, sourceImageSize.Width);
        }
    
    }
    
    /// <summary>
    /// Rotates the point, which is represented by <see cref="Vintasoft.Imaging.VintasoftPoint"/>
    /// structure, by 90 degrees clockwise.
    /// </summary>
    /// <remarks>
    /// For this example we need only one transform method, so other methods are not implemented.
    /// </remarks>
    public class ClockwiseOrthogonalRotationTransform : Vintasoft.Imaging.VintasoftPointTransform
    {
    
        /// <summary>
        /// Coordinate system size.
        /// </summary>
        Vintasoft.Imaging.VintasoftIntSize _size;
    
    
    
        /// <summary>
        /// Initializes a new instance of the <see cref="ClockwiseOrthogonalRotationTransform"/> class.
        /// </summary>
        /// <param name="size">Coordinate system size.</param>
        public ClockwiseOrthogonalRotationTransform(Vintasoft.Imaging.VintasoftIntSize size)
        {
            _size = size;
        }
    
    
    
        /// <summary>
        /// Gets a value indicating whether this transform is invertible.
        /// </summary>
        /// <value>
        /// <b>true</b> if this transform is invertible; otherwise, <b>false</b>.
        /// </value>
        /// <remarks>
        /// Implementations of the <see cref="GetInverseTransform" /> method should throw an exception
        /// if this transform is not invertible.
        /// </remarks>
        /// <seealso cref="GetInverseTransform" />
        public override bool IsInvertible
        {
            get
            {
                return false;
            }
        }
    
    
    
        /// <summary>
        /// Returns the inverse transform.
        /// </summary>
        public override Vintasoft.Imaging.VintasoftPointTransform GetInverseTransform()
        {
            throw new System.NotImplementedException();
        }
    
        /// <summary>
        /// Transforms the specified point coordinates by this <see cref="Vintasoft.Imaging.VintasoftPointTransform"/>.
        /// </summary>
        /// <param name="x">The X coordinate to transform.</param>
        /// <param name="y">The Y coordinate to transform.</param>
        public override void TransformPoint(ref double x, ref double y)
        {
            double oldX = x;
            x = y;
            y = _size.Height - oldX;
        }
    
        /// <summary>
        /// Transforms the specified point by this <see cref="Vintasoft.Imaging.VintasoftPointScaleTransform"/> and
        /// returns the result.
        /// </summary>
        /// <param name="point">The point to transform.</param>
        /// <returns>
        /// The result of transforming <i>point</i> by this <see cref="Vintasoft.Imaging.PointFScaleTransform"/>.
        /// </returns>
        public override Vintasoft.Imaging.VintasoftPoint TransformPoint(Vintasoft.Imaging.VintasoftPoint point)
        {
            throw new System.NotImplementedException();
        }
    
        /// <summary>
        /// Transforms the specified points by this <see cref="Vintasoft.Imaging.VintasoftPointScaleTransform"/>.
        /// </summary>
        /// <param name="points">The <i>points</i> to transform.
        /// The original points in the array are replaced by their transformed values.</param>
        public override void TransformPoints(Vintasoft.Imaging.VintasoftPoint[] points)
        {
            throw new System.NotImplementedException();
        }
    
        /// <summary>
        /// Transforms the specified vector coordinates by this <see cref="Vintasoft.Imaging.VintasoftPointTransform"/>.
        /// </summary>
        /// <param name="x">The X coordinate to transform.</param>
        /// <param name="y">The Y coordinate to transform.</param>
        public override void TransformVector(ref double x, ref double y)
        {
            throw new System.NotImplementedException();
        }
    
        /// <summary>
        /// Transforms the specified vector by this <see cref="Vintasoft.Imaging.VintasoftPointScaleTransform"/>.
        /// </summary>
        /// <param name="vector">The vector to transform.</param>
        /// <returns>
        /// The result of transforming <i>vector</i> by this <see cref="Vintasoft.Imaging.VintasoftPointScaleTransform"/>.
        /// </returns>
        public override Vintasoft.Imaging.VintasoftPoint TransformVector(Vintasoft.Imaging.VintasoftPoint vector)
        {
            throw new System.NotImplementedException();
        }
    
        /// <summary>
        /// Transforms the specified vectors by this <see cref="Vintasoft.Imaging.VintasoftPointScaleTransform"/>.
        /// </summary>
        /// <param name="vectors">The <i>vectors</i> to transform.
        /// The original vectors in the array are replaced by their transformed values.</param>
        public override void TransformVectors(Vintasoft.Imaging.VintasoftPoint[] vectors)
        {
            throw new System.NotImplementedException();
        }
    
    }
    
    

    Inheritance Hierarchy
    Requirements

    Target Platforms: .NET9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also