Graphics.GetHalftonePalette Method
Assembly: System.Drawing (in system.drawing.dll)
The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. The code performs the following actions:
-
Defines interoperability DllImportAttribute attributes for the Windows DLL file gdi32.dll, which contains the necessary GDI functions.
-
Defines the SelectPalette and RealizePalette functions in that DLL as external.
-
Creates an image from an existing image file SampImag.jpg (which must be in the same folder as the example code file) and draws the image to the screen.
-
Creates internal pointer type variables and sets their values to the handle to the graphics object and to the current Windows halftone palette, respectively.
-
Selects and realizes the halftone palette.
-
Creates a new graphics object using the hdc parameter.
-
Draws the image again.
-
Releases the handle to the device context.
The result is two renderings of the sample image: one with the 16-bit palette and one with the 8-bit palette.
Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.