LEADTOOLS WCF Image Processing (Leadtools.Services.ImageProcessing.ServiceContracts assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.30
ColorResolution Method
See Also 
Leadtools.Services.ImageProcessing.ServiceContracts Namespace > IColorProcessingService Interface : ColorResolution Method



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

The ColorResolution Method is available in LEADTOOLS Document and Medical Imaging toolkits.

request
A System.Runtime.Serialization.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="", 
   ProtectionLevel=ProtectionLevel.None, 
   HasProtectionLevel=False)>
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="", 
   ProtectionLevel=ProtectionLevel.None, 
   HasProtectionLevel=false)]
CommandResponse ColorResolution( 
   ColorResolutionRequest request
)
C++/CLI 
[OperationContractAttribute("ColorResolution")]
[FaultContractAttribute(DetailType=Leadtools.Services.Raster.FaultContracts.RasterFault, 
   Action="", 
   Name="", 
   Namespace="", 
   ProtectionLevel=ProtectionLevel.None, 
   HasProtectionLevel=false)]
CommandResponse^ ColorResolution( 
   ColorResolutionRequest^ request
) 

Parameters

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

Return Value

A System.Runtime.Serialization.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(Path.Combine(LEAD_VARS.ImagesDir, "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(Path.Combine(LEAD_VARS.ImagesDir, "ColorResolution.bmp"), (TryCast(response.Destination, RawBinaryData)).Data)
         End If
      End If

      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 ColorResolutionExample()
   {
      ColorProcessingServiceClient client = new ColorProcessingServiceClient();
      RawBinaryData sourceBinaryData = new RawBinaryData();
      sourceBinaryData.Data = File.ReadAllBytes(Path.Combine(LEAD_VARS.ImagesDir,"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(Path.Combine(LEAD_VARS.ImagesDir,"ColorResolution.bmp"), (response.Destination as RawBinaryData).Data);
      }

      client.Close();
   }

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

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 Leadtools.Services.ImageProcessing.DataContracts.ColorResolutionRequest.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 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7

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