1

How do I save a jpg image to database and then load it in Delphi using FIBplus and TImage?

Tim B
  • 40,716
  • 16
  • 83
  • 128
Grrey
  • 671
  • 1
  • 6
  • 4

4 Answers4

4
var
  S : TMemoryStream;
begin
  S := TMemoryStream.Create;
  try
    TBlobField(AdoQuery1.FieldByName('ImageField')).SaveToStream(S);
    S.Position := 0;
    Image1.Picture.Graphic.LoadFromStream(S);
  finally
    S.Free;
  end;
end;

if you are using JPEG images, add JPG unit to uses clause of your unit file.

Ali
  • 41
  • 1
0

This page explains it. Use SaveToStream and a TMemoryStream instead of SaveToFile if you don't want temporary files. TImage.Picture has a LoadFromStream which loads the image from the stream into the TImage for display.

Lars Truijens
  • 42,837
  • 6
  • 126
  • 143
-1

Delphi 7 paradox table

insert dbimage to jpeg

var
  FileStream: TFileStream;
  BlobStream: TStream;
begin
  if openpicturedialog1.Execute then
  begin
    Sicil_frm.DBNavigator1.BtnClick(nbEdit);
    image1.Picture.LoadFromFile(openpicturedialog1.FileName);
    try
       BlobStream := dm.sicil.CreateBlobStream(dm.sicil.FieldByName('Resim'),bmWrite);
       FileStream := TFileStream.Create(openpicturedialog1.FileName,fmOpenRead or fmShareDenyNone);
       BlobStream.CopyFrom(FileStream,FileStream.Size);
       FileStream.Free;
       BlobStream.Free;
       Sicil_frm.DBNavigator1.BtnClick(nbPost);
       DM.SicilAfterScroll(dm.sicil);
     except
       dm.sicil.Cancel;
     end;
  end;
end;

Error "Bitmap image is nat valid"

divyanshm
  • 6,600
  • 7
  • 43
  • 72
alper
  • 1
-1

Take a look here. I think you have to convert it to a stream, store it and vice versa.

Roger Ween
  • 368
  • 5
  • 14