472,133 Members | 1,071 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,133 software developers and data experts.

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)
Try
bmp.Save(oStream, Imaging.ImageFormat.Bmp)
ConvertFromPictureBoxToArray = oStream.ToArray
bmp.Dispose()
oStream.Close()
Catch ex As Exception '//--Catch
MsgBox(ex.Message)
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.

Thanks,
Mike Dixon

Jun 13 '06 #1
0 3079

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

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.