Преобразование ICO в BMP
Решение 1Попробуйте:
var
Icon: TIcon;
Bitmap: TBitmap;
begin
Icon:= TIcon.Create;
Bitmap:= TBitmap.Create;
Icon.LoadFromFile('c:\picture.ico');
Bitmap.Width:= Icon.Width;
Bitmap.Height:= Icon.Height;
Bitmap.Canvas.Draw(0, 0, Icon);
Bitmap.SaveToFile('c:\picture.bmp');
Icon.Free;
Bitmap.Free;
end;
Решение 2Способ преобразования изображения размером 32#215;32 в иконку.
unit main;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,Dialogs,ExtCtrls, StdCtrls;
type TForm1 = class(TForm)
Button1: TButton;
Image1: TImage;
Image2: TImage;
procedure Button1Click(Sender: Tobject);
procedure FormCreate(Sender: Tobject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
Procedure Tform1.Button1Click(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(Application.ExeName) + 'myfile.bmp');
end;
Procedure Tform1.FormCreate(Sender: Tobject);
begin
image1.picture.icon.loadfromfile('c:\myicon.ico');
end;
end.