Converts image data from a RasterImage based on its ICC profile. The output will be in the same RasterImage.
public void ConvertImage(
RasterImage image
)
public:
static void ConvertImage(
RasterImage^ image
)
def ConvertImage(self,image):
image
A RasterImage object holding the input data and ICC profile. This image will also hold the output data.
There are other conversion methods available in the LEADTOOLS Color Conversion toolkit, however, to get optimal conversion results use ConvertImage(RasterImage,RasterImage) or ConvertImage(RasterImage,RasterImage) as they rely on the embedded ICC profile of the source RasterImage. Here is a scenario where these two methods are invaluable:
image should be allocated and be 24-bits per pixel.
The conversion engine should have already been started by calling Start. The input and output formats for the conversion engine should be BGR/RGB for predictable results. Other types of conversion (LAB, CMYK, etc.) might have undesired results.
You can perform the output into another RasterImage using ConvertImage(RasterImage,RasterImage).
This example loads a source file containing an embedded ICC profile. The image data will be converted using the ConvertImage(RasterImage) method.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ColorConversion;
using Leadtools.ImageProcessing;
public string outputFile = Path.Combine(LEAD_VARS.ImagesDir, "ColorConversion", "ConvertImage.png");
public void ConvertImageExample()
{
// StartUp the ColorConversion.
RasterColorConverterEngine.Startup();
// Input file name
string inputFileName = Path.Combine(LEAD_VARS.ImagesDir, "ColorConversion", "11800-Embedded_RGB.png");
// Load the original image
using (RasterCodecs codecs = new RasterCodecs())
using (RasterImage image = codecs.Load(inputFileName, 24, CodecsLoadByteOrder.Bgr, 1, 1))
{
// Set the active method
ConversionParameters conversionParameters = new ConversionParameters();
conversionParameters.Method = ConversionMethodFlags.UseCustomIcc;
conversionParameters.ActiveMethod = ConversionMethodFlags.UseCustomIcc;
// Read the embedded profile from image on disk
bool hasProfile = IccProfileExtended.ImageHasIccProfile(inputFileName, 1);
Debug.WriteLine("Profile present:\t" + hasProfile);
IccProfileExtended icc = new IccProfileExtended();
icc.ReadFromImage(inputFileName, 1);
// Use the image profile as the input profile
conversionParameters.InputProfileData = icc.Data;
// Convert the image
using (RasterColorConverterEngine colorConverterEngine = new RasterColorConverterEngine())
{
colorConverterEngine.Start(ConversionColorFormat.Bgr, ConversionColorFormat.Bgr, conversionParameters);
colorConverterEngine.ConvertImage(image);
colorConverterEngine.Stop();
}
// Save output image
codecs.Save(image, outputFile, image.OriginalFormat, image.BitsPerPixel);
// Shutdown the ColorConversion
RasterColorConverterEngine.Shutdown();
}
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";
}
ConvertImage(RasterImage,RasterImage)
RasterColorConverterEngine Class
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document