PictureBox and byte array image issue.

Welcome to Wisej Support.
Questions, suggestions and plain old bugs - are all welcome here!
0
0

Hi!
Sometimes in firefox i can’t view dynamic image in picturebox even refresing a page (biytearray.lenght>0).
Fails moreĀ in mobile devices!
Works better in internet explorer.

Even i tried to open directly url link (blank page/image) and after a few tries, it finally shows the image:
background-image: url(“component.wx?sid=b16de222-97fe-4cfc-a4ae-737a5753c047&x=eyJpZCI6MjUsInZlcnNpb24iOiI1NTU5NjMiLCJkaXNwb3NlIjpmYWxzZSwibmFtZSI6IkltYWdlIn0=”)

My code is like:

if (_imageByteArray != null && _imageByteArray.Length > 0)
{
Text = _imageByteArray.Length.ToString();
var imageStream = new MemoryStream(_imageByteArray);
var image = Image.FromStream(imageStream);
picPhoto.Image = image;
}
else
{
picPhoto.Image = null;
Text = “null image”;
}

Even if I load another byteArrayImage … lenght > 0…
Thanks in advance!

  • You must to post comments
0
0

How big is the stream?

Try to load the stream in the image like this:

var image = Image.FromStream(stream);

this.picture.Image = new Bitmap(image);

When you use Image.FromStream() directly the image may not get fully loaded, System.Graphics may keep the stream open and read the image as needed. Usually new Bitmap(image) solves this issue – if this is the issue.

 

 

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.