Author |
Topic |
|
stwizard
USA
46 Posts |
Posted - Feb 26 2012 : 07:24:08
|
Greetings All,
Using TImageEnMView I can load an existing Multi-page tiff file.
The user would like to me able to append another existing multi-page tiff file to it.
Assume a 3 page document is already loaded in the TImageEnMView component. User now selects a 10 page tiff file form disk to append to it.
The code below will only load the fist page in the 10 page tiff so the TImageEnMView component now shows 4 pages. What have I done wrong? //* Open an existing tif file. OpenImageEnDialog.Filter := 'TIF Files|*.tif';
if OpenImageEnDialog.Execute then ImageEnView1.IO.LoadFromFile(OpenImageEnDialog.FileName);
Thanks, Mike
|
|
fab
1310 Posts |
Posted - Feb 26 2012 : 09:26:23
|
Hello, why not to load the TIFF using TImageEnMView instead of TImageEnView? Try:
ImageEnMView1.MIO.LoadFromFile(OpenImageEnDialog.FileName); |
|
|
stwizard
USA
46 Posts |
Posted - Sep 21 2012 : 05:04:34
|
Greetings fabrizio,
Finally back to working on this project.
Using TImageEnMView to load a 1 page tiff, followed by loading a 5 page tiff does result in a 6 page tiff, great.
However there is a problem. I would expect that the 1 page tiff that was loaded first would be the first page if this component. It is actually the last page. Hmmm.
So I cleared the TImageEnMView component, loaded the 5 page tiff first, then loaded the 1 page tiff which again results in a 6 page tiff, great.
However, now there is a different problem, it places the 1 page tiff at the beginning followed by the previous 5 pages that were previously loaded.
It seems as though instead of appending the new 1 page tiff to the wnd of the existing tiff, it is inserting it ahead of the currently selected page in the TImageEnMView component. The currently selected page was page 1.
So to verifiy this I cleared the TImageEnMView component, loaded a 5 page tiff, then selected the 3rd page in the TImageEnMView component, then appended the 1 page tiff and sure enough the 1 page tiff is now page 3 in the component and pages 3-5 are now pages 4-6.
I'm sure it must be me doing something wrong. Is there a setting that tells the TImageEnMView component that any additional pages are to be placed at the end of the line?
Thank so much, Mike
|
|
|
stwizard
USA
46 Posts |
Posted - Sep 21 2012 : 07:09:02
|
Hmmm, someone replied here to do the following and now there post is gone?
// if image already loaded add the new images to the end of the list if ImageEnMView1.ImageCount > 0 then ImageEnMView1.SelectedImage := ImageEnMView1.ImageCount-1;
Anyway, I added the above code, and I started fresh with a 5 page tiff, followed by appending a 1 page tiff and the 1 page tiff was inserted before page 5 of the five page tiff. In other words if the pages of the 5 page tiff were numbered 1 thru 5 and the 1 page tiff had the letter 'A', then the ImageEnMView1 shows 1,2,3,4,A,5
Still confused by this...
Thanks, Mike |
|
|
w2m
USA
1990 Posts |
Posted - Sep 21 2012 : 09:12:13
|
I posted the removed message. The message was removed because I tested it some more and got the same results. This seems to work however:
if ImageEnMView1.ImageCount > 0 then
begin
// make last image visible at 0,0
ImageEnMView1.DisplayImageAt(ImageEnMView1.ImageCount - 1, 0, 0);
ImageEnMView1.MIO.LoadFromFile(iFilename);
end; When testing this with a multiframe tif already loaded when the next multiframe tif was loaded the first frame for the last tif was at the end of the first tif file. I hope it works for you.
William Miller Adirondack Software & Graphics Email: w2m@frontiernet.net EBook: http://www.imageen.com/ebook/ Apprehend: http://www.frontiernet.net/~w2m/index.html |
|
|
stwizard
USA
46 Posts |
Posted - Sep 21 2012 : 09:58:01
|
Greetings William,
LOL, I thought there might have been a reason.
I changed to your newest code snippit and still something is wrong.
If I start fresh and load the 5 page first followed by the one page, my results are 'A,1,2,3,4,5. It should be 1,2,3,4,5,A
If I start fresh and load the 1 page first followed by the 5 page my results are 1,2,3,4,5,A. It should be A,1,2,3,4,5
So at least it's not shoving the 1 page into the middle of the 5 page.
Any other ideas?
Thanks, Mike |
|
|
w2m
USA
1990 Posts |
Posted - Sep 21 2012 : 10:08:54
|
Are you sure something else is not going wrong somewhere else in your code? I have been playing with it for while now and it works for me. The appended image is added at the end.
William Miller |
|
|
stwizard
USA
46 Posts |
Posted - Sep 21 2012 : 10:14:18
|
I knew that would be your next question.
My Code: Note that the first tiff file is already loaded and correctly showing in the the ImageEnMView1 component. Then the following code will add additional tiff files that the user selected.
procedure TfrmDocumentAppend.btnProcessClick(Sender: TObject); begin with cdsDocumentList do begin First;
while not eof do begin if ImageEnMView1.ImageCount > 0 then begin // make last image visible at 0,0 ImageEnMView1.DisplayImageAt(ImageEnMView1.ImageCount - 1, 0, 0);
ImageEnMView1.MIO.LoadFromFile(cdsDocumentListDOCUMENT_PATH.AsString); end;
Next; end; end;
btnSave.Enabled := True; end;
So as you can see, there is nothing special going on here.
FYI: Still on v3.1.2
Mike
|
|
|
stwizard
USA
46 Posts |
Posted - Sep 21 2012 : 10:32:52
|
William,
I just put together a small demo to test and it works...
Going to try to figure out why now.
Will be back in touch once i figure it out.
Mike |
|
|
w2m
USA
1990 Posts |
Posted - Sep 21 2012 : 10:36:30
|
It is hard for me to tell what is wrong, but something surely is. What is cdsDocumentList? what is First? Why use while not eof do? Here I load the ImageEnMView from a file and append the next tif file with LoadFromFile.
It look like DisplayImageAt(ImageEnMView1.ImageCount - 1, 0, 0) and LoadFromFile(iFilename) is being called more than one time. Here I just call this one time. If the images are being loaded one at a time rather than all at once with LoadFromFile there is a different way to add the images to the list with ImageEnMView1.SetIEBitmap(0,ImageEnView1.IEBitmap);
You should start with a simple demo with LoadFromFile and proceed from there... Have you stepped through your code with F8 to watch what is taking place? I'll bet you find something wrong if you do.
I have updated my "EBook ImageEnMView from A to Z demo" with code to append multipage tif files to the end of the ImageEnMView List. If you are interested get my book and I'll send you the updated demo. I can not post it here because the demo is over 5,000 lines of code.
William Miller Adirondack Software & Graphics Email: w2m@frontiernet.net EBook: http://www.imageen.com/ebook/ Apprehend: http://www.frontiernet.net/~w2m/index.html |
|
|
stwizard
USA
46 Posts |
Posted - Sep 21 2012 : 10:48:34
|
Greetings William,
I found what was causing the issue. Will post shortly.
Mike |
|
|
w2m
USA
1990 Posts |
Posted - Sep 21 2012 : 11:42:12
|
I also found out that if you select a frame with the mouse the image is not inserted at the end, it is inserted to the frame bedore the selected frame so add DeSelect after DisplayImageAt:
// make last image visible at 0,0
ImageEnMView1.DisplayImageAt(ImageEnMView1.ImageCount - 1, 0, 0);
// deselect all selected images.
ImageEnMView1.DeSelect; William Miller Adirondack Software & Graphics Email: w2m@frontiernet.net EBook: http://www.imageen.com/ebook/ Apprehend: http://www.frontiernet.net/~w2m/index.html |
|
|
stwizard
USA
46 Posts |
Posted - Sep 21 2012 : 12:37:21
|
Well you answered my next question before I could even ask it.
I did notice that if I used the mouse to select an image in the TImageEnMView component that it would not append at the end as expected.
Thanks, so much for your help.
Mike |
|
|
|
Topic |
|
|
|