I have a jpeg file saved in a string. I would like to load/assign the string to a TImage in Delphi7. I use KOL for the following Code:
var
ImageStream : PStream;
ImageString : String;
MyJpeg : TJpeg;
begin
ImageStream:= NewMemoryStream; // Create New Stream.
ImageStream.Write(ImageString [1], Length(ImageString )); // Fill the stream.
ImageStream.Position := 0; // Set Position to 0.
// ImageStream.SaveToFile('C:\test.jpg', 0, ImageStream.Size); // Debug --> WORKS!
MyJpeg := TJpegImage.Create; // Create a Jpeg Image.
MyJpeg.LoadFromStream(@ImageStream); // ???
Image1.picture.Assign(MyJpeg); // No picture is shown
end;
It should work since PStream is just a pointer to TStream…
But there is no picture shown in Timage…
Thanks for your help 🙂
You state that
In which case this code
cannot work. You are passing, to a parameter of type
TStream, a pointer to a pointer to TStream. To make your code compile you need to pass aTStreamtoLoadFromStream. Like this:In your position, I would probably use a
TStringStreamlike this.Perhaps there is a KOL way to do that, I don’t know KOL at all.