Visual Basic (Declaration) | |
---|---|
Public Class HighQualityRotateCommand Inherits Leadtools.ImageProcessing.RasterCommand Implements IRasterCommand |
Visual Basic (Usage) | Copy Code |
---|---|
Dim instance As HighQualityRotateCommand |
C# | |
---|---|
public class HighQualityRotateCommand : Leadtools.ImageProcessing.RasterCommand, IRasterCommand |
C++/CLI | |
---|---|
public ref class HighQualityRotateCommand : public Leadtools.ImageProcessing.RasterCommand, IRasterCommand |
This example will show the difference between normal rotation (Leadtools.ImageProcessing.RotateCommand) and high quality rotation (HighQualityRotateCommand) when performed on a 1 bits/pixel image.
Visual Basic | Copy Code |
---|---|
Public Sub HighQualityRotateCommandExample() Dim codecs As New RasterCodecs() ' Get an image Dim tifFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "ocr1.tif") Dim normalRotateFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "ocr1_NormalRotated.tif") Dim highQualityRotateFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "ocr1_HighQualityRotated.tif") Dim angle As Integer = 30 * 100 Dim fillColor As RasterColor = RasterColor.FromKnownColor(RasterKnownColor.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() End Sub Public NotInheritable Class LEAD_VARS Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" End Class |
C# | Copy Code |
---|---|
public void HighQualityRotateCommandExample() { RasterCodecs codecs = new RasterCodecs(); // Get an image string tifFileName = Path.Combine(LEAD_VARS.ImagesDir, "ocr1.tif"); string normalRotateFileName = Path.Combine(LEAD_VARS.ImagesDir, "ocr1_NormalRotated.tif"); string highQualityRotateFileName = Path.Combine(LEAD_VARS.ImagesDir, "ocr1_HighQualityRotated.tif"); int angle = 30 * 100; RasterColor fillColor = RasterColor.FromKnownColor(RasterKnownColor.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(); } static class LEAD_VARS { public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; } |
SilverlightCSharp | Copy Code |
---|---|
public void HighQualityRotateCommandExample(RasterImage image1, Stream outStream1, Stream outStream2) { RasterImage image2 = image1.Clone(); RasterCodecs codecs = new RasterCodecs(); int angle = 30 * 100; RasterColor fillColor = new RasterColor(255, 255, 255); // rotate normally by 30 degrees and save RotateCommand cmd1 = new RotateCommand(); cmd1.Angle = angle; cmd1.Flags = RotateCommandFlags.Resize | RotateCommandFlags.Bicubic; cmd1.FillColor = fillColor; cmd1.Run(image1); // save result image to "ocr1_NormalRotated.tif" codecs.Save(image1, outStream1, image1.OriginalFormat, image1.BitsPerPixel); // rotate with high quality by 30 degrees and save HighQualityRotateCommand cmd2 = new HighQualityRotateCommand(); cmd2.Angle = angle; cmd2.Flags = HighQualityRotateCommandFlags.Resize | HighQualityRotateCommandFlags.BestQuality; cmd2.FillColor = fillColor; cmd2.Run(image2); // save result image to "ocr1_HighQualityRotated.tif" codecs.Save(image2, outStream2, image2.OriginalFormat, image2.BitsPerPixel); // Now compare the saved TIF files and notice the difference in quality between // the normal rotate and high quality image1.Dispose(); image2.Dispose(); } |
SilverlightVB | Copy Code |
---|---|
Public Sub HighQualityRotateCommandExample(ByVal image1 As RasterImage, ByVal outStream1 As Stream, ByVal outStream2 As Stream) Dim image2 As RasterImage = image1.Clone() Dim codecs As RasterCodecs = New RasterCodecs() Dim angle As Integer = 30 * 100 Dim fillColor As RasterColor = New RasterColor(255, 255, 255) ' rotate normally by 30 degrees and save Dim cmd1 As RotateCommand = New RotateCommand() cmd1.Angle = angle cmd1.Flags = RotateCommandFlags.Resize Or RotateCommandFlags.Bicubic cmd1.FillColor = fillColor cmd1.Run(image1) ' save result image to "ocr1_NormalRotated.tif" codecs.Save(image1, outStream1, image1.OriginalFormat, image1.BitsPerPixel) ' rotate with high quality by 30 degrees and save Dim cmd2 As HighQualityRotateCommand = New HighQualityRotateCommand() cmd2.Angle = angle cmd2.Flags = HighQualityRotateCommandFlags.Resize Or HighQualityRotateCommandFlags.BestQuality cmd2.FillColor = fillColor cmd2.Run(image2) ' save result image to "ocr1_HighQualityRotated.tif" codecs.Save(image2, outStream2, image2.OriginalFormat, image2.BitsPerPixel) ' Now compare the saved TIF files and notice the difference in quality between ' the normal rotate and high quality image1.Dispose() image2.Dispose() End Sub |
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 Leadtools.ImageProcessing.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 Leadtools.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.
System.Object
Leadtools.ImageProcessing.RasterCommand
Leadtools.ImageProcessing.Core.HighQualityRotateCommand
Target Platforms: Silverlight 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7, MAC OS/X (Intel Only)
Reference
HighQualityRotateCommand MembersLeadtools.ImageProcessing.Core Namespace
Cleaning Up 1-Bit Images
SmoothCommand Class
BorderRemoveCommand Class
LineRemoveCommand Class
InvertedTextCommand Class
InvertedPageCommand Class
DotRemoveCommand Class
HolePunchRemoveCommand Class
HighQualityRotateCommand Class
MinimumCommand Class
MaximumCommand Class
Leadtools.ImageProcessing.Effects.RegionHolesRemovalCommand