ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 SaveToStream Image and Params

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
graphman Posted - Oct 21 2013 : 15:24:40
Is there a way to saveto stream and load to stream image and params?

void __fastcall TForm8::ButtonSaveClick(TObject *Sender)
{
//test.dat exists and empty
TFileStream* fs = new TFileStream("C:\\TEMP1\\test.dat", fmOpenReadWrite|fmShareExclusive);
TIOFileType filetype;
filetype = FindFileFormat(OpenImageEnDialog1->FileName,false);
ImageEnIO1->StreamHeaders = true;
ImageEnIO1->SaveToStream(fs,filetype);
if (filetype != 1) ImageEnIO1->Params->SaveToStream(fs);
delete fs;
}
//---------------------------------------------------------------------------

void __fastcall TForm8::ButtonLoadClick(TObject *Sender)
{
TFileStream* fs = new TFileStream("C:\\TEMP1\\test.dat", fmOpenRead|fmShareDenyWrite);
fs->Position = 0;
ImageEnIO1->LoadFromStream(fs);
ImageEnIO1->Params->LoadFromStream(fs);
ImageEnVect1->Update();
delete fs;
}
//---------------------------------------------------------------------------


ERROR
6   L A T E S T    R E P L I E S    (Newest First)
fab Posted - Oct 30 2013 : 03:55:51
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.
graphman Posted - Oct 23 2013 : 02:19:21
ButtonLoadClick
ImageEnIO1->Params->LoadFromStream(fs);
"out of memory"
xequte Posted - Oct 23 2013 : 02:02:19
OK, what is the error message? On what line does it occur?



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
graphman Posted - Oct 23 2013 : 00:19:47
In the previous version all was OK.
graphman Posted - Oct 23 2013 : 00:17:37
I need to save and load stream (image + params) in our program.
There is Error at loading.
xequte Posted - Oct 22 2013 : 20:02:21
Hi

You should not use StreamHeaders if you are saving a single image as that will make it incompatible with other applications.

Please try StreamHeaders = false;

Then test whether the created file can be opened in another image application.

Also, please clarify the nature of the error that you encounter.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com