Forum > Databases

DBImage: how to use?

(1/7) > >>

BigChimp:
Going by the Delphi and Lazarus edit: help, dbimage should be really easy to use: set datasource, set the field name to the field containing your image blob and it should display images stored there (and at least in Delphi, allow you to copy/paste image data).

I've modified a tutorial db (which had a dbgrid, navigator control etc): added dbimage control, did the above. Had to modify Firebird employee.fdb sample db to add a PHOTO field (blob) = please find it included in the zip.

However, I don't see any indication of an image (my db has mostly empty data).
What am I doing wrong?

Zip with source and database:
Edit: updated, see below.

Thanks.

wp:
Never tried it with Lazarus, but Delphi suffered from the fact that DBImage could only handle bmp files.

taazz:
It should work, teh code is there and is called when the current record is changed the only thing I see is that the stream lacks the image description so the LoadPicture method does not know how to handle the blob and it simple ignores it.

I remember a debate earlier this year of why the current implementation was incompatibilite with the rest of the world and a bug report with a patch was introduced to remove the extra bytes at the start. I guess this is the after effect. I still am against removing them.

BigChimp:
Thanks for the response, taazz!

That patch *added* support for Delphi style/custom image handling (see OnDBImageWrite, IIRC). It didn't change default behaviour. By default, IIUC, dbimage should still write the file extension etc.
see
http://wiki.lazarus.freepascal.org/Lazarus_1.2.0_release_notes#TDBImage


What should happen though with NULL values for the PHOTO field (i.e. empty blobs) Shouldn't I see some square/image placeholder where I can paste my picture?

Also, I don't really understand this part:

--- Quote from: taazz --- the only thing I see is that the stream lacks the image description so the LoadPicture method does not know how to handle the blob and it simple ignores it.

--- End quote ---
... should I add some code somewhere? Isn't dbimage supposed to do this for me (copy out file extension to the blob followed by the binary image)?

taazz:
DBImage should save the blob as
4 bytes extension length (usualy 3 or 4) |extension (eg bmp or jpg)| the image unaltered.

Your blob stream has no bmp in front as it should or I couldn't see it from IBExpert light.
DBImage has no mouse capabilities you need to add code to do so your self and no it never shown a rectangle which you could click to load data from disk.

Navigation

[0] Message Index

[#] Next page

Go to full version