Mega Code Archive

 
Categories / Delphi / Graphic
 

Icon to BMP Icono a mapa de bits

Title: Icon to BMP / Icono a mapa de bits Question: How to convert ico-resource into bitmap? Com crear un mapa de bits a partir de un icono? Answer: You must use the Draw method of the TCanvas object. Remember icons do not stretch, so do not use TCanvas.StretchDraw with an icon. ---------------------------------------------------------------------- Para lograrlo debe utilizar el mtodo "Draw" de un objeto "TCanvas". Recuerde que no es posible utilizar el mtodo "StretchDraw" de un objeto "TCanvas" con un icono. procedure ... var aIcon: TIcon; aBitmap: TBitmap; begin aIcon := TIcon.Create; try // (1)(2) ... aIcon.Handle := ExtractIcon(HInstance, Name_Of_Resource, 0); aBitmap := TBitmap.Create; with aBitmap do begin Width := aIcon.Width; Height := aIcon.Height; Canvas.Draw(0, 0, aIcon); ... // (3) ... ... end // with aBitmap ... finally FreeAndNil(aIcon); FreeAndNil(aBitmap) end // try ... finally ... end; // procedure ... ---------------------------------------------------------------------- (1) You must supply the name of a EXE or DLL file. Debe de proporcionar el nombre del Archivo .EXE o .DLL del que se desea obtener el Icono (2) Index 0 is the main icon El ndice 0 representa al icono principal (3) Make something else with the bitmap Su cdigo va en este lugar