 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Phill Guest
|
Posted: Thu Feb 05, 2004 11:13 am Post subject: How to know blob content |
|
|
Hi folks!
Could you help me?
I have a blob filed in an Oracle database.
Here it can be stored images (bmp, jpg, gif).
I want to make it possible to preview those images in a TImage control.
I can display any image, but only if I know it's file type. How could I test
the filetype of the image? I'll use an AfterScroll event, but I must know what
format is there so I could execute the display statement for that file type.
Thank you,
Eugen
|
|
| Back to top |
|
 |
Dodgy Guest
|
Posted: Thu Feb 05, 2004 11:43 am Post subject: Re: How to know blob content |
|
|
On 5 Feb 2004 03:13:14 -0800, [email]notyetguru (AT) yahoo (DOT) com[/email] (Phill) waffled on
about something:
| Quote: | Hi folks!
Could you help me?
I have a blob filed in an Oracle database.
Here it can be stored images (bmp, jpg, gif).
I want to make it possible to preview those images in a TImage control.
I can display any image, but only if I know it's file type. How could I test
the filetype of the image? I'll use an AfterScroll event, but I must know what
format is there so I could execute the display statement for that file type.
Thank you,
Eugen
|
Two methods...
1) Add a database field to indicate the different types.
2) Check the header information at the start of the Blob data.
A Jpeg will contain "JFIF" Starting 6 chars in from the start...
A BMP will start "BM" from offset 0
A GIF will start "GIF" from offset 0
Full specs of the files can be found via http://www.wotsit.org/
So basically you'll need to read the blob field into a memory stream
or something like that, then check the beginning of the data before
feeding that stream into your image routine.
Hope this helps,
Dodgy.
--
MUSHROOMS ARE THE OPIATE OF THE MOOSES
|
|
| Back to top |
|
 |
Phill Guest
|
Posted: Thu Feb 05, 2004 3:05 pm Post subject: Re: How to know blob content |
|
|
Thank you Dodgy!
It works perfect. I've chosed the second method, because I didn't want
another field in the database.
Dodgy <Dodgy (AT) earth (DOT) planet.universe> wrote
| Quote: | On 5 Feb 2004 03:13:14 -0800, [email]notyetguru (AT) yahoo (DOT) com[/email] (Phill) waffled on
about something:
Hi folks!
Could you help me?
I have a blob filed in an Oracle database.
Here it can be stored images (bmp, jpg, gif).
I want to make it possible to preview those images in a TImage control.
I can display any image, but only if I know it's file type. How could I test
the filetype of the image? I'll use an AfterScroll event, but I must know what
format is there so I could execute the display statement for that file type.
Thank you,
Eugen
Two methods...
1) Add a database field to indicate the different types.
2) Check the header information at the start of the Blob data.
A Jpeg will contain "JFIF" Starting 6 chars in from the start...
A BMP will start "BM" from offset 0
A GIF will start "GIF" from offset 0
Full specs of the files can be found via http://www.wotsit.org/
So basically you'll need to read the blob field into a memory stream
or something like that, then check the beginning of the data before
feeding that stream into your image routine.
Hope this helps,
Dodgy.
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|