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
 Navigating a memory stream

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
Elemental Posted - Mar 14 2014 : 10:33:00
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"

4   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Mar 18 2014 : 21:08:04
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
Elemental Posted - Mar 18 2014 : 14:36:46
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.
Elemental Posted - Mar 18 2014 : 07:43:22
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.
xequte Posted - Mar 16 2014 : 13:19:18
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