3
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by DdoubleD
Featured Replies
  • 1
    __avd 1,826   7 Years Ago

    Icon class is there. [code=c#] System.Drawing.Icon c = new Icon(@"c:\app\mapp\p1.ico"); pictureBox1.Image = c.ToBitmap(); [/code] Read More

0

It seems this method doesn't support ico file. I tried with .bmp files, its working fine.

Are you sure this method doesn't support ico files? I haven't seen that claim anywhere until now. Sure would be helpful to know for sure.

1

Icon class is there.

System.Drawing.Icon c = new Icon(@"c:\app\mapp\p1.ico");
pictureBox1.Image = c.ToBitmap();
Comments
thats it! :)
0

Are you sure this method doesn't support ico files? I haven't seen that claim anywhere until now. Sure would be helpful to know for sure.

Even i have not seen such claim, but i tried and was talking about result.

0

Icon class is there.

System.Drawing.Icon c = new Icon(@"c:\app\mapp\p1.ico");
pictureBox1.Image = c.ToBitmap();

I tried that--it did work. What I can't figure out is how to convert my Stream containing the icon (bitmap). I saved that icon to a file from the stream in order to narrow down the problem.

I don't understand why the Bitmap object initialization works from the file OK in this case, but not from my stream:

MemoryStream ms = new MemoryStream(webClient.DownloadData(uriIcon));
            Bitmap bmp = new Bitmap(ms); // throws exception

But, if I save the memorystream above to a file, then read it with the code you gave, it works (no exception thrown).

This failure (ParameterInvalid exception) only occurs with certain icons I test, which is why I provided the sample. How can I convert this icon directly from my stream to a bitmap without having to save it to a file first?

Thanks,
David

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.