G
Guest
How can I load a image from MemoryStream ?
Rogerio
Rogerio
Rogerio Jun said:My code is generate a exception(ARGUMENTEXCEPTION).
Code:
byte[] AImagem = ((byte[])dtr.GetValue(2));
MemoryStream AStream = new MemoryStream(AImagem);
pictureBox1.Image = new Bitmap(AStream); <- this line generate a
exception.
Rogerio
Alex Feinman said:New Bitmap(myStream)
This assumes the stream contains everything, including file header, not
just
raw data
Mark Arteaga said:Most likely it's because your stream is not a bitmap. Change your code to
this to track it down further:
byte[] AImagem = ((byte[])dtr.GetValue(2));
MemoryStream AStream = new MemoryStream(AImagem);
Bitmap b = new Bitmap(AStream);
pictureBox1.Image = b;
--
Mark Arteaga
..NET Compact Framework MVP
http://www.neotericsdc.com | http://blog.markarteaga.com
Rogerio Jun said:My code is generate a exception(ARGUMENTEXCEPTION).
Code:
byte[] AImagem = ((byte[])dtr.GetValue(2));
MemoryStream AStream = new MemoryStream(AImagem);
pictureBox1.Image = new Bitmap(AStream); <- this line generate a
exception.
Rogerio
Alex Feinman said:New Bitmap(myStream)
This assumes the stream contains everything, including file header, not
just
raw data
--
Alex Feinman
---
Visit http://www.opennetcf.org
How can I load a image from MemoryStream ?
Rogerio
Rogerio said:The error persist.
Rogerio
Most likely it's because your stream is not a bitmap. Change your code to
this to track it down further:
byte[] AImagem = ((byte[])dtr.GetValue(2));
MemoryStream AStream = new MemoryStream(AImagem);
Bitmap b = new Bitmap(AStream);
pictureBox1.Image = b;
--
Mark Arteaga
..NET Compact Framework MVP
http://www.neotericsdc.com | http://blog.markarteaga.com
My code is generate a exception(ARGUMENTEXCEPTION).
Code:
byte[] AImagem = ((byte[])dtr.GetValue(2));
MemoryStream AStream = new MemoryStream(AImagem);
pictureBox1.Image = new Bitmap(AStream); <- this line generate a
exception.
Rogerio
:
New Bitmap(myStream)
This assumes the stream contains everything, including file header, not
just
raw data
--
Alex Feinman
---
Visit http://www.opennetcf.org
How can I load a image from MemoryStream ?
Rogerio
Sergey Bogdanov said:It was suggested just that you would know what causes the exception. Ok,
tell us what values have the first two bytes of the AImagem array:
byte[] AImagem = ((byte[])dtr.GetValue(2));
It should be:
0 - 0x42
1 - 0x4D
is it?
Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
Rogerio said:The error persist.
Rogerio
Most likely it's because your stream is not a bitmap. Change your code to
this to track it down further:
byte[] AImagem = ((byte[])dtr.GetValue(2));
MemoryStream AStream = new MemoryStream(AImagem);
Bitmap b = new Bitmap(AStream);
pictureBox1.Image = b;
--
Mark Arteaga
..NET Compact Framework MVP
http://www.neotericsdc.com | http://blog.markarteaga.com
My code is generate a exception(ARGUMENTEXCEPTION).
Code:
byte[] AImagem = ((byte[])dtr.GetValue(2));
MemoryStream AStream = new MemoryStream(AImagem);
pictureBox1.Image = new Bitmap(AStream); <- this line generate a
exception.
Rogerio
:
New Bitmap(myStream)
This assumes the stream contains everything, including file header, not
just
raw data
--
Alex Feinman
---
Visit http://www.opennetcf.org
How can I load a image from MemoryStream ?
Rogerio
Rogerio said:Values are 0x42 and 0x4D.
Rogerio
:
It was suggested just that you would know what causes the exception. Ok,
tell us what values have the first two bytes of the AImagem array:
byte[] AImagem = ((byte[])dtr.GetValue(2));
It should be:
0 - 0x42
1 - 0x4D
is it?
Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
Rogerio said:The error persist.
Rogerio
:
Most likely it's because your stream is not a bitmap. Change your code to
this to track it down further:
byte[] AImagem = ((byte[])dtr.GetValue(2));
MemoryStream AStream = new MemoryStream(AImagem);
Bitmap b = new Bitmap(AStream);
pictureBox1.Image = b;
--
Mark Arteaga
..NET Compact Framework MVP
http://www.neotericsdc.com | http://blog.markarteaga.com
My code is generate a exception(ARGUMENTEXCEPTION).
Code:
byte[] AImagem = ((byte[])dtr.GetValue(2));
MemoryStream AStream = new MemoryStream(AImagem);
pictureBox1.Image = new Bitmap(AStream); <- this line generate a
exception.
Rogerio
:
New Bitmap(myStream)
This assumes the stream contains everything, including file header, not
just
raw data
--
Alex Feinman
---
Visit http://www.opennetcf.org
How can I load a image from MemoryStream ?
Rogerio
Sergey Bogdanov said:Okey, try to save this image into disk and using some image viewer make
sure that this image is not corrupted.
Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
Rogerio said:Values are 0x42 and 0x4D.
Rogerio
:
It was suggested just that you would know what causes the exception. Ok,
tell us what values have the first two bytes of the AImagem array:
byte[] AImagem = ((byte[])dtr.GetValue(2));
It should be:
0 - 0x42
1 - 0x4D
is it?
Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
Rogerio Jun wrote:
The error persist.
Rogerio
:
Most likely it's because your stream is not a bitmap. Change your code to
this to track it down further:
byte[] AImagem = ((byte[])dtr.GetValue(2));
MemoryStream AStream = new MemoryStream(AImagem);
Bitmap b = new Bitmap(AStream);
pictureBox1.Image = b;
--
Mark Arteaga
..NET Compact Framework MVP
http://www.neotericsdc.com | http://blog.markarteaga.com
My code is generate a exception(ARGUMENTEXCEPTION).
Code:
byte[] AImagem = ((byte[])dtr.GetValue(2));
MemoryStream AStream = new MemoryStream(AImagem);
pictureBox1.Image = new Bitmap(AStream); <- this line generate a
exception.
Rogerio
:
New Bitmap(myStream)
This assumes the stream contains everything, including file header, not
just
raw data
--
Alex Feinman
---
Visit http://www.opennetcf.org
How can I load a image from MemoryStream ?
Rogerio
Rogerio said:I do this. In "Full Framework" the code is ok, but in Compact Framework a
exception is generate.
Rogerio
:
Okey, try to save this image into disk and using some image viewer make
sure that this image is not corrupted.
Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
Rogerio said:Values are 0x42 and 0x4D.
Rogerio
:
It was suggested just that you would know what causes the exception. Ok,
tell us what values have the first two bytes of the AImagem array:
byte[] AImagem = ((byte[])dtr.GetValue(2));
It should be:
0 - 0x42
1 - 0x4D
is it?
Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
Rogerio Jun wrote:
The error persist.
Rogerio
:
Most likely it's because your stream is not a bitmap. Change your code to
this to track it down further:
byte[] AImagem = ((byte[])dtr.GetValue(2));
MemoryStream AStream = new MemoryStream(AImagem);
Bitmap b = new Bitmap(AStream);
pictureBox1.Image = b;
--
Mark Arteaga
..NET Compact Framework MVP
http://www.neotericsdc.com | http://blog.markarteaga.com
My code is generate a exception(ARGUMENTEXCEPTION).
Code:
byte[] AImagem = ((byte[])dtr.GetValue(2));
MemoryStream AStream = new MemoryStream(AImagem);
pictureBox1.Image = new Bitmap(AStream); <- this line generate a
exception.
Rogerio
:
New Bitmap(myStream)
This assumes the stream contains everything, including file header, not
just
raw data
--
Alex Feinman
---
Visit http://www.opennetcf.org
How can I load a image from MemoryStream ?
Rogerio