Solved

Extracting Bitmaps/Jpeg's/Gifs from Access

Posted on 2004-04-20
10
652 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
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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
countXY challenge 28 146
gHappy challenge 67 118
withoutTen challenge 14 99
Problem to open text file 11 73
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

910 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

17 Experts available now in Live!

Get 1:1 Help Now