Translates the specified color in the image, and returns the nearest matching color in the destination image.
public int TranslateColor(RasterImage destImage,int rgb)
Public Overloads Function TranslateColor( _ByVal destImage As Leadtools.RasterImage, _ByVal rgb As Integer _) As Integer
public int TranslateColor(Leadtools.RasterImage destImage,int rgb)
- (unsigned int)translateColorRgb:(LTRasterImage *)dstImagergb:(unsigned int)rgb
function Leadtools.RasterImage.TranslateColor(RasterImage,Int32)(destImage ,rgb)
public:int TranslateColor(Leadtools.RasterImage^ destImage,int rgb)
destImage
Destination RasterImage object.
rgb
Value that specifies the color in the image to be translated.
The color value or the palette index of the nearest matching color in the destination image. If the destination image is 8 bits per pixel or less, this is always the palette index. Otherwise, it is the color value.
When creating a target image for animation, you can use this method to ensure that the correct color is specified as the background color.
The reverse of this method (to get a true RGB color value from a palette index color), use GetTrueColorValue.
using Leadtools;using Leadtools.Codecs;using Leadtools.ImageProcessing;using Leadtools.ImageProcessing.Core;using Leadtools.ImageProcessing.Color;using Leadtools.Dicom;using Leadtools.Drawing;using Leadtools.Controls;using LeadtoolsExamples.Common;using Leadtools.Svg;public void TranslateColorExample(){RasterCodecs codecs = new RasterCodecs();// load an 8 bpp image and a 24 bpp imageRasterImage myImage1 = codecs.Load(Path.Combine(ImagesPath.Path, "Ulay1.bmp"));RasterImage myImage2 = codecs.Load(Path.Combine(ImagesPath.Path, "Sample1.cmp"));// translate the top-left pixel of the 24 bpp image to a palette index in the firstint win32Color = ColorTranslator.ToWin32(RasterColorConverter.ToColor(myImage2.GetPixelColor(0, 0)));int index = myImage2.TranslateColor(myImage1, win32Color) & 0x0EFFFFFF;Console.WriteLine(string.Format("Palette index: {0}", index));myImage2.Dispose();myImage1.Dispose();codecs.Dispose();}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessingImports Leadtools.ImageProcessing.CoreImports Leadtools.ImageProcessing.ColorImports Leadtools.ControlsImports Leadtools.DicomImports Leadtools.DrawingImports Leadtools.SvgPublic Sub TranslateColorExample()Dim codecs As RasterCodecs = New RasterCodecs()' load an 8 bpp image and a 24 bpp imageDim myImage1 As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Ulay1.bmp"))Dim myImage2 As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Sample1.cmp"))' translate the top-left pixel of the 24 bpp image to a palette index in the firstDim win32Color As Integer = ColorTranslator.ToWin32(RasterColorConverter.ToColor(myImage2.GetPixelColor(0, 0)))Dim index As Integer = myImage2.TranslateColor(myImage1, win32Color) And &HEFFFFFFConsole.WriteLine(String.Format("Palette index: {0}", index))myImage2.Dispose()myImage1.Dispose()codecs.Dispose()End SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
