public static RasterColor[] GetPaintColors(
RasterImage image,
Graphics graphics
)
image
The source image.
graphics
The graphics object on which this image is painted.
An array of color for the palette
For more information refer to RasterImage and GDI/GDI+ and Color Halftone and Halftone Images.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Drawing;
using Leadtools.ImageProcessing;
public void GetPaintColorsExample()
{
RasterCodecs codecs = new RasterCodecs();
RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"), 8, CodecsLoadByteOrder.Rgb, 1, 1);
using (Bitmap btmp = new Bitmap(1, 1))
{
using (Graphics g = Graphics.FromImage(btmp))
{
RasterColor[] colors = RasterImagePainter.GetPaintColors(image, g);
if (colors != null)
{
Console.WriteLine("Paint colors:");
for (int i = 0; i < colors.Length; i++)
{
Console.WriteLine("{0} - {1}", i, colors[i]);
}
}
else
{
Console.WriteLine("There is no palette");
}
}
}
image.Dispose();
codecs.Dispose();
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";
}