Converting an Icon (.ICO) to Bitmap (.BMP) Format

Last reviewed: December 8, 1995
Article ID: Q140890
The information in this article applies to:

- Professional and Enterprise Editions of Microsoft Visual Basic,

  16-bit only, for Windows, version 4.0

SUMMARY

You can convert a Windows icon file (.ICO) to a Windows bitmap (.BMP) file by storing the icon in a picture box, and then using the SavePicture statement with the Image property of the picture control.

MORE INFORMATION

You may wish to convert an icon format file to the bitmap format to perform operations that cannot be performed on icon format files, such as loading the image into Microsoft Windows Paintbrush.

To convert an icon format file to a bitmap format file, assign the icon to the Picture property of a picture box property (at design-time or run-time). At run-time, use the following statement:

   SavePicture Picture1.Image, "filename.bmp"

When you convert an icon to a bitmap, you lose device independence for resolution characteristics. Windows bitmap format files, which usually have a .BMP extension, represent an image with device independent color information. Windows icon files, which usually have an .ICO extension, can contain information for both color and resolution device independence.

The steps listed below demonstrate how to convent an icon format file to a bitmap format file:

  1. Run Visual Basic for Windows, or from the File menu, choose New Project (press ALT, F, N) if Visual Basic for Windows is already running. Form1 will be created by default.

  2. Place a picture box named Picture1 on Form1.

  3. Enter the following code into the form's Click event:

       Private Sub Form_Click ()
          Picture1.AutoSize = -1
          Picture1.Picture = LoadPicture("icons\arrows\arw01dn.ico")
          SavePicture Picture1.Image, "arw01dn.bmp"
       End Sub
    
    

  4. Press the F5 key to run the program. Click Form1 to convert the file.

REFERENCES

Chapter 19 File Formats of "Microsoft Windows Programmer's Reference"


Additional reference words: 1.00 2.00 3.00 4.00 vb4win vb416
KBCategory: kbgraphic kbprg kbcode
KBSubcategory: APrgGrap



THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: December 8, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.