Sets the palette of this RasterImage object that will be used by 1-8 bit color or grayscale image.
public void SetPalette(Leadtools.RasterColor[] palette,int startIndex,int count)
Public Sub SetPalette( _ByVal palette() As Leadtools.RasterColor, _ByVal startIndex As Integer, _ByVal count As Integer _)
public void SetPalette(Leadtools.RasterColor[] palette,int startIndex,int count)
- (BOOL)setPalette:(nullable NSArray<LTRasterColor *> *)palette range:(NSRange)range error:(NSError **)error public void setPalette(RasterColor[] palette, int startIndex, int count) function Leadtools.RasterImage.SetPalette(palette ,startIndex ,count)
public:void SetPalette(Leadtools.array<RasterColor>^ palette,int startIndex,int count)
palette
An array of RasterColor containing the new palette to use.
startIndex
Index of the first palette entry to replace.
count
Number of palette entries to replace.
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 LeadtoolsExamples.Common;using Leadtools.Svg;public void PaletteExample(){RasterCodecs codecs = new RasterCodecs();string srcFileName = Path.Combine(ImagesPath.Path, "Image1.cmp");string destFileName = Path.Combine(ImagesPath.Path, "Image1_RedPalette.bmp");// Load the image as 8 bits/pixelRasterImage image = codecs.Load(srcFileName, 8, CodecsLoadByteOrder.Rgb, 1, 1);// Get the palette of this image and change it to shades of redRasterColor[] 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 fileimage.SetPalette(palette, 0, palette.Length);codecs.Save(image, destFileName, RasterImageFormat.Bmp, image.BitsPerPixel);image.Dispose();codecs.Dispose();}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessingImports Leadtools.ImageProcessing.CoreImports Leadtools.ImageProcessing.ColorImports Leadtools.ControlsImports Leadtools.DicomImports Leadtools.DrawingImports Leadtools.SvgPublic Sub PaletteExample()Dim codecs As RasterCodecs = New RasterCodecs()Dim srcFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp")Dim destFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1_RedPalette.bmp")' Load the image as 8 bits/pixelDim image As RasterImage = codecs.Load(srcFileName, 8, CodecsLoadByteOrder.Rgb, 1, 1)' Get the palette of this image and change it to shades of redDim palette As RasterColor() = image.GetPalette()Dim i As Integer = 0Do While i < palette.Lengthpalette(i) = New RasterColor(i, 0, 0)i += 1Loop' Set the palette back in the image then save the fileimage.SetPalette(palette, 0, palette.Length)codecs.Save(image, destFileName, RasterImageFormat.Bmp, image.BitsPerPixel)image.Dispose()codecs.Dispose()End SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
using Leadtools;using Leadtools.Codecs;using Leadtools.Dicom;using Leadtools.ImageProcessing;using Leadtools.ImageProcessing.Core;using Leadtools.ImageProcessing.Color;using Leadtools.Examples;using Leadtools.Windows.Media;public void PaletteExample(RasterImage image, Stream destStream){// image should be loaded as 8 bits/pixel// Get the palette of this image and change it to shades of redRasterColor[] 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 fileimage.SetPalette(palette, 0, palette.Length);RasterCodecs codecs = new RasterCodecs();codecs.Save(image, destStream, RasterImageFormat.Bmp, 0);image.Dispose();}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.DicomImports Leadtools.ImageProcessingImports Leadtools.ImageProcessing.CoreImports Leadtools.ImageProcessing.ColorImports Leadtools.Windows.MediaPublic Sub PaletteExample(ByVal image As RasterImage, ByVal destStream As Stream)' image should be loaded as 8 bits/pixel' Get the palette of this image and change it to shades of redDim palette As RasterColor() = image.GetPalette()Dim i As Integer = 0Do While i < palette.Lengthpalette(i) = New RasterColor(i, 0, 0)i += 1Loop' Set the palette back in the image then save the fileimage.SetPalette(palette, 0, palette.Length)Dim codecs As RasterCodecs = New RasterCodecs()codecs.Save(image, destStream, RasterImageFormat.Bmp, 0)image.Dispose()End Sub
|
Products |
Support |
Feedback: SetPalette Method (RasterImage) - Leadtools |
Introduction |
Help Version 19.0.2017.6.19
|

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
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.