none
How can you convert an icon to bitmap larger than 32 x 32? RRS feed

  • Question

  • As some of you may know there is a simple way to convert an icon to bitmap using the following:

    Icon.ToBitmap

    But the problem is... It only works for the icon size 32 x 32. Which is really small. I want to be able to load a 256 x 256 icon and display it on the form in its full size. I tried forcing it with an icon that only contains a 256 x 256 image in it, but it immanently gave an error telling me that the size is out of bounds.

    Anyone know why Microsoft did this? I can understand 32 x 32 is an appropriate size for an icon, but that does not mean there isn't any bigger icons in use...

    Would be glad if someone could find a way around this little problem without any dll's, hate those things, code should all be in the EXE ;p.

    Thanks in advance.


    • Edited by Pk King X11 Saturday, July 7, 2012 11:48 AM
    Saturday, July 7, 2012 11:46 AM

Answers

  • I can't reproduce this problem. Your code works fine at my end.

    Why don't you create a bitmap directly from the icon file?

    Bitmap bmp = new Bitmap(@"C:\TestFiles\Icons\icon4848.ico");

    If this also fails, then I suggest you to try it on different machine.

    I hope this helps.


    Please mark this post as answer if it solved your problem. Happy Programming!

    Saturday, July 7, 2012 5:35 PM

All replies

  • I can't reproduce this problem. Your code works fine at my end.

    Why don't you create a bitmap directly from the icon file?

    Bitmap bmp = new Bitmap(@"C:\TestFiles\Icons\icon4848.ico");

    If this also fails, then I suggest you to try it on different machine.

    I hope this helps.


    Please mark this post as answer if it solved your problem. Happy Programming!

    Saturday, July 7, 2012 5:35 PM
  • You should read before you post.

    It converts the icon to bitmap BUT IT DOES IT FOR A SIZE OF 32 X 32

    That is small, try converting a 256 x 256 icon to bitmap - it simply will not work because Microsoft believes 32 x 32 is big enough. Well its not.

    And I don't know about C#, but this is a VB.Net discussion...

    Saturday, July 7, 2012 8:31 PM
  • Why did you think that I didn't try with 256x256 icon? I definitely used 256x256 icon and I succesfully converted it to Bitmap using both the methods. That's why I told you to try running your program in differen machine.


    Please mark this post as answer if it solved your problem. Happy Programming!

    Sunday, July 8, 2012 4:07 AM
  • Ok, my bad. I see that it needs to contain only the size that I want converted to bitmap. But my question now is how could I split an icon that has multiple resolutions and color formats and specify which one I want to use.
    Sunday, July 8, 2012 9:43 PM
  • Hi Pk King,

    Welcome to the MSDN Forum.

    For the further question, I suggest you start a new thread for it.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, July 10, 2012 8:12 AM
    Moderator