Removing Access Object Headers

Results 1 to 2 of 2

Thread: Removing Access Object Headers

  1. #1
    Join Date
    Dec 1969

    Default Removing Access Object Headers

    I was trying to display an image from an access database stored as a object using the binary.write command with no luck. It appears that access stores a header of some sort that prevents objects from simply being displayed as is. My friend has written a component (which is great but one that I cannot use due to shared server requirements) as follows:<BR><BR>Function DisplayBLOB(ByVal OleField As Variant)<BR> Dim Arr() As Byte<BR> Dim ObjHeader As OBJECTHEADER<BR> Dim Buffer As String<BR> Dim ObjectOffset As Long<BR> Dim BitmapOffset As Long<BR> Dim BitmapHeaderOffset As Integer<BR> Dim ArrBmp() As Byte<BR> Dim i As Long<BR> <BR> &#039; Resize the array, then fill it with the entire contents of the field<BR> ReDim Arr(OleField.ActualSize)<BR> Arr() = OleField.GetChunk(OleField.ActualSize)<BR> <BR> &#039; Copy the first 19 bytes into a variable of the OBJECTHEADER user defined type<BR> CopyMemory ObjHeader, Arr(0), 19<BR> <BR> &#039; Determine where the Access Header ends<BR> ObjectOffset = ObjHeader.HeaderSize + 1<BR> <BR> &#039; Grab enough bytes after the OLE header to get the bitmap header<BR> Buffer = ""<BR><BR> For i = ObjectOffset To ObjectOffset + 512<BR> Buffer = Buffer & Chr(Arr(i))<BR> Next<BR> <BR> If InStr(Buffer, "PBrush") &#062; 0 Then<BR> BitmapHeaderOffset = InStr(Buffer, "BM")<BR> ElseIf InStr(Buffer, "SoundRec") &#062; 0 Then<BR> BitmapHeaderOffset = InStr(Buffer, "RIFF")<BR> End If<BR> <BR> If BitmapHeaderOffset &#062; 0 Then<BR> &#039; Calculate the beginning of the bitmap<BR> BitmapOffset = ObjectOffset + BitmapHeaderOffset - 1<BR> <BR> &#039; Move the bitmap into its own array<BR> ReDim ArrBmp(UBound(Arr) - BitmapOffset)<BR> CopyMemory ArrBmp(0), Arr(BitmapOffset), UBound(Arr) - BitmapOffset + 1<BR><BR> &#039; Return the bitmap<BR> DisplayBLOB = ArrBmp<BR> Else<BR> DisplayBLOB = "Error"<BR> End If<BR>End Function<BR><BR>Can this function be converted into a asp friendly funcion so that I can use it on the page?<BR><BR>Thanks in advance everybody

  2. #2
    Join Date
    Dec 1969

    Default Been asked many many times...

    ...though admittedly not in exactly the way you did.<BR><BR>The usual answer here is DON&#039;T DO IT!<BR><BR>Put your images in files; put the file *names* in the DB.<BR><BR>But have you SEARCHED past postings in these forums? Especially the DB forum?<BR><BR>I found this posting, for example, almost instantly:<BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts