Board index » delphi » Problems inserting a JPEG file to a Blob field

Problems inserting a JPEG file to a Blob field

    Hi folks, how are you doing ?

    I created a simple InterBase table as the following metadata:

CREATE TABLE "PICTURES"
(
  "CODE" INTEGER NOT NULL,
  "NAME" VARCHAR(50),
  "PHOTO" BLOB SUB_TYPE 0 SEGMENT SIZE 512,
 PRIMARY KEY ("CODE")
);

    Im using a dialect 3 database, so I made a very simple application on
Delphi, using IBX, a DBEdit component (to the NAME field) and a DBImage (to
the PHOTO field). I used this code to assign the a picture file to the
DBImage, using an OpenDialog:

  if OpenDialog1.Execute then
    DBImage1.Picture.LoadFromFile(OpenDialog1.FileName);

    After this code the picture appears corretly on the DBImage component,
no matter if its a BMP, ICO, JPEG or WMF picture. When I post the record
the problem occurs. If the image file is a bitmap (".bmp") or Icon (".ico"),
the application works as expected, storing the picture and the name to the
database, but if I assign an JPEG image file (".jpg" or ".jpeg"), when I
post the record the picture desapears and no picture is stored to the
database, only the NAME field is stored.
    Ive already search the community web site for a document explaining how
to do this, I found out that its possible to store a jpeg picture to the
database, but I couldnt find out how to do this.

    Id appreciate any help or tip you can give me!

    Since now, thanks very much.

Mauricio Desiderio Filho

 

Re:Problems inserting a JPEG file to a Blob field


Quote
Desiderio wrote:

>     After this code the picture appears corretly on the DBImage component,
> no matter if its a BMP, ICO, JPEG or WMF picture. When I post the record
> the problem occurs. If the image file is a bitmap (".bmp") or Icon (".ico"),
> the application works as expected, storing the picture and the name to the
> database, but if I assign an JPEG image file (".jpg" or ".jpeg"), when I
> post the record the picture desapears and no picture is stored to the
> database, only the NAME field is stored.
>     Ive already search the community web site for a document explaining how
> to do this, I found out that its possible to store a jpeg picture to the
> database, but I couldnt find out how to do this.

DBImage is designed to only work with Bitmaps to and from a database.  The
TPicture that handles the underlying display of the image can handle JPegs, but
the DBImage will have problems with working through datasources saving and
retrieving anything but Bitmaps or icons.

You will either have to find a third party component that handles other image
types, or dump the DBImage and use a normal TImage and read and write the Blob
to it.

--
Jeff Overcash (TeamB)   I don't think there are any Russians
(Please do not email    And there ain't no Yanks
 me directly unless     Just corporate criminals
 asked.  Thank You)     Playing with tanks.  (Michael Been)

Re:Problems inserting a JPEG file to a Blob field


DBImage can manage other format than bmp.

--
Sergio Samayoa
Lgica Software
http://www.geocities.com/logicasw/

"Desiderio" <ncc170...@ig.com.br> escribi en el mensaje
news:3b3e1245_1@dnews...

Quote
>     Hi folks, how are you doing ?

>     I created a simple InterBase table as the following metadata:

> CREATE TABLE "PICTURES"
> (
>   "CODE" INTEGER NOT NULL,
>   "NAME" VARCHAR(50),
>   "PHOTO" BLOB SUB_TYPE 0 SEGMENT SIZE 512,
>  PRIMARY KEY ("CODE")
> );

>     Im using a dialect 3 database, so I made a very simple application on
> Delphi, using IBX, a DBEdit component (to the NAME field) and a DBImage
(to
> the PHOTO field). I used this code to assign the a picture file to the
> DBImage, using an OpenDialog:

>   if OpenDialog1.Execute then
>     DBImage1.Picture.LoadFromFile(OpenDialog1.FileName);

>     After this code the picture appears corretly on the DBImage component,
> no matter if its a BMP, ICO, JPEG or WMF picture. When I post the record
> the problem occurs. If the image file is a bitmap (".bmp") or Icon
(".ico"),
> the application works as expected, storing the picture and the name to the
> database, but if I assign an JPEG image file (".jpg" or ".jpeg"), when I
> post the record the picture desapears and no picture is stored to the
> database, only the NAME field is stored.
>     Ive already search the community web site for a document explaining
how
> to do this, I found out that its possible to store a jpeg picture to the
> database, but I couldnt find out how to do this.

>     Id appreciate any help or tip you can give me!

>     Since now, thanks very much.

> Mauricio Desiderio Filho

Re:Problems inserting a JPEG file to a Blob field


Sorry, is can't.

--
Sergio Samayoa
Lgica Software
http://www.geocities.com/logicasw/

"Sergio Samayoa" <serg...@terra.com.gt> escribi en el mensaje
news:3b3e25c7_1@dnews...

Quote
> DBImage can manage other format than bmp.

> --
> Sergio Samayoa
> Lgica Software
> http://www.geocities.com/logicasw/

> "Desiderio" <ncc170...@ig.com.br> escribi en el mensaje
> news:3b3e1245_1@dnews...
> >     Hi folks, how are you doing ?

> >     I created a simple InterBase table as the following metadata:

> > CREATE TABLE "PICTURES"
> > (
> >   "CODE" INTEGER NOT NULL,
> >   "NAME" VARCHAR(50),
> >   "PHOTO" BLOB SUB_TYPE 0 SEGMENT SIZE 512,
> >  PRIMARY KEY ("CODE")
> > );

> >     Im using a dialect 3 database, so I made a very simple application
on
> > Delphi, using IBX, a DBEdit component (to the NAME field) and a DBImage
> (to
> > the PHOTO field). I used this code to assign the a picture file to the
> > DBImage, using an OpenDialog:

> >   if OpenDialog1.Execute then
> >     DBImage1.Picture.LoadFromFile(OpenDialog1.FileName);

> >     After this code the picture appears corretly on the DBImage
component,
> > no matter if its a BMP, ICO, JPEG or WMF picture. When I post the
record
> > the problem occurs. If the image file is a bitmap (".bmp") or Icon
> (".ico"),
> > the application works as expected, storing the picture and the name to
the
> > database, but if I assign an JPEG image file (".jpg" or ".jpeg"), when I
> > post the record the picture desapears and no picture is stored to the
> > database, only the NAME field is stored.
> >     Ive already search the community web site for a document explaining
> how
> > to do this, I found out that its possible to store a jpeg picture to
the
> > database, but I couldnt find out how to do this.

> >     Id appreciate any help or tip you can give me!

> >     Since now, thanks very much.

> > Mauricio Desiderio Filho

Re:Problems inserting a JPEG file to a Blob field


Thanks for the idea, I undertood and will try the TImage!

"Jeff Overcash (TeamB)" <overc...@onramp.net> escreveu na mensagem
news:3B3E24D3.D3C8B453@onramp.net...

Quote

> Desiderio wrote:

> >     After this code the picture appears corretly on the DBImage
component,
> > no matter if its a BMP, ICO, JPEG or WMF picture. When I post the
record
> > the problem occurs. If the image file is a bitmap (".bmp") or Icon
(".ico"),
> > the application works as expected, storing the picture and the name to
the
> > database, but if I assign an JPEG image file (".jpg" or ".jpeg"), when I
> > post the record the picture desapears and no picture is stored to the
> > database, only the NAME field is stored.
> >     Ive already search the community web site for a document explaining
how
> > to do this, I found out that its possible to store a jpeg picture to
the
> > database, but I couldnt find out how to do this.

> DBImage is designed to only work with Bitmaps to and from a database.  The
> TPicture that handles the underlying display of the image can handle
JPegs, but
> the DBImage will have problems with working through datasources saving and
> retrieving anything but Bitmaps or icons.

> You will either have to find a third party component that handles other
image
> types, or dump the DBImage and use a normal TImage and read and write the
Blob
> to it.

> --
> Jeff Overcash (TeamB)   I don't think there are any Russians
> (Please do not email    And there ain't no Yanks
>  me directly unless     Just corporate criminals
>  asked.  Thank You)     Playing with tanks.  (Michael Been)

Re:Problems inserting a JPEG file to a Blob field


thanks for the attention.
"Sergio Samayoa" <serg...@terra.com.gt> escreveu na mensagem
news:3b3e8072_2@dnews...
Quote
> Sorry, is can't.

> --
> Sergio Samayoa
> Lgica Software
> http://www.geocities.com/logicasw/

> "Sergio Samayoa" <serg...@terra.com.gt> escribi en el mensaje
> news:3b3e25c7_1@dnews...
> > DBImage can manage other format than bmp.

> > --
> > Sergio Samayoa
> > Lgica Software
> > http://www.geocities.com/logicasw/

> > "Desiderio" <ncc170...@ig.com.br> escribi en el mensaje
> > news:3b3e1245_1@dnews...
> > >     Hi folks, how are you doing ?

> > >     I created a simple InterBase table as the following metadata:

> > > CREATE TABLE "PICTURES"
> > > (
> > >   "CODE" INTEGER NOT NULL,
> > >   "NAME" VARCHAR(50),
> > >   "PHOTO" BLOB SUB_TYPE 0 SEGMENT SIZE 512,
> > >  PRIMARY KEY ("CODE")
> > > );

> > >     Im using a dialect 3 database, so I made a very simple
application
> on
> > > Delphi, using IBX, a DBEdit component (to the NAME field) and a
DBImage
> > (to
> > > the PHOTO field). I used this code to assign the a picture file to the
> > > DBImage, using an OpenDialog:

> > >   if OpenDialog1.Execute then
> > >     DBImage1.Picture.LoadFromFile(OpenDialog1.FileName);

> > >     After this code the picture appears corretly on the DBImage
> component,
> > > no matter if its a BMP, ICO, JPEG or WMF picture. When I post the
> record
> > > the problem occurs. If the image file is a bitmap (".bmp") or Icon
> > (".ico"),
> > > the application works as expected, storing the picture and the name to
> the
> > > database, but if I assign an JPEG image file (".jpg" or ".jpeg"), when
I
> > > post the record the picture desapears and no picture is stored to the
> > > database, only the NAME field is stored.
> > >     Ive already search the community web site for a document
explaining
> > how
> > > to do this, I found out that its possible to store a jpeg picture to
> the
> > > database, but I couldnt find out how to do this.

> > >     Id appreciate any help or tip you can give me!

> > >     Since now, thanks very much.

> > > Mauricio Desiderio Filho

Other Threads