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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Navigating a memory stream
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Elemental

USA
56 Posts

Posted - Mar 14 2014 :  10:33:00  Show Profile  Reply
I am loading a multi-page TIFF with the following code. My TImageEnView component is named ievPage:


procedure LoadDocument(SelectedDoc: TIETIFFHandler; FileName: TFileName);
var
  SelectedDocStream: TMemoryStream;
begin
  ievPage.IO.Params.ImageIndex := 0;
  Assert( Assigned( SelectedDoc ) );
  Assert( FileName <> '' );
  SelectedDoc.Read( FileName );
  SelectedDocStream := TMemoryStream.Create;
  try
    SelectedDoc.WriteStream( SelectedDocStream );
    SelectedDocStream.Position := 0;
    ievPage.IO.LoadFromStreamTIFF( SelectedDocStream );
  finally
    SelectedDocStream.Free;
  end;
  ievPage.Fit;
end;


Loading the first page is fine. But I also want to allow the user to navigate the pages of the document. The Seek method will only look at the last file loaded, not the last stream loaded. How do I tell the TImageEnView component to show a particular page in the TIFF stream other than the first? Setting IO.Params.ImageIndex doesn't work, nor does IO.Params.TIFF_ImageIndex.

"Roj"

xequte

38610 Posts

Posted - Mar 16 2014 :  13:19:18  Show Profile  Reply
Hi Roj

Use of ImageIndex should absolutely work:

// Load second frame from stream
ievPage.IO.Params.TIFF_ImageIndex := 1;
ievPage.IO.LoadFromStreamTIFF( SelectedDocStream );


Please provide more detail if you are not seeing this.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

Elemental

USA
56 Posts

Posted - Mar 18 2014 :  07:43:22  Show Profile  Reply
As I said, it works fine when loading the 1st page. But when I assign ImageIndex or TIFF_ImageIndex to 2, whether or not I call the LoadFromStreamTIFF method, all I see is the first page. And when I use Seek without a second parameter, that doesn't work either, since I never did load the TIFF using a file. The stream object I'm giving it has more than one TIFF page in it.

Anyway, no reply to this thread is needed since I did a workaround: the stream now only has ONE page in it at a time, and the LoadFromStreamTIFF is happy now.
Go to Top of Page

Elemental

USA
56 Posts

Posted - Mar 18 2014 :  14:36:46  Show Profile  Reply
I'm working on another project already that also requires navigating a stream representing multiple pages and the workaround I used before isn't going to work in my new project. Here is my setup code, where FFileHandler is of type TIETIFFHandler and FMemoryStream is of type TMemoryStream:


FFileHandler.ReadFile( FileName );
FFileHandler.WriteStream( FMemoryStream );
FMemoryStream.Position := 0;
FPageViewed := ViewPage( 0 );


Here is the code to the ViewPage function:


ImageEnVect1.IO.Params.TIFF_ImageIndex := Number;
ImageEnVect1.IO.LoadFromStreamTIFF( FMemoryStream );
Result := Number;


The solution was to add this line to the ViewPage function:


FMemoryStream.Position := 0;


That's pretty funny. But I don't work with streams a whole lot, much less rivers. :) Anyway, that's the only way I can get a TIFF Handler and an image component to talk, is either through a stream or a file and a file is too permanent and too slow.
Go to Top of Page

xequte

38610 Posts

Posted - Mar 18 2014 :  21:08:04  Show Profile  Reply
Hi

That is odd, because you already reset the FMemoryStream.Position before calling ViewPage(). So it should have no effect.

Are you using v5.0.6? I wonder if the weirdness you are seeing is due to the memory issue related to TIFF and JPEG loading in that version. We will have a fix in the next few days.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: