| re: Reading access ole fields
Umm, I just realized that you original code would also work and be more
efficient then mine if you simply add the ms.position to it. Well ... me =
dumb.
"Marco Castro" <marco_dontspamme@benlan.com> wrote in message
news:ONYtx28IEHA.3720@tk2msftngp13.phx.gbl...[color=blue]
> Well I figured out what the problem was. It turns out that the offset has
> to be set after the byte array is read. So if anyone else was interested
> this is how the code looks for me now. And my offset ended up being 74.
> Thanks for the help again Ken.
>
> Private Function ConvertToBitmap(ByVal data() As Byte, ByVal offset As
> Integer) As Bitmap
>
> Dim ms As New System.IO.MemoryStream
>
> ms.Write(data, 0, data.Length)
>
> ms.Position = offset
>
> Return New Bitmap(ms)
>
> End Function
>
>
>
> "Ken Tucker [MVP]" <vb2ae@bellsouth.net> wrote in message
> news:ezmPvUaIEHA.3440@TK2MSFTNGP09.phx.gbl...[color=green]
> > Hi,
> >
> > Try changing the offset. It might be 0 or it might be 78. play
> > around
> >
> > Ken
> > --------------
> > "Marco Castro" <marco_dontspamme@benlan.com> wrote in message
> > news:%23bJJWNVIEHA.2948@TK2MSFTNGP11.phx.gbl...[color=darkred]
> > > I tried your code but I keep on getting the error "Invalid parameter[/color]
> > used."[color=darkred]
> > > at the line bm = New Bitmap(ms). Any idea why that would be? Thanks.
> > >
> > >
> > > "Ken Tucker [MVP]" <vb2ae@bellsouth.net> wrote in message
> > > news:%237EbsXOIEHA.3772@TK2MSFTNGP12.phx.gbl...
> > > > Hi,
> > > >
> > > > Access stores the images in binary format. Here is a[/color][/color][/color]
function[color=blue][color=green][color=darkred]
> > > that
> > > > converts the binary data into a bitmap. I put a parameter for[/color][/color][/color]
offset[color=blue][color=green][color=darkred]
> > > > because the northwind database has an offset of 78.
> > > >
> > > > Private Function ConvertToBitmap(ByVal data() As Byte, ByVal offset[/color][/color][/color]
As[color=blue][color=green][color=darkred]
> > > > Integer) As Bitmap
> > > >
> > > > Dim ms As New System.IO.MemoryStream
> > > >
> > > > Dim bm As Bitmap
> > > >
> > > > ms = New MemoryStream
> > > >
> > > > ms.Write(data, offset, data.Length - offset)
> > > >
> > > > bm = New Bitmap(ms)
> > > >
> > > > Return bm
> > > >
> > > > End Function
> > > >
> > > >
> > > >
> > > > Ken
> > > > -------------
> > > > "Marco Castro" <marco_dontspamme@benlan.com> wrote in message
> > > > news:uSaC8SLIEHA.3476@TK2MSFTNGP11.phx.gbl...
> > > > > Along time ago I created an access database where I used the ole[/color][/color]
> field[color=green][color=darkred]
> > > > type
> > > > > to store images. If I look at the table data it has the work[/color][/color]
> Picture[color=green]
> > in[color=darkred]
> > > > its
> > > > > field. The image in that field displays properly if I display it[/color][/color]
> from[color=green][color=darkred]
> > > > > inside of access but I can't figure out how to convert what's in[/color][/color]
> there[color=green][color=darkred]
> > > to
> > > > > anything useful outside of access.
> > > > >
> > > > > Is there some way to read what's in there from a .net application?[/color][/color]
> I[color=green][color=darkred]
> > > > would
> > > > > be content with just being able to display the picture in an[/color]
> > application[color=darkred]
> > > > but
> > > > > really I would like a way to extract them from there and[/color][/color][/color]
converting[color=blue][color=green]
> > them[color=darkred]
> > > > to
> > > > > a real picture format. Can someone help me out with this dilemma
> > > please.
> > > > > Thanks.
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color] |