How do I get an Icon from a png image?
Icons are a combination of 3 or 4 image sizes:
48 × 48, 32 × 32, 24 × 24 (optional), and 16 × 16 pixels.
And can/should also contain three different colour depths:
- 24-bit with 8-bit alpha (32-bit)
- 8-bit (256 colors) with 1-bit transparency
- 4-bit (16 colors) with 1-bit transparency
So the .png memory stream isn't going to fit into the icon's constructor. In fact, if you read the notes on the other constructor overloads, you'll see all the "Size" or Width and Height measurements for finding the correct size icon in the file.
More information on the manual creation of icons can be found under "Creating Windows XP Icons"