CreateBlobStream Picture LoadFromStream
delphi - How to display BLOB Image from database in the TAdvStringGrid with the help of DataSet
https://vigges.net/qa/?qa=1132506/
CreateBlobStream is creating a TStream object, not a TMemoryStream.
Since you do not want to write the JPG to the database you should use bmRead instead of bmReadWrite.
I am not used to SQLite, but you will have to make sure that you are using a suitable binary datetype (BLOB).
JPG := TJpegImage.Create;
Picture:= TPicture.Create;
try
st := results.CreateBlobStream(TBlobField(results.FieldByName('image')), bmRead);
try
JPG.LoadFromStream(st);
Picture.Assign(JPG);
sg.AddPicture(i,j,Picture,True,ShrinkWithAspectRatio,0,haLeft,vaTop);
finally
st.Free;
end;
finally
JPG.Free;
Picture.Free;
end;
To ensure that the stored image is really a JPG you should write the JPG for testing with something like:
var
ms: TMemoryStream;
begin
ads.Open;
ads.Append;
ms := TMemoryStream.Create;
try
Image1.Picture.Graphic.SaveToStream(ms); // make sure having loaded a JPG
ms.Position := 0;
TBlobField(ads.FieldByName('image')).LoadFromStream(ms);
finally
ms.Free;
end;
ads.Post;
end;
https://kifmesoft.wordpress.com/2006/06/09/memorystream-untuk-menampung-blob-field-image-picture/
https://codeverge.com/embarcadero.delphi.database/saving-a-jpg-in-a-graphicsfield/1067238
https://stackoverflow.com/questions/40357324/trying-to-save-a-bmp-from-pc-to-a-database-blob-field
https://www.chestysoft.com/ximage/access1.asp
https://forum.lazarus.freepascal.org/index.php?topic=43499.0