ConvertIconToBitmap
Converts an icon picture into a bitmap picture.
Syntax: ConvertIconToBitmap( IconPicture [ , BackColor ] ) As Object
- IconPicture
- required Object. An stdole.StdPicture holding an icon (
vbPicTypeIcon) or cursor (vbPicTypeIcon). - BackColor
- optional Variant. The background colour to flatten transparent pixels onto, given as an OLE colour value. If omitted, the system Window colour is used.
The returned picture is a fresh bitmap-typed stdole.StdPicture with the icon rasterised on top of the chosen background. The original icon picture is unchanged.
Warning BETA 1034
An IconPicture of Nothing ends the program with an access violation, in a 32-bit and a 64-bit build alike.
Common Errors
| Error | When |
|---|---|
-2147467259 (&H80004005), Unspecified error | IconPicture is not an icon: a bitmap, a picture with no image, or an object that is not a picture |
5 (&H5), Invalid procedure call or argument | BackColor’s high byte is other than 0, 1, 2 or &H80 (-1, for one), or it is a system colour above &H8000001E |
13 (&HD), Type mismatch | BackColor is a string that does not hold a number |
94 (&H5E), Invalid use of Null | BackColor is Null |
424 (&H1A8), Object required | IconPicture is Null |
Example
Dim MyIconPicture As StdPicture
Dim Bmp As StdPicture
Set Bmp = ConvertIconToBitmap(MyIconPicture, RGB(255, 255, 255))
Set Picture1.Picture = Bmp
See Also
- CreateStdPictureFromHandle function
- PictureToByteArray function