VintaSoft Imaging .NET SDK 14.1: Документация для .NET разработчика
Vintasoft.Imaging.ImageProcessing.Transforms Namespace / ImageTransformationBasedCommand Class
Члены типа Объект Синтаксис Example Иерархия Требования Смотрите также
    Класс ImageTransformationBasedCommand
    Предоставляет абстрактный базовый класс для команды обработки изображения, которая преобразует изображение.
    Объектная модель
    ColorBase RegionOfInterest ProcessingCommandResults ImageTransformationBasedCommand
    Синтаксис
    'Declaration
    
    Public MustInherit Class ImageTransformationBasedCommand
       Inherits Vintasoft.Imaging.ImageProcessing.ProcessingCommandWithRegion
    
    
     
    Пример

    Вот C#/VB.NET код, который демонстрирует, как создать пользовательскую команду на основе преобразования изображений:

    ''' <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();
        }
    
    }
    
    

    Иерархия наследования
    Требования

    Целевые платформы: .NET 9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    Смотрите также