Streaming Image into Picture Box

  • Thread starter Thread starter Tom John
  • Start date Start date
T

Tom John

Hi

I am using Office Web Components to generate a GIF image, which i want
to display in a picture box.

However i am having a problem when i attempt to load the image into
the picture box. Firstly i was saving the image using the Chartspace
Export and passing the path to the PictureBox load, however i think
that the image is not saved properly before the picturebox attempts to
load it.

Therefor i figured streaming it would be pretty cool, but i can't get
it to work, casting problems:


In the form load:

ChartOverviewPicture.Image.FromStream(GenerateChart())


Private Function GenerateChart() As Stream
'Code to generate chart

Return ChartSpace.GetPicture("gif", 500, 300)
End Function


Anyone ideas would be great.

Thanks

Tom
 
Hi Tom,

This is not direct your answer, because I do not know what it the format of
a chartspace Export.

This is streaming a picture from a database to am image while a memorystream
is used.
\\\
Dim arrPicture() As Byte = CType(dsFototable.Tables(0).Rows(0)("foto"),
Byte())
Dim ms As New MemoryStream(arrPicture)
originalImage = Image.FromStream(ms)
///

I hope this helps a little bit.

Cor
 
* Tom John said:
I am using Office Web Components to generate a GIF image, which i want
to display in a picture box.

However i am having a problem when i attempt to load the image into
the picture box. Firstly i was saving the image using the Chartspace
Export and passing the path to the PictureBox load, however i think
that the image is not saved properly before the picturebox attempts to
load it.

Bitmap -> Byte() -> Bitmap:

\\\
Dim b As New Bitmap("C:\WINDOWS\Angler.bmp")
Dim ms As New MemoryStream
b.Save(ms, ImageFormat.Bmp)
Dim abyt(ms.Length - 1) As Byte
ms.Seek(0, SeekOrigin.Begin)
ms.Read(abyt, 0, ms.Length)
Dim mx As New MemoryStream(abyt)
Me.BackgroundImage = Bitmap.FromStream(mx)
///
 
Cor

Thanks, this pointed me in the direction of what i was after. I
modified your code to work with the OWC ChartSpace and return an
image:

Dim ChartImageArray() As Byte = CType(ChartSpace.GetPicture(), Byte())
Dim ChartImageMemoryStream As New MemoryStream(ChartImageArray)
Return Image.FromStream(ChartImageMemoryStream)

Thanks again.

Tom
 
Back
Top