public RasterColor[] GetPalette()
@property (nonatomic, strong, readonly, nullable) NSArray<LTRasterColor *> *palette
public RasterColor[] getPalette();
public void setPalette(
RasterColor[] rasterColor[,
int intValue,
int intValue2
);
public:
array<RasterColor>^ GetPalette();
def GetPalette(self):
The palette is used for 1-8 bit color or grayscale image rendering. Image is grayscale when red, green and blue (R=G=B) components for each palette entry has the same value.
The image data of a RasterImage object with BitsPerPixel values of 1, 2, 3, 4, 5, 6, 7 or 8 consists of an index into the image palette. You can get a copy of the palette used by using the GetPalette method.
You can change the palette used by the RasterImage object with the SetPalette method.
This method does not support signed images.
For more information, refer to RasterPalette and Introduction: Palette Handling.
For information on 10 to 16-bit grayscale image, refer to the Grayscale Images.
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 Leadtools.Svg;
public void PaletteExample()
{
RasterCodecs codecs = new RasterCodecs();
string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp");
string destFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1_RedPalette.bmp");
// Load the image as 8 bits/pixel
RasterImage image = codecs.Load(srcFileName, 8, CodecsLoadByteOrder.Rgb, 1, 1);
// Get the palette of this image and change it to shades of red
RasterColor[] palette = image.GetPalette();
for (int i = 0; i < palette.Length; i++)
palette[i] = new RasterColor(i, 0, 0);
// Set the palette back in the image then save the file
image.SetPalette(palette, 0, palette.Length);
codecs.Save(image, destFileName, RasterImageFormat.Bmp, image.BitsPerPixel);
image.Dispose();
codecs.Dispose();
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images";
}
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
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.