Leadtools Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
ChangeViewPerspectiveCommand Class
See Also  Members   Example 
Leadtools.ImageProcessing Namespace : ChangeViewPerspectiveCommand Class



Rotates and flips the image data as necessary to achieve the desired view perspective.

Object Model


Syntax

Visual Basic (Declaration) 
Public Class ChangeViewPerspectiveCommand 
   Inherits RasterCommand
   Implements IRasterCommand 
Visual Basic (Usage)Copy Code
Dim instance As ChangeViewPerspectiveCommand
C# 
public class ChangeViewPerspectiveCommand : RasterCommand, IRasterCommand  
C++/CLI 
public ref class ChangeViewPerspectiveCommand : public RasterCommand, IRasterCommand  

Example

This example will load an image and then change its view perspective.

Visual BasicCopy Code
Public Sub ChangeViewPerspectiveCommandExample()
 RasterCodecs.Startup()
 Dim codecs As RasterCodecs = New RasterCodecs()

 Dim srcFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "Image1.cmp"

 ' Load the source image from disk
 Dim image As RasterImage = codecs.Load(srcFileName)

 ' Check the view perspective
 Console.WriteLine("Original view perspective = {0}", image.ViewPerspective)

 ' If the view perspective is TopLeft, change to BottomLeft and vise versa
 Dim viewPerspective As RasterViewPerspective = image.ViewPerspective
 If viewPerspective = RasterViewPerspective.TopLeft Then
    viewPerspective = RasterViewPerspective.BottomLeft
 Else
    viewPerspective = RasterViewPerspective.TopLeft
 End If

 ' Change the image view perspective
 Dim command As ChangeViewPerspectiveCommand = New ChangeViewPerspectiveCommand()
 command.ViewPerspective = viewPerspective
 command.InPlace = True

 command.Run(image)

 ' Re-check the view perspective
 Console.WriteLine("New view perspective = {0}", image.ViewPerspective)
 Debug.Assert(image.ViewPerspective = viewPerspective)

 ' Clean up
 image.Dispose()
 RasterCodecs.Shutdown()
      End Sub
C#Copy Code
public void ChangeViewPerspectiveCommandExample() 

   RasterCodecs.Startup(); 
   RasterCodecs codecs = new RasterCodecs(); 
 
   string srcFileName = LeadtoolsExamples.Common.ImagesPath.Path + "Image1.cmp"; 
 
   // Load the source image from disk 
   RasterImage image = codecs.Load(srcFileName); 
 
   // Check the view perspective 
   Console.WriteLine("Original view perspective = {0}", image.ViewPerspective); 
 
   // If the view perspective is TopLeft, change to BottomLeft and vise versa 
   RasterViewPerspective viewPerspective = image.ViewPerspective; 
   if(viewPerspective == RasterViewPerspective.TopLeft) 
      viewPerspective = RasterViewPerspective.BottomLeft; 
   else 
      viewPerspective = RasterViewPerspective.TopLeft; 
 
   // Change the image view perspective 
   ChangeViewPerspectiveCommand command = new ChangeViewPerspectiveCommand(); 
   command.ViewPerspective = viewPerspective; 
   command.InPlace = true; 
 
   command.Run(image); 
 
   // Re-check the view perspective 
   Console.WriteLine("New view perspective = {0}", image.ViewPerspective); 
   Debug.Assert(image.ViewPerspective == viewPerspective); 
 
   // Clean up 
   image.Dispose(); 
   RasterCodecs.Shutdown(); 
}

Remarks

The ViewPerspective is the arrangement of pixels in the image. This command references image coordinates, which are often different from the display coordinates of an image.

Use this command to change the data and the ViewPerspective to simplify calculations that involve image coordinates. This method does not affect the image display. For more information, refer to Accounting for View Perspective.

Inheritance Hierarchy

System.Object
   Leadtools.ImageProcessing.RasterCommand
      Leadtools.ImageProcessing.ChangeViewPerspectiveCommand

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also