How do I save a jpg image to database and then load it in Delphi using FIBplus and TImage?
            Asked
            
        
        
            Active
            
        
            Viewed 1.9k times
        
    4 Answers
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"
-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