Page 1 of 1

The picture example with jpegs?

Posted: Tue 17 Apr 2007 11:11
by kaffeburk
Is there any way to get JPEGS working with this?

Posted: Tue 17 Apr 2007 12:44
by mvalent
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...

Posted: Tue 17 Apr 2007 14:17
by kaffeburk
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?

Posted: Tue 17 Apr 2007 15:06
by mvalent
MyDac is handling binary fields.
Storing and retrieving pictures, sounds or else is your responsability. It has nothing to do with Database connection.

Posted: Wed 18 Apr 2007 06:54
by Antaeus
This problem was discussed in this thread. Also you can see the Delphi Jpeg demo.

Posted: Wed 18 Apr 2007 10:21
by kaffeburk
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;

Posted: Wed 18 Apr 2007 10:24
by kaffeburk
Its a pointer.... Sorry...

Posted: Thu 19 Apr 2007 03:17
by kaffeburk
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?

Posted: Thu 19 Apr 2007 13:15
by Antaeus
I mean the example that comes with Delphi 7. It is located in this directory: %Delphi7%\Help\Examples\Jpeg\

Posted: Thu 19 Apr 2007 17:57
by kaffeburk
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.