Board index » delphi » JPG-Pictures save into PDOX7-Table

JPG-Pictures save into PDOX7-Table

Hi all,

last month I have found to this theme an entry in this Newsgroup:

(Tbl.FieldByName('jpegblob') as
TblobField).LoadFormFile(OpenDialog1.Filename);

I tried this with Table-Fieldtypes of  'Graphic' and also with 'Binary'.
The Object in Form1 is TDBImage. (D5-Pro and Pdox7-Table)

For all JPG-Files I see this Error-Message (in German)
'Unbekannte Bilddateierweiterung (.JPG)'

Sourcecode:
procedure TForm1.Button1Click(Sender: TObject);
begin
  with Prod do begin
    if OpenPictureDialog1.execute then begin
      edit;
      try
        (FieldByName('BBild') as
TBlobField).LoadFromFile(OpenPictureDialog1.Filename);
        post;
      except on E: Exception do
          ShowMessage(E.Message);
      end;
    end;
  end;
end;

How can I read in JPG-Files?
What's wrong in this code?
Can anybody help me?

Best Regards
Kurt

 

Re:JPG-Pictures save into PDOX7-Table


Use a binary field.

To save a file to a blob see the TblobField.loadfromFile method

I'm using the following code suggested (slightly modified) by
Brian (TeamB) to display JPG's  in a TImage:

procedure TFloorPlan.TablePHMODELSAfterScroll(DataSet: TDataSet);
var
  MS: TMemoryStream;
  J1: TJPEGImage;
begin
  if Datafield.isnull then exit;
  J1 := TJPEGImage.Create;
  MS := TMemoryStream.Create;
  try
    TBlobField(DataSet.Fieldbyname('Jpeg')).SaveToStream(MS);
    MS.Seek(0, soFromBeginning);
    with J1 do begin
      PixelFormat := jf24Bit;
      Scale := jsFullSize;
      Grayscale := False;
      Performance := jpBestQuality;
      ProgressiveDisplay := True;
      ProgressiveEncoding := True;
      LoadFromStream(MS);
    end;
    ImageElevation.Picture.Assign(J1);
  except
  end;
    J1.Free;
    MS.Free;
end;

If you search the last couple weeks under my
name, or JPEG or jpg, you should
find everything you need if this doesn't solve
your problem.  don't us dbImage

Re:JPG-Pictures save into PDOX7-Table


Hi Art,
Thanks for your help.

I have searched http://www.mers.com for old entries from this newsgroup
(Theme: JPG and JPEG).
From 60 Answers I have no more found as your last tip.

Art Begun <beg...@mindspring.com> schrieb in im Newsbeitrag:
833tnp$c...@forums.borland.com...

Quote

> If you search the last couple weeks under my
> name, or JPEG or jpg, you should
> find everything you need if this doesn't solve
> your problem.  don't us dbImage

> Use a binary field.

yes, I use Table1.fieldbyName('B') -  and  Form1.TImage1

Quote

> To save a file to a blob see the TblobField.loadfromFile method

1. I read a 24Bit-JPG-File into Blobfield:
procedure TProdukteForm.Button2Click(Sender: TObject);
begin
  if opendialog1.execute then begin
     with Table1 do begin
      insert;
      (fieldbyName('B') as TblobField).loadFromFile(OpenDialog1.filename);
      post;
    end;
  end;
end;

2. Now I will place the Picture on Form1.Image1   :
procedure TProdukteForm.Button3Click(Sender: TObject);
var
  MS: TMemoryStream;
  J1: TJPEGImage;
begin
  if Table1.Fieldbyname('B').isnull then exit;
  J1 := TJPEGImage.Create;
  MS := TMemoryStream.Create;
  try
    TBlobField(Table1.Fieldbyname('B')).SaveToStream(MS);
    MS.Seek(soFromBeginning, 0);
    with J1 do begin
      PixelFormat := jf24Bit;
      Scale := jsFullSize;
      Grayscale := False;
      Performance := jpBestQuality;
      ProgressiveDisplay := True;
      ProgressiveEncoding := True;
      LoadFromStream(MS);
    end;

{   Problempoint
     the following command brings every time
     '....Error: read from Address FFFFFFFF': }
    Image1.Picture.Graphic.Assign(J1);

  finally
    J1.Free;
    MS.Free;
  end;
end;

How can I solve this problem?

Best Regards
Kurt.

Re:JPG-Pictures save into PDOX7-Table


THe messages have not expired yet.
Try to download more headers with your newsgroup
program.  You should also be able to find
them with deja.com.  If you have another question
post it and I and others will try to solve it for you.

Quote
"Kurt Mller" <kurt-muel...@gmx.de> wrote in message

news:838nmo$j4m16@forums.borland.com...
Quote
> Hi Art,
> Thanks for your help.

> I have searched http://www.mers.com for old entries from this newsgroup
> (Theme: JPG and JPEG).
> From 60 Answers I have no more found as your last tip.

> Art Begun <beg...@mindspring.com> schrieb in im Newsbeitrag:
> 833tnp$c...@forums.borland.com...

> > If you search the last couple weeks under my
> > name, or JPEG or jpg, you should
> > find everything you need if this doesn't solve
> > your problem.  don't us dbImage

> > Use a binary field.
> yes, I use Table1.fieldbyName('B') -  and  Form1.TImage1

> > To save a file to a blob see the TblobField.loadfromFile method

> 1. I read a 24Bit-JPG-File into Blobfield:
> procedure TProdukteForm.Button2Click(Sender: TObject);
> begin
>   if opendialog1.execute then begin
>      with Table1 do begin
>       insert;
>       (fieldbyName('B') as TblobField).loadFromFile(OpenDialog1.filename);
>       post;
>     end;
>   end;
> end;

> 2. Now I will place the Picture on Form1.Image1   :
> procedure TProdukteForm.Button3Click(Sender: TObject);
> var
>   MS: TMemoryStream;
>   J1: TJPEGImage;
> begin
>   if Table1.Fieldbyname('B').isnull then exit;
>   J1 := TJPEGImage.Create;
>   MS := TMemoryStream.Create;
>   try
>     TBlobField(Table1.Fieldbyname('B')).SaveToStream(MS);
>     MS.Seek(soFromBeginning, 0);
>     with J1 do begin
>       PixelFormat := jf24Bit;
>       Scale := jsFullSize;
>       Grayscale := False;
>       Performance := jpBestQuality;
>       ProgressiveDisplay := True;
>       ProgressiveEncoding := True;
>       LoadFromStream(MS);
>     end;

> {   Problempoint
>      the following command brings every time
>      '....Error: read from Address FFFFFFFF': }
>     Image1.Picture.Graphic.Assign(J1);

>   finally
>     J1.Free;
>     MS.Free;
>   end;
> end;

> How can I solve this problem?

> Best Regards
> Kurt.

Re:JPG-Pictures save into PDOX7-Table


Art Begun <beg...@mindspring.com> schrieb in im Newsbeitrag:
839fvs$p4...@forums.borland.com...

Quote
> THe messages have not expired yet.
> Try to download more headers with your newsgroup
> program.  You should also be able to find
> them with deja.com.  If you have another question
> post it and I and others will try to solve it for you.

Thanks to you.
The problem is solved - the program is running now.

Kurt

Other Threads