![]() |
Umwandlung TIcon -> TBitmap
Hi,
hat jemand eine Idee wie man ein TIcon mit 32*32 Pixel in ein TBitmap mit 32*32 Pixel konvertieren kann? MFG Thomas |
Hi,
ich habe zuhause eine Funktion, die ich Dir am späten Nachmittag zur Verfügung stellen kann. Sie basiert darauf, dass ein TBitmap eine Canvas bereits stellt, auf die man das TIcon zeichnen kann. Vorher noch mit TBitmap.Width / TBitmap.Height die Größe angepasst, die Farbtiefe im Zweifelsfall lieber etwas zu hoch gewählt und schon geht's los :-) Grüße, Daniel |
That's it.
Code:
:cat:
[b]var[/b]
Bitmap: TBitmap; Icon: TIcon; [b]begin[/b] Icon := TIcon.Create; Bitmap := TBitmap; [b]try[/b] Icon.Handle := ICONHANDLE von Irgendwo; Bitmap.Width := Icon.Width; Bitmap.Height := Icon.Height; Bitmap.Canvas.Draw(0, 0, Icon); ..... [b]finally[/b] Bitmap.Free; Icon.Free; [b]end[/b]; [b]end[/b]; |
Jo danke :D
|
Hast du auch ne Idee für den umgekehrten Weg?
|
Re: Umwandlung TIcon -> TBitmap
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; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:40 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz