LEADTOOLS GDI/GDI+ (Leadtools.Drawing assembly)
LEAD Technologies, Inc

GetPaintPalette Method

Example 





The source image.
The graphics object on which this Leadtools.RasterImage is painted.
Returns a GDI+ palette corresponding to this Leadtools.RasterImage if painted on the given graphic object.
Syntax
public static ColorPalette GetPaintPalette( 
   RasterImage image,
   Graphics graphics
)
'Declaration
 
Public Shared Function GetPaintPalette( _
   ByVal image As RasterImage, _
   ByVal graphics As Graphics _
) As ColorPalette
'Usage
 
Dim image As RasterImage
Dim graphics As Graphics
Dim value As ColorPalette
 
value = RasterImagePainter.GetPaintPalette(image, graphics)
public static ColorPalette GetPaintPalette( 
   RasterImage image,
   Graphics graphics
)
 function Leadtools.Drawing.RasterImagePainter.GetPaintPalette( 
   image ,
   graphics 
)
public:
static ColorPalette^ GetPaintPalette( 
   RasterImage^ image,
   Graphics^ 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+.

For more information, refer to Handling Palette Changes.

Example
 
Public Sub GetPaintPaletteExample()
      Dim codecs As New RasterCodecs()
      Dim image As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"), 8, CodecsLoadByteOrder.Rgb, 1, 1)

      Using btmp As New Bitmap(1, 1)
         Using g As Graphics = Graphics.FromImage(btmp)
            Dim palette As ColorPalette = RasterImagePainter.GetPaintPalette(image, g)
            If Not IsNothing(palette) Then
               Console.WriteLine("Paint palette colors:")
               For i As Integer = 0 To palette.Entries.Length - 1
                  Console.WriteLine("{0} - {1}", i, palette.Entries(i))
               Next
            Else
               Console.WriteLine("There is no palette")
            End If
         End Using
      End Using

      image.Dispose()
      codecs.Dispose()
   End Sub

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
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:\Users\Public\Documents\LEADTOOLS Images";
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

RasterImagePainter Class
RasterImagePainter Members

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.