创建调色板

procedure TForm1.Button1Click(Sender: TObject);
var
  lpPalette : PLogPalette;
  hPal : hPalette;
  i : integer;
begin

 {Allocate the memory used by the palette}
  GetMem(lpPalette,
         sizeof(TLogPalette) + (255 * sizeof(TPaletteEntry)));

 {Fill out the palette header}
  lpPalette^.palVersion := $300;
  lpPalette^.palNumEntries := 256;

 {Turn range checking off if it is on and}
 {remember the range checking state}
 {$IFOPT R+}
   {$DEFINE CKRANGE}
   {$R-}
 {$ENDIF}

 {Fill in the palette structure color table with shades of gray}
  for i := 0 to 255 do begin
    lpPalette^.PalPalEntry[i].peRed := i;
    lpPalette^.PalPalEntry[i].peGreen := i;
    lpPalette^.PalPalEntry[i].peBlue := i;
  end;

 {Turn range checking back on if it was on when we started}
 {$IFDEF CKRANGE}
   {$UNDEF CKRANGE}
   {$R+}
 {$ENDIF}

 {Create a palette handle}
  hPal := CreatePalette(lpPalette^);

 {Free the memory use by the palette structure}
  FreeMem(lpPalette,
          sizeof(TLogPalette) + (255 * sizeof(TPaletteEntry)));

 {Do something with the palette here}

 {Delete the palette handle after use}
  DeleteObject(hPal);
end;

 

转载于:https://www.cnblogs.com/yzryc/p/6373583.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值