Method function IGDIPlus.TGPGraphics.GetHalftonePalette() : HPALETTE

From Mitov Wiki Doc
Jump to: navigation, search

This is a Beta Read Only version of this page. Please review and send recommendations to mitov@mitov.com. We will enable the editing as soon as we are happy with the overall Wiki site.

Class: TGPGraphics

Contents

Syntax

Delphi:

function GetHalftonePalette() : HPALETTE;

C++ Builder:

HPALETTE __fastcall GetHalftonePalette();

Visual C++ (MFC):

HPALETTE GetHalftonePalette();

Summary

Returns a Windows halftone palette.

Description

Call this method to get a Windows halftone palette.


Example:

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.

var
  AGraphics1 : IGPGraphics;
  AGraphics2 : IGPGraphics;
  AImage     : IGPImage;
  APalette   : HPALETTE;

begin

  AImage := TGPImage.Create( 'Mosaic.png' );



  AGraphics1 := TGPGraphics.Create( ACanvas );
  AGraphics1.DrawImage(AImage, 10, 10);


  Araphics1 := NIL;

  APalette := TGPGraphics.GetHalftonePalette();
  SelectPalette( ACanvas.Handle, APalette, FALSE);
  RealizePalette( ACanvas.Handle );

  AGraphics2 := TGPGraphics.Create( ACanvas );
  graphics2.DrawImage(AImage, 300, 10);


  Araphics2 := NIL;
  DeleteObject( APalette);
end;

Remarks The purpose of the 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 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 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.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox