LEADTOOLS WCF Image Processing (Leadtools.Services.ImageProcessing.ServiceContracts assembly)

HighQualityRotate Method

Show in webframe
Example 





A System.Runtime.Serialization.DataContractAttribute containing the data that will be used in this HighQualityRotate operation.
Perform high quality rotation on a black and white image.
Syntax
[FaultContractAttribute(DetailType=Leadtools.Services.Raster.FaultContracts.RasterFault, 
   Action="", 
   Name="", 
   Namespace="", 
   ProtectionLevel=ProtectionLevel.None, 
   HasProtectionLevel=false)]
[OperationContractAttribute("HighQualityRotate")]
CommandResponse HighQualityRotate( 
   HighQualityRotateRequest request
)
'Declaration
 
<FaultContractAttribute(DetailType=Leadtools.Services.Raster.FaultContracts.RasterFault, 
   Action="", 
   Name="", 
   Namespace="", 
   ProtectionLevel=ProtectionLevel.None, 
   HasProtectionLevel=False)>
<OperationContractAttribute("HighQualityRotate")>
Function HighQualityRotate( _
   ByVal request As HighQualityRotateRequest _
) As CommandResponse
'Usage
 
Dim instance As IDocumentProcessingService
Dim request As HighQualityRotateRequest
Dim value As CommandResponse
 
value = instance.HighQualityRotate(request)

            

            
[FaultContractAttribute(DetailType=Leadtools.Services.Raster.FaultContracts.RasterFault, 
   Action="", 
   Name="", 
   Namespace="", 
   ProtectionLevel=ProtectionLevel.None, 
   HasProtectionLevel=false)]
[OperationContractAttribute("HighQualityRotate")]
CommandResponse^ HighQualityRotate( 
   HighQualityRotateRequest^ request
) 

Parameters

request
A System.Runtime.Serialization.DataContractAttribute containing the data that will be used in this HighQualityRotate operation.

Return Value

A System.Runtime.Serialization.DataContractAttribute containing the modified image resulting from the HighQualityRotate operation.
Remarks

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

Normal rotation operations such as IImageProcessingService.Rotate 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 operation will temporarily convert the image to 8 bits/pixel internally, perform the rotation and then convert the image back to 1 bits/pixel.

This operation only works with a 1 bits/pixel images, using this operation on any other image type will result in an exception.

This operation does not support signed data images.

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

Example
Copy Code  
Imports Leadtools.Services
Imports leadtools.services.datacontracts._2009._01
Imports leadtools.services.raster.datacontracts._2009._01
Imports leadtools.services.imageprocessing.datacontracts._2009._01

Public Sub HighQualityRotateExample()
   ' 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 String = "White"


   Dim sourceBinaryData As RawBinaryData = New RawBinaryData()
   sourceBinaryData.Data = File.ReadAllBytes(tifFileName)

   Dim convertOptions As RasterConvertOptions = New RasterConvertOptions()

   convertOptions.Source = sourceBinaryData
   convertOptions.Destination = Nothing
   convertOptions.Format = RasterImageFormat.Tif
   convertOptions.FirstPage = 1
   convertOptions.LastPage = 1
   convertOptions.BitsPerPixel = 1
   convertOptions.QualityFactor = 2

   ' Load the image, rotate normally by 30 degrees and save
   Dim client As ImageProcessingServiceClient = New ImageProcessingServiceClient()

   Dim request As RotateRequest = New RotateRequest()

   request.ConvertOptions = convertOptions
   request.RegionData = Nothing
   request.Angle = angle
   request.Flags = RotateCommandFlags.Resize Or RotateCommandFlags.Bicubic
   request.FillColor = fillColor

   Dim response As CommandResponse = client.Rotate(request)
   If Not response.Destination Is Nothing Then
      If TypeOf response.Destination Is RawBinaryData Then
         File.WriteAllBytes(LeadtoolsExamples.Common.ImagesPath.Path & normalRotateFileName, (TryCast(response.Destination, RawBinaryData)).Data)
      End If
   End If

   client.Close()

   ' Load the image, rotate with high quality by 30 degrees and save
   Dim documentClient As DocumentProcessingServiceClient = New DocumentProcessingServiceClient()

   Dim documentRequest As HighQualityRotateRequest = New HighQualityRotateRequest()

   documentRequest.ConvertOptions = convertOptions
   documentRequest.RegionData = Nothing
   documentRequest.Angle = angle
   documentRequest.Flags = HighQualityRotateFlags.Resize Or HighQualityRotateFlags.BestQuality
   documentRequest.FillColor = fillColor

   response = documentClient.HighQualityRotate(documentRequest)
   If Not response.Destination Is Nothing Then
      If TypeOf response.Destination Is RawBinaryData Then
         File.WriteAllBytes(LeadtoolsExamples.Common.ImagesPath.Path & highQualityRotateFileName, (TryCast(response.Destination, RawBinaryData)).Data)
      End If
   End If

   documentClient.Close()

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

Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools.Services;
using leadtools.services.datacontracts._2009._01;
using leadtools.services.raster.datacontracts._2009._01;
using leadtools.services.imageprocessing.datacontracts._2009._01;

public void HighQualityRotateExample()
{
   // 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;
   string fillColor = "White";


   RawBinaryData sourceBinaryData = new RawBinaryData();
   sourceBinaryData.Data = File.ReadAllBytes(tifFileName);

   RasterConvertOptions convertOptions = new RasterConvertOptions();

   convertOptions.Source = sourceBinaryData;
   convertOptions.Destination = null;
   convertOptions.Format = RasterImageFormat.Tif;
   convertOptions.FirstPage = 1;
   convertOptions.LastPage = 1;
   convertOptions.BitsPerPixel = 1;
   convertOptions.QualityFactor = 2;

   // Load the image, rotate normally by 30 degrees and save
   {
      ImageProcessingServiceClient client = new ImageProcessingServiceClient();

      RotateRequest request = new RotateRequest();

      request.ConvertOptions = convertOptions;
      request.RegionData = null;
      request.Angle = angle;
      request.Flags = RotateCommandFlags.Resize | RotateCommandFlags.Bicubic;
      request.FillColor = fillColor;

      CommandResponse response = client.Rotate(request);
      if (response.Destination != null)
      {
         if (response.Destination is RawBinaryData)
            File.WriteAllBytes(LeadtoolsExamples.Common.ImagesPath.Path + normalRotateFileName, (response.Destination as RawBinaryData).Data);
      }

      client.Close();
   }

   // Load the image, rotate with high quality by 30 degrees and save
   {
      DocumentProcessingServiceClient client = new DocumentProcessingServiceClient();

      HighQualityRotateRequest request = new HighQualityRotateRequest();

      request.ConvertOptions = convertOptions;
      request.RegionData = null;
      request.Angle = angle;
      request.Flags = HighQualityRotateCommandFlags.Resize | HighQualityRotateCommandFlags.BestQuality;
      request.FillColor = fillColor;

      CommandResponse response = client.HighQualityRotate(request);
      if (response.Destination != null)
      {
         if (response.Destination is RawBinaryData)
            File.WriteAllBytes(LeadtoolsExamples.Common.ImagesPath.Path + highQualityRotateFileName, (response.Destination as RawBinaryData).Data);
      }

      client.Close();
   }

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

static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
Requirements

Target Platforms

See Also

Reference

IDocumentProcessingService Interface
IDocumentProcessingService Members
Cleaning Up 1-Bit Images
Smooth Method
BorderRemove Method
LineRemove Method
InvertedText Method
InvertedPage Method
DotRemove Method
HolePunchRemove Method
HighQualityRotate Method
Minimum Method
Maximum Method

 

 


Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.

Applications developed with LEADTOOLS WCF components require runtime licenses. Server licensing is required for applications on a server. For more information, refer to: Imaging Pro/Document/Medical