I´m trying to storage a JPEG image in a blob field but it generate an
exception. WIth bitmaps this works OK. I´m using Delphi 5 Enterprise with
IBX. Anybody can help me?
--
Edward Fernandes
Diretor Técnico
AUSLAND Intellicom Technologies
(41) 377-2730
http://www.intellicom.com.br/
http://www.ausland.com.br/
I惴 already using a correct component (TGrahic descendent). The question is
why my post doesn愒 write the image to blob field on InterBase. When try to
post, gives me an exception.
"John Jacobson" <joh...@xnet.com> escreveu na mensagem
news:3b12810e$2_2@dnews...
> Your problems have nothing to do with IBX if you can store a bitmap OK.
You
> might want to check to see if JPEG is registered as an image type for the
> TImage control, if you are using one of those. I am storing JPEG's in an
> Interbase database and I found that I had to track what type of graphic it
> was so I could create the proper TGraphic descendent when trying to get
the
> JPEG out of the database and show it.
>
> "Edward Fernandes - Intellicom" <edw...@intellicom.com.br> wrote in
message
> news:3b127b22_1@dnews...
> > Hello All
> >
> > I惴 trying to storage a JPEG image in a blob field but it generate an
> > exception. WIth bitmaps this works OK. I惴 using Delphi 5 Enterprise
"Edward Fernandes - Intellicom" <edw...@intellicom.com.br> wrote in message
news:3b127b22_1@dnews...
What is the exception?
--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
Anyone who cannot cope with mathematics is not fully human.
At best he is a tolerable subhuman who has learned to wear
shoes, bathe and not make messes in the house. (Heinlein)
if OpenPictureDialog1.Execute then
DBJPEGImage1.Picture.LoadFromFile(OpenPictureDialog1.FileName);
the image is corretly view in the screen but when i try to post, ocurrs an
exception:
Invalid Class TypeCast
"Jeff Overcash (TeamB)" <over...@onramp.net> escreveu na mensagem
news:3B128BF4...@onramp.net...
Tanks
"Jeff Overcash (TeamB)" <over...@onramp.net> escreveu na mensagem
news:3B128BF4...@onramp.net...
> Edward Fernandes - Intellicom wrote:
> >
> > Hello
> >
> > I´m already using a correct component (TGrahic descendent). The question
is
> > why my post doesn´t write the image to blob field on InterBase. When try
the error ocurrs in this type cast on DBTable unit:
FDataSet := FField.DataSet as TBDEDataSet;
tanks
"Jeff Overcash (TeamB)" <over...@onramp.net> escreveu na mensagem
news:3B128BF4...@onramp.net...
Edward Fernandes - Intellicom wrote:
>
> My code is:
>
> if OpenPictureDialog1.Execute then
> DBJPEGImage1.Picture.LoadFromFile(OpenPictureDialog1.FileName);
>
> the image is corretly view in the screen but when i try to post, ocurrs an
> exception:
>
> Invalid Class TypeCast
>
That exception is not raised by IBX. IBBlobStream does no dirty typecasts.
This means the error is in the component you are using. IBX has absolutely no
knowledge of graphic formats. Blobs are just streams to IBX and that is it. It
doesn't know the difference between bmp, jpeg, gif or rtf, doc, xls or any other
stream you want to save in IB Blob fields. It is up to you or the component to
correctly identify the Blob type and correctly convert it.
Here is a C++ example of retrieving and storing JPegs to and from a TImage
component.
void __fastcall TForm1::IBDataSet1AfterScroll(TDataSet *DataSet)
{
if (DataSet->State == dsInsert)
return;
TJPEGImage *j = new TJPEGImage();
TMemoryStream *m = new TMemoryStream();
try
{
IBDataSet1T1->SaveToStream(m);
m->Position = 0;
j->LoadFromStream(m);
Image1->Picture->Graphic = j;
}
__finally
{
delete j;
delete m;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::IBDataSet1BeforePost(TDataSet *DataSet)
{
TMemoryStream *m = new TMemoryStream();
try
{
Image1->Picture->Graphic->SaveToStream(m);
m->Position = 0;
IBDataSet1T1->LoadFromStream(m);
}
__finally
{
delete m;
}
}
T1 is the Blob field in the DB and I persisted the fields so IBDataSet1T1 is the
BlobField for the table.
Tanks, the code is working, but in Delphi.
To load de JPEG Image:
procedure TForm1.CarregarImagem1Click(Sender: TObject);
begin
if OpenPictureDialog1.Execute then
Image1.Picture.LoadFromFile(OpenPictureDialog1.FileName);
end;
To save jpeg to a blob field in interbase:
procedure TForm1.BitBtn1Click(Sender: TObject);
var
M:TMemoryStream;
begin
M:=TMemoryStream.Create;
try
Image1.Picture.Graphic.SaveToStream(m);
m.Position := 0;
IBTable1IMAGEM.LoadFromStream(m);
IBTable1.Post;
finally
m.free;
end;
end;
to display image on the screen:
procedure TForm1.IBTable1AfterScroll(DataSet: TDataSet);
var
M:TMemoryStream;
J:TJpegImage;
begin
if (DataSet.State=dsInsert) then
exit;
try
J:=TJpegimage.Create;
M:=TMemoryStream.Create;
IBTable1IMAGEM.SaveToStream(m);
m.position:=0;
j.loadfromstream(m);
Image1.Picture.Graphic := j;
finally
J.Free;
m.Free;
end;
end;
"Jeff Overcash (TeamB)" <over...@onramp.net> escreveu na mensagem
news:3B129916...@onramp.net...
file://---------------------------------------------------------------------
IBX does not use DBTables at all. This is coming from somewhere else
in your app. Again, there is no use of DBTables anywhere in IBX.
-Craig
--
Craig Stuntz (TeamB) Senior Developer, Vertex Systems Corp.
Delphi/InterBase weblog: http://delphi.weblogs.com
Use Borland servers; posts via others are not seen by TeamB.
For more info, see http://www.borland.com/newsgroups/genl_faqs.html