Board index » delphi » TGraphicField.LoadFromFile Question

TGraphicField.LoadFromFile Question

I have a simple problem. Perhaps someone can help.

I am trying to load a jpg file into a Paradox Blob Field. I've
included the jpeg unit.

procedure TQuoteImageForm.Button2Click(Sender: TObject);
begin
  if MyOpenDialog.Execute then
  begin
    Table1.Edit;
    (Table1.FieldByName('Image') as
TGraphicField).LoadFromFile(MyOpenDialog.Filename);
  end;
end;

When the file is a bitmap there is no problem. When it is not, the
error message is "Bitmap image is not valid". I found a workaround
using the TDBImage control.

begin
  if MyOpenDialog.Execute then
  begin
      DBImage1.Picture.LoadFromFile(MyOpenDialog.Filename);
      DBImage1.CopyToClipboard;
      DBImage1.PasteFromClipboard;
  end;
end;

Does anyone know what's happening here?

 

Re:TGraphicField.LoadFromFile Question


On Thu, 1 Jul 1999 18:42:20 -0700, b...@bluestars{*word*99}.com (Robert Zurer)
wrote:

[...]

Quote
>When the file is a bitmap there is no problem. When it is not, the
>error message is "Bitmap image is not valid". I found a workaround
>using the TDBImage control.

[...]

The source of your problem is that the TDBImage component requires graphics
formats native to the Windows environment, like bitmap and Windows
meta-file. Other common graphics types like JPEG and GIF are not native to
Windows and will cause problems with TDBImage.

For JPEG files, use the TJPEGImage component. As it is not data-aware, you
would need to load the image from the table's field programmatically. A
good place to do that is in a handler for the dataset component's
AfterScroll event, which fires each time the record pointer moves.

For GIF files, though, nothing is included in Delphi. You would need to get
a third-party component for this.

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
Steve Koterski     "An inventor is a person who makes an ingenious
Felton, CA         arrangement of wheels, levers and springs, and believes
                   it civilization."          -- Ernest Dimnet (1866-1954)

Other Threads