Leadtools.Services.ImageProcessing.ServiceContracts Requires Document/Medical product license | Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
ColorResolution Method
See Also  Example
Leadtools.Services.ImageProcessing.ServiceContracts Namespace > IColorProcessingService Interface : ColorResolution Method



request
A DataContractAttribute containing the data that will be used in this ColorResolution operation.
request
A DataContractAttribute containing the data that will be used in this ColorResolution operation.
Converts an image from any bits-per-pixel to any bits-per-pixel.

Syntax

Visual Basic (Declaration) 
<OperationContractAttribute("ColorResolution")>
<FaultContractAttribute(DetailType=Leadtools.Services.Raster.FaultContracts.RasterFault, 
   Action="", 
   Name="", 
   Namespace="", 
   HasProtectionLevel=False)>
Overridable Function ColorResolution( _
   ByVal request As ColorResolutionRequest _
) As CommandResponse
Visual Basic (Usage)Copy Code
Dim instance As IColorProcessingService
Dim request As ColorResolutionRequest
Dim value As CommandResponse
 
value = instance.ColorResolution(request)
C# 
[OperationContractAttribute("ColorResolution")]
[FaultContractAttribute(DetailType=Leadtools.Services.Raster.FaultContracts.RasterFault, 
   Action="", 
   Name="", 
   Namespace="", 
   HasProtectionLevel=false)]
virtual CommandResponse ColorResolution( 
   ColorResolutionRequest request
)
C++/CLI 
[OperationContractAttribute("ColorResolution")]
[FaultContractAttribute(DetailType=Leadtools.Services.Raster.FaultContracts.RasterFault, 
   Action="", 
   Name="", 
   Namespace="", 
   HasProtectionLevel=false)]
virtual CommandResponse ColorResolution( 
   ColorResolutionRequest request
) 

Parameters

request
A DataContractAttribute containing the data that will be used in this ColorResolution operation.

Return Value

A DataContractAttribute containing the modified image resulting from the ColorResolution operation.

Example

Visual BasicCopy Code
Public Sub ColorResolutionExample()
  Dim client As ColorProcessingServiceClient = New ColorProcessingServiceClient()
  Dim sourceBinaryData As RawBinaryData = New RawBinaryData()
  sourceBinaryData.Data = File.ReadAllBytes(LeadtoolsExamples.Common.ImagesPath.Path & "image1.cmp")

  Dim convertOptions As RasterConvertOptions = New RasterConvertOptions()

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

  Dim request As ColorResolutionRequest = New ColorResolutionRequest()

  request.ConvertOptions = convertOptions
  request.RegionData = Nothing
  request.BitsPerPixel = 4
  request.DitheringMethod = RasterDitheringMethod.None
  request.Order = RasterByteOrder.Rgb
  request.PaletteFlags = ColorResolutionCommandPaletteFlags.Optimized

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

  client.Close()
End Sub
C#Copy Code
public void ColorResolutionExample() 

   ColorProcessingServiceClient client = new ColorProcessingServiceClient(); 
   RawBinaryData sourceBinaryData = new RawBinaryData(); 
   sourceBinaryData.Data = File.ReadAllBytes(LeadtoolsExamples.Common.ImagesPath.Path + "image1.cmp"); 
 
   RasterConvertOptions convertOptions = new RasterConvertOptions(); 
 
   convertOptions.Source = sourceBinaryData; 
   convertOptions.Destination = null; 
   convertOptions.Format = RasterImageFormat.Bmp; 
   convertOptions.FirstPage = 1; 
   convertOptions.LastPage = 1; 
   convertOptions.BitsPerPixel = 24; 
   convertOptions.QualityFactor = 2; 
 
   ColorResolutionRequest request = new ColorResolutionRequest(); 
 
   request.ConvertOptions = convertOptions; 
   request.RegionData = null; 
   request.BitsPerPixel = 4; 
   request.DitheringMethod = RasterDitheringMethod.None; 
   request.Order = RasterByteOrder.Rgb; 
   request.PaletteFlags = ColorResolutionCommandPaletteFlags.Optimized; 
 
   CommandResponse response = client.ColorResolution(request); 
   if (response.Destination != null) 
   { 
      if (response.Destination is RawBinaryData) 
         File.WriteAllBytes(LeadtoolsExamples.Common.ImagesPath.Path + "ColorResolution.bmp", (response.Destination as RawBinaryData).Data); 
   } 
 
   client.Close(); 
}

Remarks

This operation provides flexibility in specifying the output destination and in specifying the palette to use.

For general information about dithering, refer to Color Resolution and Dithering and Dithering Methods.

You can convert the image in place or create a new converted image.

In specifying a palette, you can use simple palette options, or you can specify a palette that is tailored to your needs. The tailored palette can be any size that you specify. It can include specific colors, reserved blank entries, and open entries that this method fills with optimized colors.

NOTE: Using this operation to change the color order of a 24-bit or 32-bit image (i.e. RGB to BGR) will have no effect on the image when painting or saving (to a file). If you want to change the visual appearance, you can simply swap the color order using the Order property.

This operation does not support signed data images. An exception will be thrown if a signed data image is passed to this operation.

For more information, refer to Introduction - Palette Handling.

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also

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 Features