TDBImage

Discussion of open issues, suggestions and bugs regarding PgDAC (PostgreSQL Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Lacmane
Posts: 5
Joined: Thu 30 Aug 2012 08:47

TDBImage

Post by Lacmane » Tue 21 Jan 2014 14:04

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

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: TDBImage

Post by AlexP » Wed 22 Jan 2014 08:51

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.

Lacmane
Posts: 5
Joined: Thu 30 Aug 2012 08:47

Re: TDBImage

Post by Lacmane » Wed 22 Jan 2014 09:02

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.

Lacmane
Posts: 5
Joined: Thu 30 Aug 2012 08:47

Re: TDBImage

Post by Lacmane » Wed 22 Jan 2014 09:14

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;
Last edited by Lacmane on Wed 22 Jan 2014 09:20, edited 1 time in total.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: TDBImage

Post by AlexP » Wed 22 Jan 2014 09:17

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;

Post Reply