Returns a Windows palette handle corresponding to this
RasterImage if painted on the given device context.
Syntax
Visual Basic (Declaration) |
|
Public Function GetPaintHPalette( _
ByVal hdc As IntPtr _
) As IntPtr |
Visual Basic (Usage) |
Copy Code |
Dim instance As RasterImage
Dim hdc As IntPtr
Dim value As IntPtr
value = instance.GetPaintHPalette(hdc)
|
Parameters
- hdc
- The device context object on which this RasterImage is painted.
Return Value
A Windows palette handle (HPALETTE)
Example
Visual Basic |
Copy Code |
Public Sub GetPaintHPaletteExample() 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 GetPaintHPaletteExample() { 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