LEADTOOLS WCF (Leadtools.Services.Raster.ServiceContracts assembly)
LEAD Technologies, Inc

Convert(String,String,String,RasterImageFormat,Int32,Int32,Int32,String,Int32) Method

Example 





The uri of image.
The username who has privilages on the the specified uri. Must be passes as (domain/username).
The password for the specified user.
The output image format.
Value that indicates the number of bits for the destination image.
The new image width in pixels.
The new image height in pixels.
A color value to determine how to fill the background color if the image dimensions are smaller than width and height. Can be HTML named colors or hexadecimal color values.
The QualityFactor to be used when converting the image, refer to Save.
Converts an image to any image file format supported by LEADTOOLS.
Syntax
[OperationContractAttribute(Name="ConvertImage", Action="ConvertImage")]
[FaultContractAttribute(DetailType=Leadtools.Services.Raster.FaultContracts.RasterFault, 
   Action="", 
   Name="", 
   Namespace="", 
   ProtectionLevel=ProtectionLevel.None, 
   HasProtectionLevel=false)]
[WebGetAttribute()]
Stream Convert( 
   string uri,
   string username,
   string password,
   RasterImageFormat format,
   int bitsPerPixel,
   int width,
   int height,
   string backColor,
   int qualityFactor
)
'Declaration
 
<OperationContractAttribute(Name="ConvertImage", Action="ConvertImage")>
<FaultContractAttribute(DetailType=Leadtools.Services.Raster.FaultContracts.RasterFault, 
   Action="", 
   Name="", 
   Namespace="", 
   ProtectionLevel=ProtectionLevel.None, 
   HasProtectionLevel=False)>
<WebGetAttribute()>
Overloads Function Convert( _
   ByVal uri As String, _
   ByVal username As String, _
   ByVal password As String, _
   ByVal format As RasterImageFormat, _
   ByVal bitsPerPixel As Integer, _
   ByVal width As Integer, _
   ByVal height As Integer, _
   ByVal backColor As String, _
   ByVal qualityFactor As Integer _
) As Stream
'Usage
 
Dim instance As IRasterService
Dim uri As String
Dim username As String
Dim password As String
Dim format As RasterImageFormat
Dim bitsPerPixel As Integer
Dim width As Integer
Dim height As Integer
Dim backColor As String
Dim qualityFactor As Integer
Dim value As Stream
 
value = instance.Convert(uri, username, password, format, bitsPerPixel, width, height, backColor, qualityFactor)
[OperationContractAttribute(Name="ConvertImage", Action="ConvertImage")]
[FaultContractAttribute(DetailType=Leadtools.Services.Raster.FaultContracts.RasterFault, 
   Action="", 
   Name="", 
   Namespace="", 
   ProtectionLevel=ProtectionLevel.None, 
   HasProtectionLevel=false)]
[WebGetAttribute()]
Stream Convert( 
   string uri,
   string username,
   string password,
   RasterImageFormat format,
   int bitsPerPixel,
   int width,
   int height,
   string backColor,
   int qualityFactor
)
OperationContractAttribute(Name="ConvertImage", Action="ConvertImage")
FaultContractAttribute(DetailType=Leadtools.Services.Raster.FaultContracts.RasterFault, 
   Action="", 
   Name="", 
   Namespace="", 
   ProtectionLevel=ProtectionLevel.None, 
   HasProtectionLevel=)
WebGetAttribute()
function Leadtools.Services.Raster.ServiceContracts.IRasterService.Convert(String,String,String,RasterImageFormat,Int32,Int32,Int32,String,Int32)( 
   uri ,
   username ,
   password ,
   format ,
   bitsPerPixel ,
   width ,
   height ,
   backColor ,
   qualityFactor 
)
[OperationContractAttribute(Name="ConvertImage", Action="ConvertImage")]
[FaultContractAttribute(DetailType=Leadtools.Services.Raster.FaultContracts.RasterFault, 
   Action="", 
   Name="", 
   Namespace="", 
   ProtectionLevel=ProtectionLevel.None, 
   HasProtectionLevel=false)]
[WebGetAttribute()]
Stream^ Convert( 
   String^ uri,
   String^ username,
   String^ password,
   RasterImageFormat format,
   int bitsPerPixel,
   int width,
   int height,
   String^ backColor,
   int qualityFactor
) 

Parameters

uri
The uri of image.
username
The username who has privilages on the the specified uri. Must be passes as (domain/username).
password
The password for the specified user.
format
The output image format.
bitsPerPixel
Value that indicates the number of bits for the destination image.
width
The new image width in pixels.
height
The new image height in pixels.
backColor
A color value to determine how to fill the background color if the image dimensions are smaller than width and height. Can be HTML named colors or hexadecimal color values.
qualityFactor
The QualityFactor to be used when converting the image, refer to Save.

Return Value

A Stream that contains the document data.
Example
 
Public Sub ConvertImageExample()
      Dim buffer As Byte() = New Byte(1024 * 64 - 1) {}
      Dim totalBytesRead As Integer = 0
      Dim memoryStream As MemoryStream = New MemoryStream()
      Dim client As RasterServiceClient = New RasterServiceClient()

      Dim stream As Stream = client.ConvertImage("http://sp2007ep/Ocr/Shared%20Documents/OCR.TIF", "username", "password", RasterImageFormat.Bmp, 24, 200, 200, "White", 0)

      Dim bytesRead As Integer
      'TODO: INSTANT VB TODO TASK: Assignments within expressions are not supported in VB.NET
      'ORIGINAL LINE: while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) > 0)
      Do While (bytesRead = stream.Read(buffer, 0, buffer.Length)) > 0
         totalBytesRead += bytesRead
         memoryStream.Write(buffer, 0, bytesRead)
      Loop

      File.WriteAllBytes(Path.Combine(LEAD_VARS.ImagesDir, "convertimage.bmp"), memoryStream.ToArray())

      client.Close()
   End Sub

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
public void ConvertImageExample()
   {
      byte[] buffer = new byte[1024 * 64];
      int totalBytesRead = 0;
      MemoryStream memoryStream = new MemoryStream();
      RasterServiceClient client = new RasterServiceClient();

      Stream stream = client.ConvertImage(@"http://sp2007ep/Ocr/Shared%20Documents/OCR.TIF", "username", "password", RasterImageFormat.Bmp, 24, 200, 200, "White", 0);

      int bytesRead;
      while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) > 0)
      {
         totalBytesRead += bytesRead;
         memoryStream.Write(buffer, 0, bytesRead);
      }

      File.WriteAllBytes(Path.Combine(LEAD_VARS.ImagesDir,"convertimage.bmp"), memoryStream.ToArray());

      client.Close();
   }

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

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

IRasterService Interface
IRasterService Members
Overload List

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 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: LEADTOOLS Toolkit Features