从BMP到ICO问题...................... ( 积分: 50 )

  • 主题发起人 yunxi126
  • 开始时间
Y

yunxi126

Unregistered / Unconfirmed
GUEST, unregistred user!
var
Bmp: TBitmap;
Icon: TIcon;
ImageList: TImageList;
begin
Bmp := TBitmap.Create;
Icon := TIcon.Create;
try
Bmp.Assign(Image1.Picture);
ImageList := TImageList.CreateSize(Bmp.Width, Bmp.Height);
try
ImageList.AddMasked(Bmp, Bmp.TransparentColor);
ImageList.GetIcon(0, Icon);
Icon.SaveToFile('c:/123.ico');
finally
ImageList.Free;
end;
finally
Bmp.Free;
Icon.Free;
end;


掉色严重
 
不要用这种方法,去draw,试试这个效果:
if (Extension = ico) then
begin
aIcon:= TIcon.Create;
try
aIcon.LoadFromFile(Filename);
RESULT.Height := aIcon.Height;
RESULT.Width := aIcon.Width;
RESULT.PixelFormat := pf24bit; // avoid palette problems
RESULT.Canvas.Draw(0, 0, aIcon)
finally
aIcon.Free
end
end;
 
掉色严重是因为Delphi的TIcon.SaveToFile方法只支持16色.
 
http://www.51zhan.com 最好的网址站
http://www.51zhan.com 最好的网址站
http://www.51zhan.com 最好的网址站
 
接受答案了.
 

Similar threads

I
回复
0
查看
615
import
I
I
回复
0
查看
525
import
I
I
回复
0
查看
346
import
I
I
回复
0
查看
491
import
I
顶部