←Select platform

ColorResolution Method

Summary

Converts an image from any bits-per-pixel to any bits-per-pixel.

Syntax

C#
VB
C++
[FaultContractAttribute(System.Type)] 
[OperationContractAttribute(Action="ColorResolution", 
   AsyncPattern=false, 
   IsOneWay=false, 
   IsInitiating=true, 
   IsTerminating=false)] 
public CommandResponse ColorResolution( 
   ColorResolutionRequest request 
) 
  
<OperationContractAttribute("ColorResolution")> 
<FaultContractAttribute(DetailType=Leadtools.Services.Raster.FaultContracts.RasterFault,  
   Action="",  
   Name="",  
   Namespace="",  
   ProtectionLevel=ProtectionLevel.None,  
   HasProtectionLevel=False)> 
Function ColorResolution( _ 
   ByVal request As Leadtools.Services.Imageprocessing.Datacontracts.ColorResolutionRequest _ 
) As Leadtools.Services.Imageprocessing.Datacontracts.CommandResponse 
[OperationContractAttribute("ColorResolution")] 
[FaultContractAttribute(DetailType=Leadtools.Services.Raster.FaultContracts.RasterFault,  
   Action="",  
   Name="",  
   Namespace="",  
   ProtectionLevel=ProtectionLevel.None,  
   HasProtectionLevel=false)] 
Leadtools.Services.Imageprocessing.Datacontracts.CommandResponse^ ColorResolution(  
   Leadtools.Services.Imageprocessing.Datacontracts.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.

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.

Example

C#
VB
using Leadtools.Services; 
 
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"; 
} 
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 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 

Requirements

Target Platforms

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.