←Select platform

GetPaintPalette Method

Summary
Returns a GDI+ palette corresponding to this Leadtools.RasterImage if painted on the given graphic object.
Syntax
C#
C++/CLI
Python
public static ColorPalette GetPaintPalette( 
   RasterImage image, 
   Graphics graphics 
) 
public: 
static ColorPalette^ GetPaintPalette(  
   RasterImage^ image, 
   Graphics^ graphics 
)  
def GetPaintPalette(self,image,graphics): 

Parameters

image
The source image.

graphics
The graphics object on which this Leadtools.RasterImage is painted.

Return Value

a GDI+ palette

Remarks

For more information refer to RasterImage and GDI/GDI+ and Handling Palette Changes.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Drawing; 
using Leadtools.ImageProcessing; 
 
 
public void GetPaintPaletteExample() 
{ 
   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)) 
      { 
         ColorPalette palette = RasterImagePainter.GetPaintPalette(image, g); 
         if (palette != null) 
         { 
            Console.WriteLine("Paint palette colors:"); 
            for (int i = 0; i < palette.Entries.Length; i++) 
            { 
               Console.WriteLine("{0} - {1}", i, palette.Entries[i]); 
            } 
         } 
         else 
         { 
            Console.WriteLine("There is no palette"); 
         } 
      } 
   } 
 
   image.Dispose(); 
   codecs.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Drawing Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.