Image/Picture <-> Bitmap from Access-OLE Fields in VB.NET?

M

Matthias Müller

Hello,
I know, that this here is possibly not the right ng to ask, but I do it,
because I hope Stephen Lebans can help me.
I have an mdb with a Table, containing pictures. Some of them are "Bitmap",
some are "Bild" (wich I think is "Image" or "Picture" - I'm using the german
version).
I try to show these Pictures from a VB.NET-Application. I can show
"Bitmap"s, but I can't show "Bild". I think "Bild" is a DIB, but I found no
way to show it.

Here the code used:
-----------------------------------------------------------------
' Get Data

Me.OleDbDataAdapterFotos.SelectCommand.CommandText = "SELECT PID, Foto FROM
PersonFoto WHERE PID = " & myPIDtoSearch

Dim myDSF As DataSet = New DataSet
Me.OleDbDataAdapterFotos.Fill(myDSF)
Dim myF As System.Data.DataRow()
myF = myDSF.Tables("PersonFoto").Select("PID = " & myPIDtoSearch)


Dim myMemStream As MemoryStream


' Cut first Bytes (probably the OLE-Header)
myMemPictStream.Write(myF(0)("Foto"), 73 - 1, UBound(myF(0)("Foto")) - 73 +
1)


Try
b = New Bitmap(myMemPictStream)
Me.Foto.Image = b
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OKOnly Or MsgBoxStyle.Information, "Ups")
Me.Foto.Image = Nothing
End Try

-----------------------------------------------------------------------------

This works fine with "Bitmap".
But it doesn't work with "Bild" ("Image" or "Picture"). This always returns
an Excption: "Invalid Parameter"

Is there a way to show these "Bild"-Element outside Access? Does anybody
know something about the format of "Bild"?

Thank You for your help (and excuse my poor english).

Matthias Müller
 
S

Stephen Lebans

The Header is documented in a couple of KB articles. The Header size can
be of variable in length if it includes the original filename. Search
the MS KB for:
read OLE header Access

THere are at least two seperate articles with code. I think a couple of
months ago I was involved in a thread on this same issue. GoogleGroups
should turn it up.

Let me know how you make out. I'd like to write up an article on this
issue as it is starting to popup now and then.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
W

William Benson

I am not sure my need is related, but what I have is a table of imageURLs, I
am looking for a quick way to save the pictures they point to as jpg's on my
HD.

I thought I could load the pictures into a control on the form, looping
through them one by one, and then save the resulting picture to disk using
simple code.

I say simple but maybe it is not simple?

Could someone walk me through this or give me a pointer to a KB article?

Thanks so much!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top