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



Perform high quality rotation on a black and white image.

Syntax

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

Example

This example will show the difference between normal rotation (RotateCommand) and high quality rotation (HighQualityRotateCommand) when performed on a 1 bits/pixel image.

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

   ' Get an image
   Dim tifFileName As String = "C:\Users\Public\Documents\LEADTOOLS Images\ocr1.tif"
   Dim normalRotateFileName As String = "C:\Users\Public\Documents\LEADTOOLS Images\ocr1_NormalRotated.tif"
   Dim highQualityRotateFileName As String = "C:\Users\Public\Documents\LEADTOOLS Images\ocr1_HighQualityRotated.tif"

   Dim angle As Integer = 30 * 100
   Dim fillColor As RasterColor = RasterColor.FromGdiPlusColor(Color.White)

   ' Load the image, rotate normally by 30 degrees and save
   Using image As RasterImage = codecs.Load(tifFileName)
      Dim cmd As New RotateCommand()
      cmd.Angle = angle
      cmd.Flags = RotateCommandFlags.Resize Or RotateCommandFlags.Bicubic
      cmd.FillColor = fillColor
      cmd.Run(image)
      codecs.Save(image, normalRotateFileName, image.OriginalFormat, image.BitsPerPixel)
   End Using

   ' Load the image, rotate with high quality by 30 degrees and save
   Using image As RasterImage = codecs.Load(tifFileName)
      Dim cmd As New HighQualityRotateCommand()
      cmd.Angle = angle
      cmd.Flags = HighQualityRotateCommandFlags.Resize Or HighQualityRotateCommandFlags.BestQuality
      cmd.FillColor = fillColor
      cmd.Run(image)
      codecs.Save(image, highQualityRotateFileName, image.OriginalFormat, image.BitsPerPixel)
   End Using

   ' Now compare the saved TIF files and notice the difference in quality between
   ' the normal rotate and high quality

   codecs.Dispose()
   RasterCodecs.Shutdown()
End Sub
C#Copy Code
public void HighQualityRotateCommandExample() 

   RasterCodecs.Startup(); 
   RasterCodecs codecs = new RasterCodecs(); 
 
   // Get an image 
   string tifFileName = @"C:\Users\Public\Documents\LEADTOOLS Images\ocr1.tif"; 
   string normalRotateFileName = @"C:\Users\Public\Documents\LEADTOOLS Images\ocr1_NormalRotated.tif"; 
   string highQualityRotateFileName = @"C:\Users\Public\Documents\LEADTOOLS Images\ocr1_HighQualityRotated.tif"; 
 
   int angle = 30 * 100; 
   RasterColor fillColor = RasterColor.FromGdiPlusColor(Color.White); 
 
   // Load the image, rotate normally by 30 degrees and save 
   using(RasterImage image = codecs.Load(tifFileName)) 
   { 
      RotateCommand cmd = new RotateCommand(); 
      cmd.Angle = angle; 
      cmd.Flags = RotateCommandFlags.Resize | RotateCommandFlags.Bicubic; 
      cmd.FillColor = fillColor; 
      cmd.Run(image); 
      codecs.Save(image, normalRotateFileName, image.OriginalFormat, image.BitsPerPixel); 
   } 
 
 
   // Load the image, rotate with high quality by 30 degrees and save 
   using(RasterImage image = codecs.Load(tifFileName)) 
   { 
      HighQualityRotateCommand cmd = new HighQualityRotateCommand(); 
      cmd.Angle = angle; 
      cmd.Flags = HighQualityRotateCommandFlags.Resize | HighQualityRotateCommandFlags.BestQuality; 
      cmd.FillColor = fillColor; 
      cmd.Run(image); 
      codecs.Save(image, highQualityRotateFileName, image.OriginalFormat, image.BitsPerPixel); 
   } 
 
   // Now compare the saved TIF files and notice the difference in quality between 
   // the normal rotate and high quality 
 
   codecs.Dispose(); 
   RasterCodecs.Shutdown(); 
}

Remarks

The HighQualityRotateCommand can be used to perform high quality rotation on a black and white (1 bits/pixel) images in any angle.

Normal rotation commands such as RotateCommand will rotate the image data as is, which may result in less than desired quality due to the limited number of bits/pixel of the image (1 bit). This command will temporarily convert the image to 8 bits/pixel internally, perform the rotation and then convert the image back to 1 bits/pixel.

This command only works with a 1 bits/pixel images (a RasterImage with RasterImage.BitsPerPixel equals to 1). Using this command on any other image type will result in an exception.

This command does not support signed data images.

For more information, refer to Cleaning Up 1-Bit Images.

Inheritance Hierarchy

System.Object
   Leadtools.ImageProcessing.RasterCommand
      Leadtools.ImageProcessing.Core.HighQualityRotateCommand

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also