Image class and memoryStream/Stream problems once more
I have an array of gray level bytes I want to show on screen. In order to do that I use MemoryStream and the Image class:
private void CellView_Paint(object sender, System.Windows.Forms.PaintEventArgas e)
{
MemoryStream strm = new MemoryStream();
Image img;
Graphics grfx;
Graphics grfx = e.Graphics;
// Panel was created further up in the program
// what is shown here is a small part of the whole program
grfx = panel.CreateGraphics();
strm.Position = 0; strm.Write(pByteArray,0,nSize);
Stream st = (Stream)strm;
img = Image.FromStream(st); grfx.DrawImage(img,0,0,width,height);
strm.Close;
}
But the program gives the same error message as before:
Invalid parameter used in the statement below:
img = Image.FromStream(strm);
It seems as if
Report this post to a moderator | IP: Logged
01-28-2003 10:48 AM
*************
I tested for at least compilation
private void buttonOpenIE_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
MemoryStream strm = new MemoryStream();
Image img;
Thanks for your help.
I made a new program where I used the code you send me. The compilation went fine though, but when I ran the program I got the same error message as before in my original program. It crashes in the statement
img = Image.FromStream(st)
where an error message box pops up saying
Invalid parameter used
Thanks for having a look. I attach the project without the bin directory. It is a very simple example in order to keep the program as simple and small as possible
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.