(1) method 1
VaR
Icon: ticon;
Bitmap: tbitmap;
Begin
Icon: = ticon. Create;
Bitmap: = tbitmap. Create;
Icon. loadfromfile ('C: \ picture. ICO '); // load an ico
From file
Bitmap. Width: = icon. width;
Bitmap. Height: = icon. height;
Bitmap. Canvas. Draw (0, 0, icon );
Bitmap. savetofile ('C: \ picture.bmp '); // convert ICO
BMP!
Icon. Free;
Bitmap. Free;
End;
(2) method 2
Procedure tform1.convertclick (Sender: tobject );
VaR
Windc, srcdc, destdc: HDC;
Oldbitmap: hbitmap;
Iinfo: ticoninfo;
Begin
Geticoninfo (image1.picture. Icon. Handle, iinfo );
Windc: = getdc (handle );
Srcdc: = createcompatibledc (windc );
Destdc: = createcompatibledc (windc );
Oldbitmap: = SelectObject (destdc, iinfo. hbmcolor );
Oldbitmap: = SelectObject (srcdc, iinfo. hbmmask );
Bitblt (destdc, 0, 0,
Image1.picture. Icon. Width, image1.picture. Icon. Height, srcdc,
0, 0, srcpaint );
Image2.picture. bitmap. Handle: = SelectObject (destdc,
Oldbitmap );
Deletedc (destdc );
Deletedc (srcdc );
Deletedc (windc );
Image2.picture. bitmap. savetofile (extractfilepath (applicat
Ion. exename) + 'myfile.bmp ');
End;
Procedure tform1.formcreate (Sender: tobject );
Begin
Image1.picture. Icon. loadfromfile ('C: \ myicon. ICO ');
End;