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
 PrintImage with transparent background
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

jrpcguru

USA
266 Posts

Posted - Jun 06 2016 :  19:01:52  Show Profile  Reply
I'm using ImageEnView layer 0 to display a scanned document and layer 1 to draw selection boxes so I can capture the coordinates of each field to fill in on the document. This works well and I can use ImageEnView1.Proc.TextOut to place the desired text into each field on the scanned document.

I thought it would be easy to make layer 0 invisible, layer 1 transparent and then print the desired text onto black documents. However I always get a gray background for layer 1 when printing. I'm sure I'm missing something here. How does one convince ImageEn to print only the text created with TextOut?

J.R.

xequte

38684 Posts

Posted - Jun 07 2016 :  00:17:41  Show Profile  Reply
Hi JR

Can you give me the steps to reproduce this issue in our of our demos.



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

jrpcguru

USA
266 Posts

Posted - Jun 07 2016 :  13:59:33  Show Profile  Reply
Boy did I have a typo. I'm trying to print text onto Blank, not Black documents.

I reviewed several demo programs to help start my current program. I used the Layers demo to learn about layers and PrintProjects to learn about printing. But I missed the TextOut example in the Layers demo. It provides the solution. Apparently ImageEnView1.Layers[1].Transparency is not what is needed to make the layer transparent for printing. This seems to work:

ImageEnView1.LayersAdd;
ImageEnView1.Proc.Fill( CreateRGB( 255,255,255 ) );
{use ImageEnView1.Proc.TextOut to place the text over each data field displayed in layer 0}
ImageEnView1.Proc.SetTransparentColors(
CreateRGB( 255, 255, 255 ),
CreateRGB( 255, 255, 255 ), 0 ); // remove the white, making it as transparent

So my original question is answered. Thank you.

But I find another question. I have 15 text fields to fill via TextOut. The underlying image displays in layer 0 nearly instantly, but TextOut seems notably slow to finish overlaying the text. Is this normal? I have tried both forms of TextOut, just in case listing the font for each TextOut was less efficient than setting it once on the canvas. No significant improvement.


J.R.
Go to Top of Page

xequte

38684 Posts

Posted - Jun 09 2016 :  00:17:29  Show Profile  Reply
Hi JR

Moving back a step, did you try using LayersCreateFromText:

http://www.imageen.com/help/TImageEnView.LayersCreateFromText.html

If you are experiencing slowness, can you advise how the steps to reproduce it?

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

jrpcguru

USA
266 Posts

Posted - Jun 09 2016 :  11:08:28  Show Profile  Reply
I did not try LayersCreateFromText. It does not appear to allow me to place text at the desired coordinates.

Here is the code that is slow (the slowness is all inside the loop):

  ImageEnView1.LayersAdd;
  ImageEnView1.Proc.Fill( CreateRGB( 255,255,255 ) );

      ImageEnView1.Layers[1].Opacity := 0.45;
      ImageEnView1.Layers[1].Visible := true;

  for I := 0 to 2 do
    begin

      ImageEnView1.Proc.TextOut(iDateLeft, iDateTop + (i * iCheckHeightLocal), 'MM/DD/YYYY ', 'Arial', 36, clBlack, [fsBold]);
      ImageEnView1.Proc.TextOut(iPayeeLeft, iPayeeTop + (i *  iCheckHeightLocal), sField, 'Arial', 36, clBlack, [fsBold]);
      ImageEnView1.Proc.TextOut(iNumericDollarsLeft , iNumericDollarsTop + (i *  iCheckHeightLocal) , '999999999', 'Arial', 36, clBlack, [fsBold]);
      ImageEnView1.Proc.TextOut(iTextDollarsLeft , iTextDollarsTop + (i *  iCheckHeightLocal) , sDollars, 'Arial', 36, clBlack, [fsBold]);
      ImageEnView1.Proc.TextOut(iMemoLeft , iMemoTop + (i *  iCheckHeightLocal) , sMemo, 'Arial', 24, clBlack, [fsBold]);
end;

  ImageEnView1.Proc.SetTransparentColors(
     CreateRGB( 255, 255, 255 ),
     CreateRGB( 255, 255, 255 ), 0 );    


I thought I had tried the first syntax for TextOut, but apparently not. I now find that this code is very quick, though I don't understand why I need to repeat the font setting on the canvas:

  for I := 0 to 2 do
    begin
		ImageEnView1.IEBitmap.Canvas.Font.Name := 'Arial';
		ImageEnView1.IEBitmap.Canvas.Font.Size := 36;
		ImageEnView1.IEBitmap.Canvas.Font.Color := clRed;
		
			  ImageEnView1.Proc.TextOut(iDateLeft, iDateTop + (i * iCheckHeightLocal), 'MM/DD/YYYY ', Nil, 0, false);
			  
		ImageEnView1.IEBitmap.Canvas.Font.Name := 'Arial';
		ImageEnView1.IEBitmap.Canvas.Font.Size := 36;
		ImageEnView1.IEBitmap.Canvas.Font.Color := clRed;
		
			  ImageEnView1.Proc.TextOut(iPayeeLeft, iPayeeTop + (i *  iCheckHeightLocal), sField, Nil, 0, false);
			  
		ImageEnView1.IEBitmap.Canvas.Font.Name := 'Arial';
		ImageEnView1.IEBitmap.Canvas.Font.Size := 36;
		ImageEnView1.IEBitmap.Canvas.Font.Color := clRed;
		
			  ImageEnView1.Proc.TextOut(iNumericDollarsLeft , iNumericDollarsTop + (i *  iCheckHeightLocal) , '999999999', Nil, 0, false);
			  
		ImageEnView1.IEBitmap.Canvas.Font.Name := 'Arial';
		ImageEnView1.IEBitmap.Canvas.Font.Size := 36;
		ImageEnView1.IEBitmap.Canvas.Font.Color := clRed;
		
			  ImageEnView1.Proc.TextOut(iTextDollarsLeft , iTextDollarsTop + (i *  iCheckHeightLocal) , sDollars, Nil, 0, false);
			  
		ImageEnView1.IEBitmap.Canvas.Font.Name := 'Arial';
		ImageEnView1.IEBitmap.Canvas.Font.Size := 24;
		ImageEnView1.IEBitmap.Canvas.Font.Color := clRed;
		
			  ImageEnView1.Proc.TextOut(iMemoLeft , iMemoTop + (i *  iCheckHeightLocal) , sMemo, Nil, 0, false);   
end;


I'm wondering if I'm doing something wrong with the second syntax for TextOut. The first syntax clearly works well now, if I set the canvas before each TextOut. If not it sometimes reverts to a much smaller font.

J.R.
Go to Top of Page

jwest

Brazil
67 Posts

Posted - Jun 09 2016 :  13:52:25  Show Profile  Reply
What about to call ImageEnView1.LockUpdate before the loop and ImageEnView1.UnLockUpdate after it?
Go to Top of Page

jrpcguru

USA
266 Posts

Posted - Jun 09 2016 :  14:07:57  Show Profile  Reply
The first syntax is virtually as fast as displaying the Layer0 image. The second syntax remains deathly slow even with LockUpdate and UnLockUpdate;


J.R.
Go to Top of Page

jwest

Brazil
67 Posts

Posted - Jun 09 2016 :  15:00:58  Show Profile  Reply
What happend if you use:

ImageEnView1.Layers[X].Bitmap.Canvas.TextOut(x,y,text) where X is your layer index instead of
ImageEnView1.Proc.TextOut(iDateLeft, iDateTop + (i * iCheckHeightLocal), 'MM/DD/YYYY ', Nil, 0, false);
Go to Top of Page

jrpcguru

USA
266 Posts

Posted - Jun 09 2016 :  15:37:43  Show Profile  Reply

  ImageEnView1.LockUpdate ;

  ImageEnView1.IEBitmap.Canvas.Font.Name := 'Arial';
ImageEnView1.IEBitmap.Canvas.Font.Size := 36;
ImageEnView1.IEBitmap.Canvas.Font.Color := clRed;
ImageEnView1.IEBitmap.Canvas.Font.Style := [fsBold];

  for I := 0 to 2 do
    begin


ImageEnView1.IEBitmap.Canvas.Font.Size := 36;
      ImageEnView1.Layers[1].Bitmap.Canvas.TextOut(iDateLeft,iDateTop + (i * iCheckHeightLocal), 'MM/DD/YYYY ') ;
      ImageEnView1.Layers[1].Bitmap.Canvas.TextOut(iPayeeLeft,iPayeeTop + (i * iCheckHeightLocal), sField) ;
      ImageEnView1.Layers[1].Bitmap.Canvas.TextOut(iNumericDollarsLeft,iNumericDollarsTop + (i * iCheckHeightLocal), '999999999') ;
      ImageEnView1.Layers[1].Bitmap.Canvas.TextOut(iTextDollarsLeft,iTextDollarsTop + (i * iCheckHeightLocal), sDollars) ;
ImageEnView1.IEBitmap.Canvas.Font.Size := 24;
      ImageEnView1.Layers[1].Bitmap.Canvas.TextOut(iMemoLeft,iMemoTop + (i * iCheckHeightLocal), sMemo) ;
ImageEnView1.UnLockUpdate;



This executes just as fast as displaying the image and is simpler than my previous code using the first syntax of proc.TextOut. I wonder if we have identified an inefficiency in the first syntax of Proc.TextOut?

J.R.
Go to Top of Page

xequte

38684 Posts

Posted - Jun 09 2016 :  17:04:27  Show Profile  Reply
Well the only difference is the first TextOut overload needs to create a TFont object. Though I'm surprised font creation should be so noticeably slow.

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

jrpcguru

USA
266 Posts

Posted - Jun 09 2016 :  17:22:39  Show Profile  Reply
There is really a huge difference in speed. To use the first overload I would need to keep everything hidden with an hourglass while it processes. The gap between displaying layer 0 and filling layer 1 with text is several seconds.

With the alternative methods that you have helped me to discover, it displays almost instantaneously. A user won't even realize that two separate layers have loaded and displayed.

Thank you for the help.

I'm using Win 7 Pro with 12 gig of ram and a 2 core i7 cpu, if that has anything to do with font creation speed.

J.R.
Go to Top of Page

xequte

38684 Posts

Posted - Jun 09 2016 :  18:30:41  Show Profile  Reply
I'll investigate a performance fix.



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

jwest

Brazil
67 Posts

Posted - Jun 09 2016 :  18:58:55  Show Profile  Reply
Hi, good. I have seen Mr Nigel answered you.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: