469,645 Members | 1,595 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,645 developers. It's quick & easy.

Obtaining array of bytes from PictureBox or PictureBox.Handle

I have a third party DLL that communicates with a camera (Sony 1384)
and I have it working where the image is being displayed in a
picturebox. I am using VB.NET . There is a function in the legacy DLL
that allows me to send in the PictureBox Handle and the image is then
set to that handle.

I have the need to obtain the bytes from the image and store them in a
database. I tried using the following:

Private Function ConvertFromPictureBoxToArray(ByVal oPictureBox As
PictureBox) As Byte()
Dim oStream As New MemoryStream
Dim myImage As Image

If oPictureBox.Image Is Nothing Then
ConvertFromPictureBoxToArray = Nothing
Return Nothing
End If
Dim bmp As New Bitmap(oPictureBox.Image)
bmp.Save(oStream, Imaging.ImageFormat.Bmp)
ConvertFromPictureBoxToArray = oStream.ToArray
Catch ex As Exception '//--Catch
End Try
End Function

The problem is that PictureBox.Image is nothing and therefore I get no
data. I believe the legacy DLL is using DirectShow. Does anyone know
how to get the data, for instance, from the Handle or any other way.

Mike Dixon

Jun 13 '06 #1
0 2955

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Walter Dnes (delete the 'z' to get my real address | last post: by
3 posts views Thread by Dean Slindee | last post: by
11 posts views Thread by seannakasone | last post: by
5 posts views Thread by toby | last post: by
5 posts views Thread by =?Utf-8?B?QXlrdXQgRXJnaW4=?= | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.