>ColorToRGB() 查查delphi的在线帮助文件
返回的是longint,肯定不行的。贴一个例子有关调色板的:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
x,y : integer;
BitMap : TBitMap;
lplogpal
MaxLogPalette;//pointer of TMaxLogPalette
p
ByteArray;
begin
BitMap := TBitMap.create;
Bitmap.Width:=form1.Width;
Bitmap.Height:=form1.Height;
Bitmap.PixelFormat:= pf8bit;
// randomize;
GetMem(lpLogPal,sizeof(TLOGPALETTE) + ((255) * sizeof(TPALETTEENTRY)));
lpLogPal.palVersion := $0300; //the current palette version
lpLogPal.palNumEntries := 256;
for x := 0 to 255 do
begin
lpLogPal.palPalEntry[x].peRed := 255;//x*23
lpLogPal.palPalEntry[x].peGreen :=x;
lpLogPal.palPalEntry[x].peBlue := random(127);
end;
Bitmap.Palette := CreatePalette(pLogPalette(lpLogPal)^);
FreeMem(lpLogPal,sizeof(TLOGPALETTE) + ((255) * sizeof(TPALETTEENTRY)));
for y := 0 to BitMap.Height -1 do
begin
P := BitMap.ScanLine[y];
for x := 0 to BitMap.Width -1 do
P[x] :=byte( (y*x));//ÕâÀï²»ÀàÐÍת»»Ò»ÏÂÒ²»áRange Checking´í
end;
canvas.draw(0,0,BitMap);//form.canvas, just for a look
end;
end.