首页 > Windows开发 > 详细

Delphi 把一个ICO转换为BMP

时间:2015-11-26 22:53:32      阅读:490      评论:0      收藏:0      [点我收藏+]
// 方法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 to
BMP!
   Icon.Free;
   Bitmap.Free;
end;

// 方法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;

http://blog.csdn.net/yanjiaye520/article/details/6676215

Delphi 把一个ICO转换为BMP

原文:http://www.cnblogs.com/findumars/p/4999182.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!