How to create a greyscale palette #215

var
  PPal: PLogPalette;
  i: byte;
begin
  GetMem (PPal, SizeOf(TLogPalette) + 255 * SizeOf(TPaletteEntry));
  with PPal^ do
  begin
    PalVersion := $300;
    PalNumEntries := 256;
    {$R-}
    for i := 0 to 255 do
    begin
      PalPalEntry[i].peRed := i;
      PalPalEntry[i].peGreen := i;
      PalPalEntry[i].peBlue  := i;
      PalPalEntry[i].peFlags := 0;
    end;
  end;
  Result:= CreatePalette(PPal^);
  FreeMem (PPal, SizeOf(TLogPalette) + 255 * SizeOf(TPaletteEntry));
end;
Original resource: The Delphi Pool
Author: Taras Bregin
Added: 2013/03/13
Last updated: 2013/03/13