 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Randel Bjorkquist Guest
|
Posted: Thu Jan 22, 2004 5:26 pm Post subject: Help with TDBImage control take 2 |
|
|
Hello all,
I tried posting this a couple months back and got ZERO responses. Is there
no-one that can help me?
----------------------------------------------------------------------------
---
Using a TDBImage control, I am having troubles viewing anything other then a
bitmap. My application can insert all different types of picture/image
files (JPG, BMP, TIFF, etc...) into the database. However when I retrieve
them, and yes my SQL statement does work, the TDBImage control will only
show the record images that are bitmaps. I have looked to see if the
TDBImage control only shows bitmaps or if I am missing some kind of
conversion. But I haven't seen those.
What am I missing? Any ideas?
Thanks for the help in advance,
Randel Bjorkquist
|
|
| Back to top |
|
 |
JD Guest
|
Posted: Thu Jan 22, 2004 9:59 pm Post subject: Re: Help with TDBImage control take 2 |
|
|
"Randel Bjorkquist" <rbjorkquist (AT) coilcraft (DOT) com> wrote:
| Quote: | [...] I have looked to see if the TDBImage control only
shows bitmaps or if I am missing some kind of conversion.
But I haven't seen those.
|
AFAIK, the TDBImage only displays bitmaps but it's not the end
of the world. The TDBImage::Assign method will convert the
image to a bitmap. The trick will be knowing what the image
type is so you know what type of object to load it into first.
You might need to add an extra field to the db to record what
kind of image it is or you might consider converting all of
the images to bitmaps before you save them to the database.
If you are going to have different type images, you might also
consider dropping the TDBImage and opting for a simple TImage.
The following sample (untested) converts a jpeg:
void __fastcall TForm1::Table1AfterScroll(TDataSet DataSet)
{
TMemoryStream* pStream = new TMemoryStream;
TJPEGImage* pImage = new TJPEGImage;
TBlobField(DataSet->Fieldbyname("myBlob"))->SaveToStream( pStream );
pStream->Seek( 0, soFromBeginning );
pImage->PixelFormat = jf24Bit;
pImage->Scale = jsFullSize;
pImage->Grayscale = False;
pImage->Performance = jpBestQuality;
pImage->ProgressiveDisplay = true;
pImage->ProgressiveEncoding = true;
pImage->LoadFromStream( pStream );
if( pStream->Size > 0 ) Image1->Picture->Assign( pImage );
else Image1->Picture->Assign( NULL );
delete pImage;
delete pStream;
}
~ JD
|
|
| Back to top |
|
 |
Randel Bjorkquist Guest
|
Posted: Fri Jan 23, 2004 5:15 pm Post subject: Re: Help with TDBImage control take 2 |
|
|
Thankd JD for the help. I have actually decided to try something else. I'm
going to try and use the windows file associations and use what the user has
set up to open any type of file. Don't know if that makes sense. But here
is what I'm think I'll try.
Get the BLOB and its' file name (including file extention) from the database
Save the BLOB into a temporary location, using the file name from the
database
Try to open the file as if the end-user was double-clicking on it.
I'm not sure how to do this. So any comments and or sugguestions will be
welcome.
Randel
"JD" <nospam (AT) nospam (DOT) com> wrote
| Quote: |
"Randel Bjorkquist" <rbjorkquist (AT) coilcraft (DOT) com> wrote:
[...] I have looked to see if the TDBImage control only
shows bitmaps or if I am missing some kind of conversion.
But I haven't seen those.
AFAIK, the TDBImage only displays bitmaps but it's not the end
of the world. The TDBImage::Assign method will convert the
image to a bitmap. The trick will be knowing what the image
type is so you know what type of object to load it into first.
You might need to add an extra field to the db to record what
kind of image it is or you might consider converting all of
the images to bitmaps before you save them to the database.
If you are going to have different type images, you might also
consider dropping the TDBImage and opting for a simple TImage.
The following sample (untested) converts a jpeg:
void __fastcall TForm1::Table1AfterScroll(TDataSet DataSet)
{
TMemoryStream* pStream = new TMemoryStream;
TJPEGImage* pImage = new TJPEGImage;
TBlobField(DataSet->Fieldbyname("myBlob"))->SaveToStream( pStream );
pStream->Seek( 0, soFromBeginning );
pImage->PixelFormat = jf24Bit;
pImage->Scale = jsFullSize;
pImage->Grayscale = False;
pImage->Performance = jpBestQuality;
pImage->ProgressiveDisplay = true;
pImage->ProgressiveEncoding = true;
pImage->LoadFromStream( pStream );
if( pStream->Size > 0 ) Image1->Picture->Assign( pImage );
else Image1->Picture->Assign( NULL );
delete pImage;
delete pStream;
}
~ JD
|
|
|
| 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
|
|