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
 RenderToCanvas returns with empty screens

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
Reiner Posted - Sep 26 2018 : 16:09:03
Hi,
we have just put the TIEBitmap and TImageEnIO into the kernel of our printing application to handle multipage tiff sources. In principle everything works as expected ... but randomly a few pages come out as blanc pages.

We could locate the issue as a possible timing problem while using the RenderToCanvas() method. Here the results, focussing on the central methods:

Sequence (1) - Straight forward
ietifbmp->RenderToCanvas(PrnBmp->Canvas,L,T,W,H,rfLanczos3,0,clWhite);
Printer()->Canvas->StretchDraw(Printer()->Canvas->ClipRect,PrnBmp);
===> blanc pages are printed randomly (about one of 10)

Sequence (2)- Inserting a delay
ietifbmp->RenderToCanvas(PrnBmp->Canvas,L,T,W,H,rfLanczos3,0,clWhite);
DelayLoop(500 ms) // containing Application->ProcessMessages()
Printer()->Canvas->StretchDraw(Printer()->Canvas->ClipRect, PrnBmp);
===> all pages are printed, anytime

My assumption: The RenderToCanvas() method seems to work asynchronly, i.e. it returns before the target bitmap is completed.

Is there any solution like an event or a state value that can inform us about the rendering process state.

Thank you!
Reiner
4   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Sep 29 2018 : 22:43:03
Hi Reiner

Good to hear you have found a working solution.

Nigel
Xequte Software
www.imageen.com
Reiner Posted - Sep 29 2018 : 14:41:43
Hi again Nigel,

it took me a while, because our test program did not show any problems with the multipage-tiff-printing.


//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)

#pragma link "hyiedefs"
#pragma link "hyieutils"
#pragma link "iesettings"
#pragma link "iexLayers"
#pragma link "iexRulers"
#pragma link "ieopensavedlg"
#pragma link "iexBitmaps"
#pragma link "ieview"
#pragma link "imageenio"
#pragma link "imageenview"
#pragma resource "*.dfm"

TForm1 *Form1;
TPrinter *PRN;

//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner): TForm(Owner)
//---------------------------------------------------------------------------
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button0Click(TObject *Sender)
//---------------------------------------------------------------------------
{
   TIETIFFHandler *tiffs=new TIETIFFHandler();
   TMemoryStream  *tmp  =new TMemoryStream();
   TIEBitmap      *iebmp=new TIEBitmap();
   TImageEnIO     *IO   =new TImageEnIO(iebmp);
   TBitmap        *bmp  =new TBitmap;

   bmp->Width  = 2479;
   bmp->Height = 3508;

   PRN=Printer();

   OpenFileDlg->Execute();

   if(OpenFileDlg->FileNameW!="")
   {
	 PRN->BeginDoc();
	 PRN->Canvas->CopyMode=cmSrcCopy;

	 tiffs->ReadFile(OpenFileDlg->FileNameW);
	 int pages=tiffs->GetPagesCount();

	 Button0->Caption=IntToStr(pages)+" Pages";

	 for(int i=0; i<pages; i++) // print all pages of the tif-file
	 {
	   tmp->Position=0; tiffs->WriteStream(tmp,i);
	   tmp->Position=0; IO->LoadFromStreamTIFF(tmp);

	   // render to intermediate bitmap (this step is not really necessary)
	    iebmp->RenderToCanvas(bmp->Canvas,0,0,2479,3508,rfFastLinear,0,clWhite);

	   PRN->Canvas->StretchDraw(PRN->Canvas->ClipRect,bmp);
	   if(i<pages-1)PRN->NewPage();

	   //  IM->Picture->Bitmap->Assign(bmp); // TImage control on Form1
	   Button0->Caption=IntToStr(pages)+" Pages printed";
	 }

	 PRN->EndDoc();
   }

   delete bmp;
   delete IO;
   delete iebmp;
   delete tmp;
   delete tiffs;
}
//---------------------------------------------------------------------------



In my final application the rendering and printing portion shown above is located within a Windows service class. Probably here we are facing the asynchronous effects providing us blanc pages. Here your assumption regarding the Printer->Canvas behavior hits the mark.

After a few more hours of try&error I now have noticed, that if we just add the following 1-dot-Draw function ahead the main StretchDraw(), the blanc pages disappear:

PRN->Canvas->Draw(0,0,1_dot_bmp); // added line
PRN->Canvas->StretchDraw(PRN->Canvas->ClipRect,bmp);

I admit that this does not get us to the root cause but it gets our application working stable up to now.

Thank you again
Reiner
Reiner Posted - Sep 28 2018 : 01:57:02
Hi Nigel,

Thanks a lot for your prompt reply.
This is already a valuable information.
I will prepare a little test program for further research and come back to this thread as soon as possible.

Reiner
xequte Posted - Sep 27 2018 : 15:24:02
Hi Reiner

RenderToCanvas isn't asynchronous, but is it possible that Printer->Canvas work asynchronously (using Windows messages, which explains the ProcessMessages() calls).

Is PrnBmp a TIEBitmap or TBitmap?

Unfortunately we cannot reproduce the error here. Are you able to create a simple test application that shows the issue?

Nigel
Xequte Software
www.imageen.com