Extracting Bitmaps/Jpeg's/Gifs from Access

I have no problem using an ADO stream to insert small images into an Access table. These are not 'viewable' in Access, but can be streamed out with ADO, again no problem.  However, if I or (a user) manually inserts, say a BitMap, when written out to a file with ADO stream, a small 'header' is included which then makes the image unviewable.

; normal BMP file
424D0E28 00000000 00003600 00002800  BM·(······6···(·
00004200 00003300 00000100 18000000  ··B···3·········
0000D827 00000000 00000000 00000000  ··Ø'············
00000000 0000CC99 CCCCCCCC CCCCCCCC  ······Ì™ÌÌÌÌÌÌÌÌ

;  when manually input and streamed out from Access
151C2F00 02000000 0D000E00 14002100  ··/···········!·
FFFFFFFF 4269746D 61702049 6D616765  ÿÿÿÿBitmap Image
00506169 6E742E50 69637475 72650001  ·Paint.Picture··
05000002 00000007 00000050 42727573  ···········PBrus
68000000 00000000 00002028 0000424D  h········· (··BM
0E280000 00000000 36000000 28000000  ·(······6···(···
42000000 33000000 01001800 00000000  B···3···········

Is there anyway I can detect this header for all types of images, and if so are there any rules for stripping it off prior to writing the image out to a file? [I assume I could look for 424D as the first byte to denote a BMP, but that wouldn't work for a gif]

stan
stanlAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
ankuratvbConnect With a Mentor Commented:
Why dont you just insert the path of the images instead of the images?

I know this has its own complications with respect to distribution of the database.
but having worked with Access and suffered quite a lot,i'd never insert images into an access database which would make it bloat even more.

Access is renowned for corrupting quite frequently.Storing the paths would reduce the size of your database to quite an extent as well.
0
 
drnickCommented:
ok, guessing, no idea, could be rubbish:

can it be that you stored the image as an ole object?
in that case, the class name (Bitmap.Image?) and CLSI would be stored in the stream too.
the stream looks somehow like it was a compound document.
then, you may have to treat it like a compound document and extract the bitmap like it
was an object in such a document.
0
 
stanlAuthor Commented:
>>extract the bitmap like it
>>was an object in such a document.

which begs the question.  How?
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
waysideConnect With a Mentor Commented:
Every image type has some sort of magic bytes at the beginning to identify it:

bitmap -> BM
.gif -> GIF

etc. Maybe search for those to find the beginning.

Or maybe the bits of the image always start at the 78th byte as they do in the example you posted, do a little experimenting with different image types to see if that is the case.
0
 
drnickConnect With a Mentor Commented:
also a good idea.

to mine proposal:
 if i was right, you have it to do with a stream or storage.
 if so, you can store everything in a file, like you did,
 but then, try to open it with
  StgOpenStorage or StgOpenStorageEx.
if that works, you could use OpenStream to get the stream,
however, you've to guess the streams name.
0
 
Melih SARICAIT ManagerCommented:
First 4 bytes of every image has descrtiptor header..

like BMP. GIF. JFIF check these bytes

0
 
Melih SARICAConnect With a Mentor IT ManagerCommented:
and check this link for all formats

www.wotsit.org
0
 
stanlAuthor Commented:
you can delete the question -
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.