Page 1 of 1

TDBImage

Posted: Tue 21 Jan 2014 14:04
by Lacmane
Hi,
I am trying to insert/update an image on a table (postgres data base using column bytea). I am working with component TDBImage, but it gives me an error "stream read error", when I set the field name on this component.
What type of image should I save in a bytea column (bmp, jpg, gif, etc), and can I work with TDBImage component to display it?

If I save a bmp image and try to show it on TDBImage, it says Bitmap image is not valid.

I am working with builder XE3 (c++).

Thanks!
LL

Re: TDBImage

Posted: Wed 22 Jan 2014 08:51
by AlexP
Hello,

We cannot reproduce the problem. BMP images saved in the Bytea field are correctly displayed in the TDBImage. Please specify the exact version of PgDAC, and provide the code you are using for image insert/update.

Re: TDBImage

Posted: Wed 22 Jan 2014 09:02
by Lacmane
Hi,
pgdac version 3.6.12 for RAD Studio XE3

At the moment I only updating the images in the bytea field with a sql update.
update device_conf set image ='C:\\Users\\leandro\\Pictures\\Sites_converted.bmp';

If I do a select,
select * from device_conf;
result of the previous select,
C:\\Users\\leandro\\Pictures\\Sites_converted.bmp

Maybe this is my problem I am not saving the image properly in the data base.

Re: TDBImage

Posted: Wed 22 Jan 2014 09:14
by Lacmane
Hi,

I did the following ... and now I can see the image on the TDBImage

TPicture *Picture = new TPicture();
TOpenDialog *OpenDialog1 = new TOpenDialog(this);
OpenDialog1->Execute();
Picture->LoadFromFile(OpenDialog1->FileName);

DBImage1->Picture = Picture;

Re: TDBImage

Posted: Wed 22 Jan 2014 09:17
by AlexP
The query you provided will insert not an image, but the 'C:\\Users\\leandro\\Pictures\\Sites_converted.bmp' string to the image field. To insert an image, use parameters:

Code: Select all

PgQuery1.SQL.Text := 'update device_conf set image =:image';
PgQuery1.ParamByName('image').LoadFromFile('C:\\Users\\leandro\\Pictures\\Sites_converted.bmp',ftBlob);
PgQuery1.Execute;