Solved

Extracting Bitmaps/Jpeg's/Gifs from Access

Posted on 2004-04-20
10
692 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +2
10 Comments
 
LVL 5

Expert Comment

by:drnick
ID: 10875547
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
ID: 10876484
>>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
ID: 10877917
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Assisted Solution

by:wayside
wayside earned 125 total points
ID: 10878521
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
 
LVL 5

Assisted Solution

by:drnick
drnick earned 125 total points
ID: 10881529
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
ID: 10887860
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
ID: 10887876
and check this link for all formats

www.wotsit.org
0
 

Author Comment

by:stanl
ID: 11080571
you can delete the question -
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

739 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