Recent

Author Topic: [SOLVED] TDbf table, Level 7 with a graphic field  (Read 4810 times)

1HuntnMan

  • Full Member
  • ***
  • Posts: 194
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
[SOLVED] TDbf table, Level 7 with a graphic field
« on: April 13, 2024, 10:14:19 pm »
I have one form in an app I'm designing for Photos.  Each record to store a bit of info. for the photo, i.e. Photo ID, Location, File Name, Date Taken, etc. My last field, Field Name = PHOTO, Type = Graphic.

I can't seem to finish the form enough to test because can't seem to figure the correct way to put this field on a form.  I put a TDBImage component on the form, sized it, defined the DataSource, Field Name=PHOTO but just to test, running it Laz errors with a Debugger Exception, see attached. But, I can run the application.exe just fine but the field isn't on the form.

The run exception occurs in dbimage.inc in the procedure ReadImageHeader;

Am I approaching this wrong, is there a better way?
Tks in advance...
« Last Edit: April 17, 2024, 10:35:54 pm by 1HuntnMan »

wp

  • Hero Member
  • *****
  • Posts: 11986
Re: TDbf table, Level 7 with a graphic field
« Reply #1 on: April 14, 2024, 01:28:05 am »
Not 100% sure, but I think TDbf does not support ftGraphic fields. I played a bit with it, and could not get a good result. But you can use a ftBlob field which is able to read and write arbitrary data. As a consequence, on the other hand, you cannot use a TDBImage to display the picture - but with a few lines of code you can display the BLOB in a standard TImage.

I wrote the attached demo program which creates a dbf file and stores some images of any registered format in it. The code is a bit more complex because I do not like editing directly inside the grid and added a second form for editing the records. And all database-related routines are moved into a separate datamodule. I hope that it's not too complicated...

A warning should be given, though: storing images directly inside databases generally is not a recommended technique because the database will become very large. Since huge images make any buffering obsolete, access to the database finally will become rather slow. I would recommend to copy the images in the file system to a folder next to the database files and store only the relative path to the images in the dbf.
« Last Edit: April 14, 2024, 01:30:40 am by wp »

Zvoni

  • Hero Member
  • *****
  • Posts: 2362
Re: TDbf table, Level 7 with a graphic field
« Reply #2 on: April 15, 2024, 08:39:27 am »
I see a column namend "File Name"
Is TS storing the Photo as a Blob, or just the Filename pointing to the JPG/PNG on the Hard-Drive?
Because if the latter, then TDBIMage is the wrong Control, since the Image-Data is not part of the Recordset
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

wp

  • Hero Member
  • *****
  • Posts: 11986
Re: TDbf table, Level 7 with a graphic field
« Reply #3 on: April 15, 2024, 10:33:43 am »
The TS mentions in his first post a field "PHOTO, type = Graphic". Therefore, I assumed that this refers to images stored inside the database when I wrote my sample (although I would not recommend that in general).

Thaddy

  • Hero Member
  • *****
  • Posts: 14560
  • Sensorship about opinions does not belong here.
Re: TDbf table, Level 7 with a graphic field
« Reply #4 on: April 15, 2024, 11:01:41 am »
There is no reason why you could not store the photo as a blob in dB7.
That means there is an error in your code.
What I think you mean is to store the EXIF information of a picture separated from the actual picture.

When you need to extract that before storing into string fields. The picture itself can be stored as a blob, or as suggested, with a file path (which I would not do)

But we simply need to see how you try to store and read the images. As usual you do not give enough information. (also note that any of the dBASE formats are usually a bad choice for new code, although I personally like it because I worked so much with it over the past 40 years or so, that is not a valid reason to actually use it, though)
« Last Edit: April 15, 2024, 12:25:07 pm by Thaddy »
bitrate is always calculated like this:sample rate * bitdepth * number of channels.

1HuntnMan

  • Full Member
  • ***
  • Posts: 194
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: TDbf table, Level 7 with a graphic field
« Reply #5 on: April 17, 2024, 10:03:16 pm »
You're all correct. In fact, I was thinking wrong. There is not reason to store the actual photo because the form is just an inventory. Was thinking earlier they would like it. Photographer's take really large digital photos. Each one can be megs in size. I was thinking a small jpg.  But, the name of the file is all they need because they are inventorying their photography anyway, esp. if they are using Lightroom.

I'm back on track, thanks all...

 

TinyPortal © 2005-2018