Graphman, unfortunately it is not as simple as it seems. The decoder (jpeg, tiff...) could not read the stream from start to the end: so when LoadFromStream finishes the stream position may not be at the start of the "params".
You should use header streams for both read and write, and read manually this header in order to set the right position for the "params" stream.
Here is an example in Delphi:
// write a TIFF and Params
var
fs: TFileStream;
begin
fs := TFileStream.Create('c:\test.dat', fmCreate);
ImageEnView1.IO.StreamHeaders := true;
ImageEnView1.IO.SaveToStreamTIFF(fs);
ImageEnView1.IO.Params.SaveToStream(fs);
fs.Free();
end;
// read back the TIFF and Params
var
fs: TFileStream;
streamHeader: TIFFSHead;
begin
fs := TFileStream.Create('c:\test.dat', fmOpenRead);
fs.Read(streamHeader, sizeof(TIFFSHead));
fs.Position := 0;
ImageEnView1.IO.StreamHeaders := true;
ImageEnView1.IO.LoadFromStreamTIFF(fs);
fs.Position := streamHeader.dim + sizeof(TIFFSHead);
ImageEnView1.Io.Params.LoadFromStream(fs);
fs.Free();
end;
From next minor version this will be enough:
var
fs: TFileStream;
begin
fs := TFileStream.Create('c:\test.dat', fmOpenRead);
ImageEnView1.IO.StreamHeaders := true;
ImageEnView1.IO.LoadFromStreamTIFF(fs);
ImageEnView1.Io.Params.LoadFromStream(fs);
fs.Free();
end;
Hope this helps.