Returns a palette corresponding to this
RasterImage if painted on the given graphics object.
Syntax
Visual Basic (Usage) | Copy Code |
---|
Dim instance As RasterImage
Dim graphics As Graphics
Dim value() As RasterColor
value = instance.GetPaintColors(graphics)
|
Parameters
- graphics
- The graphics object on which this image is painted.
Return Value
An array of color for the palette
Example
Visual Basic | Copy Code |
---|
Public Sub GetPaintColorsExample()
RasterCodecs.Startup()
Dim codecs As RasterCodecs = New RasterCodecs()
Dim image As RasterImage = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "IMAGE1.CMP", 8, CodecsLoadByteOrder.Rgb, 1, 1)
Dim testForm As Form = New Form()
Dim g As Graphics = testForm.CreateGraphics()
Dim colors As RasterColor() = image.GetPaintColors(g)
If colors Is Nothing Then
Console.WriteLine("There is no palette")
Else
Dim msg As String = String.Format("There are {0} palette entries--the first entry is RGB(0x{1:x},0x{2:x},0x{3:x})", colors.Length, colors(0).R, colors(0).G, colors(0).B)
Console.WriteLine(msg)
End If
g.Dispose()
image.Dispose()
codecs.Dispose()
RasterCodecs.Shutdown()
End Sub |
C# | Copy Code |
---|
public void GetPaintColorsExample() { RasterCodecs.Startup(); RasterCodecs codecs = new RasterCodecs(); RasterImage image = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "IMAGE1.CMP", 8, CodecsLoadByteOrder.Rgb, 1, 1); Form testForm = new Form(); Graphics g = testForm.CreateGraphics(); RasterColor[] colors = image.GetPaintColors(g); if(colors == null) Console.WriteLine("There is no palette"); else { string msg = String.Format("There are {0} palette entries--the first entry is RGB(0x{1:x},0x{2:x},0x{3:x})", colors.Length, colors[0].R, colors[0].G, colors[0].B); Console.WriteLine(msg); } g.Dispose(); image.Dispose(); codecs.Dispose(); RasterCodecs.Shutdown(); } |
Remarks
Requirements
Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family
See Also