Einzelnen Beitrag anzeigen

Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#6

Re: Umwandlung TIcon -> TBitmap

  Alt 2. Aug 2003, 20:58
Genau umgekehrt:
Delphi-Quellcode:
// ein Bitmap wird zu einem Iconprocedure
TForm1.Button1Click(Sender: TObject);
var bm1,bm2:TBitmap;
  ic:TIcon;Iinfo:TIconInfo;
begin
  ic:=TIcon.Create;
  bm1:=TBitmap.create;
  try
    bm1.loadfromfile('d:\bilder\vogel.bmp');
    bm2:=TBitmap.create;
    bm2.width:=ic.width;
    bm2.height:=ic.height;
    bm2.canvas.stretchdraw(rect(0,0,bm2.width,bm2.height),bm1);
    bm1.assign(bm2);
    bm2.monochrome:=true;
    Iinfo.fIcon:=true;
    Iinfo.xHotspot:=0;
    Iinfo.yHotspot:=0;
    Iinfo.hbmMask:=bm2.Handle;
    Iinfo.hbmColor:=bm1.Handle;
    ic.Handle:=CreateIconIndirect(Iinfo);
    ic.savetofile('c:\test.ico');
  finally
    bm2.free;
    bm1.free;
  ic.free;
end;
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat