Programming C++Builder How to convert an icon to a bitmap in C++Builder
Notice: Undefined variable: relatedArticlesCount in /home/wwwroot/ on line 149

This example show you how to convert a specified icon to a bitmap. Easy way follow me. Create a new project in c++builder enviroment, put an Image, a Button and an OpenDialog control on the Form1. Rename the button1 ConvertIcon2Bitmap, then add the following codes as its OnClick event handler.

void __fastcall TForm1::ConvertIcon2BitmapClick(TObject *Sender)

  OpenDialog1->DefaultExt = ".ICO";
  OpenDialog1->Filter = "icons (*.ico)|*.ICO";
  OpenDialog1->Options << ofOverwritePrompt << ofFileMustExist << ofHideReadOnly;
  if (OpenDialog1->Execute())
    TIcon *pIcon = new TIcon();
      AnsiString szBitmap;
      szBitmap = ChangeFileExt(OpenDialog1->FileName,".BMP");
      Image1->Width = pIcon->Width;
      Image1->Height = pIcon->Height;

      ShowMessage(OpenDialog1->FileName + "has been saved to " + szBitmap);
      delete pIcon;

Run your project to see the result and good luck!

Add comment

Security code

Programming - C++Builder