Author |
Topic  |
|
andyhill
  
Australia
159 Posts |
Posted - Nov 01 2012 : 17:28:01
|
I am having with ImageEnMView.
I have an application that scans the given path for all PDF files, a complete list is built first, then after the scanning process the list is traversed and thumbnails are built for each listing using ImageEnMView. When a thumbnail is selected the image is re-fetched again and shown in more detail via ImageEnVect.
Code for ImageEnVect works every time:-
try PDFLibrary:= TDebenuPDFLibrary0912.Create; ms:= TMemoryStream.Create; UnlockResult:= PDFLibrary.UnlockKey('xxx'); if UnlockResult = 1 then begin PDFLibrary.LoadFromFile(ImageEnMView9.ImageFileName[ImageEnMView9.SelectedImage], ''); // Render Options: 0 = BMP, 1 = JPEG, 2 = WMF, 3 = EMF, 4 = EPS, 5 = PNG, 6 = GIF, 7 = TIFF, 8 = EMF+, 9 = HTML5, 10 = TIFF (G4) PDFLibrary.RenderPageToStream(120, 1, 1, ms); // dpi, page, jpeg, stream ms.Seek(0, soFromBeginning); ImageEnVectDisplay.IO.LoadFromStreamJpeg(ms); ImageEnVectDisplay.Hint:= ImageEnMView9.ImageFileName[ImageEnMView9.SelectedImage]; end else begin ShowMessage('Invalid license key'); end; ms.Free; PDFLibrary.Free; except ms.Free; PDFLibrary.Free; end;
Code that builds ImageEnMView Thumb Nails does not work every time and yet it is the same PDF File ?
try PDFLibrary:= TDebenuPDFLibrary0912.Create; ms:= TMemoryStream.Create; UnlockResult:= PDFLibrary.UnlockKey('xxx'); if UnlockResult = 1 then begin PDFLibrary.LoadFromFile(DirectoryList2[i], ''); // Render Options: 0 = BMP, 1 = JPEG, 2 = WMF, 3 = EMF, 4 = EPS, 5 = PNG, 6 = GIF, 7 = TIFF, 8 = EMF+, 9 = HTML5, 10 = TIFF (G4) PDFLibrary.RenderPageToStream(96, 1, 1, ms); // dpi, page, jpeg, stream ms.Seek(0, soFromBeginning); ImageEnMView9.MIO.LoadFromStreamFormat(ms, ioJPEG); ImageEnMView9.ImageFileName[ImageEnMView9.ImageCount-1]:= DirectoryList2[i]; ImageEnMView9.ImageBottomText[ImageEnMView9.ImageCount-1].Font.Size:= 4; ImageEnMView9.ImageBottomText[ImageEnMView9.ImageCount-1].Caption:= FileName; Inc(TotalCount); Application.ProcessMessages; end else begin ShowMessage('Invalid license key'); end; ms.Free; PDFLibrary.Free; except ms.Free; PDFLibrary.Free; end;
To see it in action you can download the test app from www.axfite.com.au/ImageSort.zip (uncheck all and check only PDF). What appears to be happening is that for some reason ImageEnMView gets confused with an image and decides it is of unknown format when quite clearly ImageEnVect does not get confused with the very same image. Once confused it stays in this state.
Please advise, Regards
Andy |
|
w2m
   
USA
1990 Posts |
Posted - Nov 01 2012 : 17:39:27
|
Just an idea... eliminate Application.ProcessMessages; sometime it causes problems.
William Miller |
 |
|
andyhill
  
Australia
159 Posts |
Posted - Nov 01 2012 : 21:29:21
|
Thanks William, tried your suggestion but it made no difference.
Andy |
 |
|
xequte
    
39053 Posts |
Posted - Nov 02 2012 : 17:34:27
|
Hi Andy
I ran the test app and i cannot reproduce any problem (Windows 7). Can you please describe in more detail they symptoms of the failure?
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
 |
|
andyhill
  
Australia
159 Posts |
Posted - Nov 02 2012 : 18:00:23
|

Nigel, The 26th ThumbNail failed to load into ImageEnMView yet that very same file rendered the very same way loads perfectly into ImageEnVect ?
All PDF files that fail to load or fail to render are not added to ImageEnMView, they are skipped.
The problem usually starts at the 26th ThumbNail irrespective of which path or file - so - it appears to be a memory resource issue as each ThumbNail image is always rendered the same size.
Hope this helps.
Andy |
 |
|
xequte
    
39053 Posts |
Posted - Nov 02 2012 : 18:20:23
|
Hi Andy
Can you please narrow down the problem to being an issue in ImageEnMView or the PDF library (which may be failing on the thru-put).
Replace the line:
ImageEnMView9.MIO.LoadFromStreamFormat(ms, ioJPEG);
With some code to save the stream as a JPEG file to disk. Then after it completes parsing the folder, ensure that all the saved JPEG's are correct.
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
 |
|
andyhill
  
Australia
159 Posts |
Posted - Nov 02 2012 : 18:50:27
|
Nigel, the 26th Image (that fails to load correctly saved as jpeg file) loads perfectly as a jpeg file into ImageEnMView.
As I said it appears to be some sort of resource issue and ImageEnMView fails to reset it self some how ?
Andy |
 |
|
xequte
    
39053 Posts |
|
andyhill
  
Australia
159 Posts |
Posted - Nov 02 2012 : 20:57:14
|
.StoreType:= ietThumb;
Andy |
 |
|
andyhill
  
Australia
159 Posts |
Posted - Nov 03 2012 : 14:08:54
|
Nigel, I have added a TImage and on each Render I load the results into TImage (all paint correctly from the renderer).
What is even more concerning is the 64bit version, please download and run both 32 and 64 www.axfite.com.au/ImageSort.zip (uncheck all and check only PDF), the 64bit version also has another problem, it does not paint ImageEnVect ??? and yet it is the same code.
Code below
9: begin pcCategories.ActivePageIndex:= 9; Image1.Picture.Bitmap:= Nil; try PDFLibrary:= TDebenuPDFLibrary0912.Create; ms:= TMemoryStream.Create; bm:= TBitmap.Create; Jpg:= TJpegImage.Create; UnlockResult:= PDFLibrary.UnlockKey('my key'); if UnlockResult = 1 then begin if PDFLibrary.LoadFromFile(DirectoryList2[i], '') = 1 then begin if PDFLibrary.PageCount > 0 then begin PDFLibrary.SelectPage(1); if PDFLibrary.CombineContentStreams = 1 then begin // Render Options: 0 = BMP, 1 = JPEG, 2 = WMF, 3 = EMF, 4 = EPS, 5 = PNG, 6 = GIF, 7 = TIFF, 8 = EMF+, 9 = HTML5, 10 = TIFF (G4) if PDFLibrary.RenderPageToStream(96, 1, 1, ms) = 1 then begin if PDFLibrary.LastRenderError = '' then begin if ms.Size > 99 then begin // ms.Seek(0, soFromBeginning); Jpg.LoadFromStream(ms); bm.Assign(Jpg); Image1.Picture.Bitmap:= bm; Image1.Stretch:= True; // ms.Seek(0, soFromBeginning); ImageEnMView9.MIO.LoadFromStreamFormat(ms, ioJPEG); // ioUnknown, ioPDF, ioEMF, ioJPEG, ioBMP ImageEnMView9.ImageFileName[ImageEnMView9.ImageCount-1]:= DirectoryList2[i]; ImageEnMView9.ImageBottomText[ImageEnMView9.ImageCount-1].Font.Size:= 4; ImageEnMView9.ImageBottomText[ImageEnMView9.ImageCount-1].Caption:= FileName; Inc(TotalCount); end else begin s:= DirectoryList2[i]+' = Image Stream Length < 100'; DirectoryListError.Add('Render Error: '+s); end; end else begin s:= DirectoryList2[i]+' = '+PDFLibrary.LastRenderError; DirectoryListError.Add('Render Error: '+s); end; end else begin s:= DirectoryList2[i]+' = '+PDFLibrary.LastRenderError; DirectoryListError.Add('Render Error: '+s); end; // Render end else begin s:= DirectoryList2[i]+' = '+PDFLibrary.LastRenderError; DirectoryListError.Add('CombineContentStream Error: '+s); end; end; // Page end else begin s:= DirectoryList2[i]; DirectoryListError.Add('Load Error: '+s); end; // Load end else begin ShowMessage('Invalid license key'); end; except end; Jpg.Free; bm.Free; ms.Free; PDFLibrary.Free; Application.ProcessMessages; end;
Andy |
 |
|
fab
   
1310 Posts |
Posted - Nov 03 2012 : 14:25:18
|
quote: the 64bit version also has another problem, it does not paint ImageEnVect ???
Testing TImageEnVect with 64 bit seems to work well (tested annotations\vectorial sample). |
 |
|
andyhill
  
Australia
159 Posts |
Posted - Nov 03 2012 : 15:28:06
|
Fabrizio, I am running W7x64, XE3 and ImageSort was built in both Win32 and Win64.
Are you saying that ImageSort64.exe is working fine on your PC ?
Andy |
 |
|
fab
   
1310 Posts |
Posted - Nov 04 2012 : 10:11:18
|
No, I still not tested ImageSort64, but only TImageEnVect in "annotations\vectorial". |
 |
|
|
Topic  |
|
|
|