LEADTOOLS GDI/GDI+ (Leadtools.Drawing assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.29
GetPaintColors Method
See Also 



image
The source image.
graphics
The graphics object on which this image is painted.
image
The source image.
graphics
The graphics object on which this image is painted.
Returns a palette corresponding to this Leadtools.RasterImage if painted on the given graphics object.

Syntax

Visual Basic (Declaration) 
Public Shared Function GetPaintColors( _
   ByVal image As RasterImage, _
   ByVal graphics As Graphics _
) As RasterColor()
Visual Basic (Usage)Copy Code
Dim image As RasterImage
Dim graphics As Graphics
Dim value() As RasterColor
 
value = RasterImagePainter.GetPaintColors(image, graphics)
C# 
public static RasterColor[] GetPaintColors( 
   RasterImage image,
   Graphics graphics
)
C++/CLI 
public:
static array<RasterColor>^ GetPaintColors( 
   RasterImage^ image,
   Graphics^ graphics
) 

Parameters

image
The source image.
graphics
The graphics object on which this image is painted.

Return Value

An array of color for the palette

Example

Visual BasicCopy Code
Public Sub GetPaintColorsExample()
      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 colors() As RasterColor = RasterImagePainter.GetPaintColors(image, g)
            If Not IsNothing(colors) Then
               Console.WriteLine("Paint colors:")
               For i As Integer = 0 To colors.Length - 1
                  Console.WriteLine("{0} - {1}", i, colors(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
C#Copy Code
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:\Users\Public\Documents\LEADTOOLS Images";
}

Remarks

For more information refer to RasterImage and GDI/GDI+.

For more information, refer to Color Halftone and Halftone Images.

Requirements

Target Platforms: Silverlight 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7, MAC OS/X (Intel Only)

See Also