Solved

Extracting Bitmaps/Jpeg's/Gifs from Access

Posted on 2004-04-20
10
636 Views
Last Modified: 2012-08-13
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
0
Comment
Question by:stanl
  • 2
  • 2
  • 2
  • +2
10 Comments
 
LVL 5

Expert Comment

by:drnick
Comment Utility
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
 

Author Comment

by:stanl
Comment Utility
>>extract the bitmap like it
>>was an object in such a document.

which begs the question.  How?
0
 
LVL 9

Accepted Solution

by:
ankuratvb earned 125 total points
Comment Utility
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
 
LVL 14

Assisted Solution

by:wayside
wayside earned 125 total points
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 5

Assisted Solution

by:drnick
drnick earned 125 total points
Comment Utility
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
 
LVL 19

Expert Comment

by:Melih SARICA
Comment Utility
First 4 bytes of every image has descrtiptor header..

like BMP. GIF. JFIF check these bytes

0
 
LVL 19

Assisted Solution

by:Melih SARICA
Melih SARICA earned 125 total points
Comment Utility
and check this link for all formats

www.wotsit.org
0
 

Author Comment

by:stanl
Comment Utility
you can delete the question -
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
This article will show, step by step, how to integrate R code into a R Sweave document
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This video teaches viewers about errors in exception handling.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now