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
 Demo PDF Builder
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

John

USA
94 Posts

Posted - Feb 25 2015 :  14:33:37  Show Profile  Reply
Hello

I have added an ImageEnMView to the PDF builder demo in an attempt to:
- place each scanned image into a memory stream and
- then load each image from the stream into the ImageEnMView.

The goal is to ;
- load the ImageEnMView without creating any files and
- utilize the idx in the OnClick event of the ImageEnMView to recall the image from the stream and load it back into the ImageEnView in case it needs to be reviewed prior to saving the file.

In an attempt to accomplish the above I have added an ImageEnMView component to the 3rd tab set of the demo and added the following code.

var
  tempMemoryStream: TMemoryStream;

procedure TformPDFBuilder.FormCreate(Sender: TObject);
begin
  tempMemoryStream := TMemoryStream.Create;
  ImageEnView1.IO.StreamHeaders := True;   
end;

procedure TformPDFBuilder.AddPage;
begin
// existing code

  ImageEnView1.IO.SaveToStreamJpeg(tempMemoryStream);
  ImageEnMView1.MIO.LoadFromStreamFormat(tempMemoryStream, ioJPEG);
end;




Unfortunately, the above loads the first scanned image into the ImageENMView component over and over and not the newly scanned images. The correct scanned image is, however, displayed in the ImageEnView component.

I would greatly appreciate any suggestions?

TIA

John

xequte

38610 Posts

Posted - Feb 25 2015 :  18:16:10  Show Profile  Reply
Hi John

It looks like you are trying to replace the content of the TImageEnMView, you should be appending the content, e.g.

ImageEnMView1.AppendImage( tempMemoryStream );

http://www.imageen.com/help/TImageEnMView.AppendImage.html

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

John

USA
94 Posts

Posted - Feb 25 2015 :  22:38:43  Show Profile  Reply
Nigel

Thanks for the reply.

My problem with this solution is that the scanned image does not display in the ImageEnMView component, rather an image of a folder, see attached image.



TIA

John

Go to Top of Page

xequte

38610 Posts

Posted - Feb 26 2015 :  17:07:37  Show Profile  Reply
Hi

A bug in v5.2.0 causes it to show a folder icon for invalid files. Are you sure you have reset the position of the stream before calling AppendImage.

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

Manarsoft

Algeria
4 Posts

Posted - Feb 27 2015 :  07:54:37  Show Profile  Reply
hi John,
can you post the source code?

...
Delphi IDE Blog!
delphiide.blogspot.com
Go to Top of Page

John

USA
94 Posts

Posted - Feb 27 2015 :  11:43:10  Show Profile  Reply
Nigel

I was not resetting the MemoryStream.

a) If I add tempMemoryStream.Position := 0; , the scanned images do display in the ImageEnMView. However, the first scanned image is repeated in the ImageEnMView.

procedure TformPDFBuilder.AddPage;
.... existing code in demo
  ImageEnView1.IO.SaveToStreamJpeg(tempMemoryStream);
  tempMemoryStream.Position := 0;   
  ImageEnMView1.AppendImage(tempMemoryStream);
end;






b) If I change the AddPage code to the following, the scanned images correctly display in the ImageEnMView component.

procedure TformPDFBuilder.AddPage;
var
  tempidx: Integer;
begin
// existing code

  tempImageCount := tempImageCount + 1;
  ImageEnView1.IO.SaveToStreamJpeg(tempMemoryStream);
  tempMemoryStream.Position := 0;
  tempidx := ImageEnMView1.AppendImage;
  ImageEnMView1.SetImage(tempidx, ImageEnView1.Bitmap);
end;







c) However (as you can see from the above image), if I try to reload an existing image from the ImageInMView back into the ImageEnView with the following code in the ImageEnMView.OnImageSelect event, it does not work.

procedure TformPDFBuilder.ImageEnMView1ImageSelect(Sender: TObject; idx: Integer);
begin
  ImageEnView1.Clear;
  tempMemoryStream.Position := idx;
  ImageEnView1.IO.LoadFromStreamJpeg(tempMemoryStream);
end;



I suspect the reloading problem relates to the fact that I am using a stream and not files, because "ImageEnView1.IO.LoadFromFile(ImageEnMView1.ImageFileName[idx]);" works for files.

Suggestions?

TIA

John



Manarsoft
The code above and that from the initial post is the only code I added to the ImageEn PDFBuilder demo to illustrate the problem.





Go to Top of Page

xequte

38610 Posts

Posted - Feb 27 2015 :  13:21:39  Show Profile  Reply
Hi

Perhaps you should start with the Multi\Multiview demo. The open function will append images to the TImageEnMView. It also has a save event that will allow you to output all frames to a multipage file such as a PDF (you can also use ImageEnMView1.MIO.SaveToFilePDF).

To make it show in an TImageEnView add this to the ImageSelect event:

procedure TMainForm.ImageEnMView1ImageSelect(Sender: TObject; idx: Integer);
begin
  ImageEnMView1.CopyToIEBitmap( idx, ImageEnView1.IEBitmap );
  ImageEnView1.Update;
end;



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: