Board index » delphi » BMP --> ICO...

BMP --> ICO...

Is there an algorithm or routine to convert 32x32 bit Bitmaps to ICO's?

 

Re:BMP --> ICO...


Quote
De{*word*81} wrote:

> Is there an algorithm or routine to convert 32x32 bit Bitmaps to ICO's?

        See, the reason nobody is telling you how to do it is that (as
paople have said before) "convert a bmp to an ico" is not a well-defined
operation. The ico file contains two bitmaps, roughly an image and a mask.
You need to decide how you're going to decide which parts of the
bitmap should become transparent in the icon.

--
David Ullrich

sig.txt not found

Re:BMP --> ICO...


Actually I did figure it out afterall. :D

Re:BMP --> ICO...


Quote
In article <19970905175701.NAA15...@ladder02.news.aol.com>, debug...@aol.com (De{*word*81}) wrote:

>Is there an algorithm or routine to convert 32x32 bit Bitmaps to ICO's?

In the UDDF there is ICO -> BMP. I think you can reverse that process.

The Graphical Gnome   (r...@ktibv.nl)
Senior Software Engineer

Information Technology Department KTI b.v.
Phone: +31 79 3531520

--------------------------------------------------------------------------------------------------------------
Delphi developers FAQ at http://www.gnomehome.demon.nl/uddf/index.htm
Non frame version     at http://www.gnomehome.demon.nl/uddf/indexnf.htm
Delphi Beautifier     at http://www.gnomehome.demon.nl/xrefpas/xrefpas.zip    

Re:BMP --> ICO...


On 5 Sep 1997 17:57:35 GMT, debug...@aol.com (De{*word*81}) wrote:

Quote

>Is there an algorithm or routine to convert 32x32 bit Bitmaps to ICO's?

This will do it:

david sampson

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.

david sampson

dsamp...@atlanta.com

Other Threads