Graphics::GetHalftonePalette method (gdiplusgraphics.h)

The Graphics::GetHalftonePalette method gets a Windows halftone palette.

Syntax

HPALETTE GetHalftonePalette();

Return value

Type: static

This method returns a handle to a Windows halftone palette.

Remarks

The purpose of the Graphics::GetHalftonePalette method is to enable GDI+ to produce a better quality halftone when the display uses 8 bits per pixel. To display an image using the halftone palette, use the following procedure:

  1. Call Graphics::GetHalftonePalette to get a GDI+ halftone palette.
  2. Select the halftone palette into a device context.
  3. Realize the palette by calling the RealizePalette function.
  4. Construct a Graphics object from a handle to the device context.
  5. Call the Graphics::DrawImage method of the Graphics object.
Be sure to delete the palette when you have finished using it. If you do not follow the preceding procedure, then on an 8-bits-per-pixel-display device, the default, 16-color process is used, which results in a lesser quality halftone.

Examples

The following example draws the same image twice. Before the image is drawn the second time, the code gets a halftone palette, selects the palette into a device context, and realizes the palette.

VOID Example_GetHalftonePalette(HDC hdc)
{
   Image image(L"Mosaic.png");
   
   Graphics* graphics1 = new Graphics(hdc);
   graphics1->DrawImage(&image, 10, 10);
   delete graphics1;
   
   HPALETTE hPalette = Graphics::GetHalftonePalette();
   SelectPalette(hdc, hPalette, FALSE);
   RealizePalette(hdc);
   Graphics* graphics2 = new Graphics(hdc);
   graphics2->DrawImage(&image, 300, 10);
   delete graphics2;
   DeleteObject(hPalette);
}

Requirements

Requirement Value
Minimum supported client Windows XP, Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header gdiplusgraphics.h (include Gdiplus.h)
Library Gdiplus.lib
DLL Gdiplus.dll

See also

GetPalette

Graphics

RealizePalette

SetPalette