Returns a GDI+ palette corresponding to this
RasterImage if painted on the given graphic object.
Syntax
Parameters
- graphics
- The graphics object on which this RasterImage is painted.
Return Value
a GDI+ palette
Example
Visual Basic |
Copy Code |
Public Sub GetPaintPaletteExample() RasterCodecs.Startup() Dim codecs As New RasterCodecs()
Dim srcFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "Ocr1.tif"
Dim image As RasterImage = codecs.Load(srcFileName)
Dim btmp As New Bitmap(1, 1) Dim g As Graphics = Graphics.FromImage(btmp) Dim palette As ColorPalette = image.GetPaintPalette(g) g.Dispose() btmp.Dispose()
Console.WriteLine("Paint palette has {0} entries", palette.Entries.Length) For i As Integer = 0 To palette.Entries.Length - 1 Console.WriteLine("{0} - {1}", i, palette.Entries(i).ToString()) Next
image.Dispose() codecs.Dispose() RasterCodecs.Shutdown() End Sub |
C# |
Copy Code |
public void GetPaintPaletteExample() { RasterCodecs.Startup(); RasterCodecs codecs = new RasterCodecs(); string srcFileName = LeadtoolsExamples.Common.ImagesPath.Path + "Ocr1.tif"; // Load a paletteized image RasterImage image = codecs.Load(srcFileName); // Get the palette Bitmap btmp = new Bitmap(1, 1); Graphics g = Graphics.FromImage(btmp); ColorPalette palette = image.GetPaintPalette(g); g.Dispose(); btmp.Dispose(); Console.WriteLine("Paint palette has {0} entries", palette.Entries.Length); for(int i = 0; i < palette.Entries.Length; i++) Console.WriteLine("{0} - {1}", i, palette.Entries[i].ToString()); 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