(CodeLib-Manager)
Registriert seit: 10. Jun 2002
4.648 Beiträge
Delphi XE Professional
|
Re: Bitmap zu Icon ohne Farbe Verlust ?
23. Aug 2008, 14:20
Hallo,
So wird die Qualität besser:
Delphi-Quellcode:
uses
IconsToFile; {Siehe Anhang icon2file.zip}
function Bmp2Ico(Bitmap: TBitmap; IcoFileName: TFilename): Boolean;
var
Icon: TIcon;
ImageList: TImageList;
begin
Result := False;
ImageList := TImageList.CreateSize(Bitmap.Width, Bitmap.Height);
try
ImageList.AllocBy := 1;
ImageList.AddMasked(Bitmap, Bitmap.TransparentColor);
Icon := TIcon.Create;
try
ImageList.GetIcon(0, Icon);
Result := hicontofile(IcoFileName, Icon.Handle, BitC24) <> -1;
// Icon.SaveToFile(IcoFileName);
finally
Icon.Free;
end;
finally
ImageList.Free;
end;
end;
// Beispiel:
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
begin
Bmp2Ico(Image1.Picture.Bitmap, 'c:\Output.ico');
end;
Thomas
|
|
Zitat
|