The Convert(String,String,String,RasterImageFormat,Int32,Int32,Int32,String,Int32) Method is available in LEADTOOLS Document and Medical Imaging toolkits.
Converts an image to any image file format supported by LEADTOOLS.
Syntax
Visual Basic (Declaration) | |
---|
<FaultContractAttribute(DetailType=Leadtools.Services.Raster.FaultContracts.RasterFault,
Action="",
Name="",
Namespace="",
ProtectionLevel=ProtectionLevel.None,
HasProtectionLevel=False)>
<WebGetAttribute()>
<OperationContractAttribute(Name="ConvertImage", Action="ConvertImage")>
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 |
C# | |
---|
[FaultContractAttribute(DetailType=Leadtools.Services.Raster.FaultContracts.RasterFault,
Action="",
Name="",
Namespace="",
ProtectionLevel=ProtectionLevel.None,
HasProtectionLevel=false)]
[WebGetAttribute()]
[OperationContractAttribute(Name="ConvertImage", Action="ConvertImage")]
Stream Convert(
string uri,
string username,
string password,
RasterImageFormat format,
int bitsPerPixel,
int width,
int height,
string backColor,
int qualityFactor
) |
C++/CLI | |
---|
[FaultContractAttribute(DetailType=Leadtools.Services.Raster.FaultContracts.RasterFault,
Action="",
Name="",
Namespace="",
ProtectionLevel=ProtectionLevel.None,
HasProtectionLevel=false)]
[WebGetAttribute()]
[OperationContractAttribute(Name="ConvertImage", Action="ConvertImage")]
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
This example will convert TIF file on sharepoint to BMP and save it on disk.
Visual Basic | Copy Code |
---|
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 |
C# | Copy Code |
---|
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: Microsoft .NET Framework 3.0, Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7
See Also