The picture example with jpegs?

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
kaffeburk
Posts: 214
Joined: Mon 29 Jan 2007 08:03

The picture example with jpegs?

Post by kaffeburk » Tue 17 Apr 2007 11:11

Is there any way to get JPEGS working with this?

mvalent
Posts: 62
Joined: Thu 04 Nov 2004 17:42

Post by mvalent » Tue 17 Apr 2007 12:44

You will go nowhere with a question like this... :-)

I mean, if you don't explain what you are doing you will not get any response...

kaffeburk
Posts: 214
Joined: Mon 29 Jan 2007 08:03

Post by kaffeburk » Tue 17 Apr 2007 14:17

Oki, as i understand it (now) DBimage (for delphi7) can not handle JPEG, thats probably why the demo have BMP pictures. But i found a freeware who did. A component called umDBImage. Works fine with MYDAC - only drawback i seen yet is that it cant handle som Jpeg formats like CONICA cameras and not gif, but everything jpg that photoshop creates works fine...

Perhaps include a data-aware picture component in mydac that can handle both JPEG and GIF? MySQL Developer Studio already can do this, so why not mydac to?

mvalent
Posts: 62
Joined: Thu 04 Nov 2004 17:42

Post by mvalent » Tue 17 Apr 2007 15:06

MyDac is handling binary fields.
Storing and retrieving pictures, sounds or else is your responsability. It has nothing to do with Database connection.

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Wed 18 Apr 2007 06:54

This problem was discussed in this thread. Also you can see the Delphi Jpeg demo.

kaffeburk
Posts: 214
Joined: Mon 29 Jan 2007 08:03

Post by kaffeburk » Wed 18 Apr 2007 10:21

Oki i get it, thanx. Just one question - the BlobField: TBlobField on the "Pictures" examle is never instansiated. Misstake or ?

procedure TPicturesFrame.btLoadClick(Sender: TObject);
var
BlobField: TBlobField; // ******
begin
{$IFNDEF LINUX}
with TOpenPictureDialog.Create(nil) do
{$ELSE}
with TOpenDialog.Create(nil) do
{$ENDIF}
try
InitialDir := '.\Pictures';
if Execute then begin
if quPictures.State in [dsBrowse] then
quPictures.Edit;
BlobField := quPictures.FieldByName('Picture') as TBlobField; ****
BlobField.LoadFromFile(FileName);
end;
finally
Free;
end;
end;

kaffeburk
Posts: 214
Joined: Mon 29 Jan 2007 08:03

Post by kaffeburk » Wed 18 Apr 2007 10:24

Its a pointer.... Sorry...

kaffeburk
Posts: 214
Joined: Mon 29 Jan 2007 08:03

Post by kaffeburk » Thu 19 Apr 2007 03:17

Where cani find this JPEG example? Its not in mydac 5, and i dont want to uninstall mydac 5, and install mydac 4 just to get that example, and then reinstall mydac 5. Perhaps put the demos as a separate download?

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Thu 19 Apr 2007 13:15

I mean the example that comes with Delphi 7. It is located in this directory: %Delphi7%\Help\Examples\Jpeg\

kaffeburk
Posts: 214
Joined: Mon 29 Jan 2007 08:03

Post by kaffeburk » Thu 19 Apr 2007 17:57

Thanx, i found it. Did have some trouble because all examples loaded from a file, and i wanted to get it straight out of mydac. I used a TmemoryStream, witch behaves different if load from file or load from a Tblobfield. In the first case pos of stream is 0 and in the later and end of stream. When i put pos to 0 it worked. Then i found out i not need a stream at all. Now it works.

procedure TForm1.ShowBlob;
var
jpg : TJpegImage;
blob : Tblobfield;

begin

blob := MyQuery1.FieldByName('Picture') as TBlobField;
if blob.BlobSize>0 then
begin

jpg:= TJpegImage.Create;
jpg.Assign(blob);
image1.Picture.Graphic:=jpg;

jpg.Free;
jpg:=nil;

end //of showing blob
else image1.Picture.Graphic:=nil; // no picture - clear the Timage

end;

Then i call "ShowBlob" from TmyQuerys after scroll event, and also when i load the image. I must use Timage, DBimage cant handle Jpeg and the freeware umDBimage cant handle more than a few JPEG versions.

Post Reply