我已经写过一次了,应该是这样吧.问题是这样并不能解决问题
mBmp.Canvas.Draw(0,0,mIcon);
完整代码
procedure TForm1.Button1Click(Sender: TObject);
var
mIcon: TIcon;
palette:hpalette;
entries:array[0..255] of TPaletteEntry;
number :Integer;
mBmp: TBitmap;
begin
mIcon:=TIcon.Create;
mBmp:=TBitmap.Create;
try
mIcon.LoadFromFile('c:/1.ico');
mBmp.Width:=32;
mBmp.Height:=32;
mBmp.Canvas.Draw(0,0,mIcon);
palette:=mBmp.Palette;
number:=GetPaletteEntries(mBmp.Palette,0,256,entries);
finally
mIcon.Free;
mBmp.Free;
end;
edit1.text:=inttostr(number);
end;