«« Site Rescued »»

While the site is still going to move from its current host, a new site will now take its place. More Info.

The new site may have less content, but the core will now remain. And it will now play nicely with phones! Keep an eye on the DelphiDabbler Blog for news.

» Help

How to create a greyscale palette

   
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

« Return to contents »