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
 Printing error
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Audax

Slovenia
5 Posts

Posted - Feb 10 2022 :  08:19:13  Show Profile  Reply
Hi

I've used the bottom code to print the ImageEnMain(TImageEnVect) content and for years and it worked just well.


procedure TfrmTest.Print;
var
  TmpBmp: TIEBitmap;
begin
  // ImageEnMain contains a few layers...
  ImageEnMain.LayersCurrent:= 0;
  tmpBmp:= TIEBitmap.Create(ImageEnMain.IEBitmap.Width, ImageEnMain.IEBitmap.Height);

  try
    tmpBmp.AssignImage(ImageEnMain.IEBitmap);
    ImageEnPrint.AttachedIEBitmap:= tmpBmp;

    ImageEnMain.LayersDrawTo(tmpBmp);

    Printer.Title:= ExtractFileName(Application.ExeName) + '-printing';
    if cbxPortrait.Checked then
      Printer.Orientation:= poPortrait
    else
      Printer.Orientation:= poLandscape;

    if PrintDialog.Execute then
    begin
      Printer.BeginDoc;
      ImageEnPrint.PrintImage(Printer.Canvas,
                      0,
                      0,
                      0,
                      0,
                      ievpCENTER,
                      iehpCENTER,
                      iesSPECIFIEDSIZE,
                      PaperWidthCm / 2.54,
                      PaperHeightCm / 2.54,
                      1);
	  // PaperWidthCm and PaperHeightCm are calculated before...				  
      Printer.EndDoc;
    end;
  finally
    tmpBmp.Free;
  end;

end;


But after upgrading from version 6.3.0 to 9.2.0 I get an error "Out of memory".

 

compiled with : Delphi 10.4 Sydney
madExcept version : 5.1.1
callstack crc : $e8e65e3a, $cdca047b, $3a89a4f1
exception number : 1
exception class : EOutOfMemory
exception message : Out of memory.

main thread ($41b0):
00410437 +16b Test.exe System 4831 +0 DynArraySetLength
00410599 +005 Test.exe System 4831 +0 @DynArraySetLength
01179600 +1c8 Test.exe imageenproc _ResampleLinearEx
01176492 +30e Test.exe imageenproc _ResampleEx
011ea037 +33f Test.exe iexBitmaps TIEBitmap.RenderToCanvas
010fd81d +0b9 Test.exe imageenio ImageEnPrint.PrintImagePosEx
010fe1a1 +69d Test.exe imageenio ImageEnPrint.PrintImageEx
010fe6bf +0e7 Test.exe imageenio ImageEnPrint.PrintImage




If I change PrintDialog with PrinterSetupDialog it works again until I
try to print on "Microsoft Print to PDF".
Than the error is back.

Is this a bug that will be resolved in the next version, or do I have to change
somethink in my code?

Best regards.

xequte

38608 Posts

Posted - Feb 10 2022 :  21:23:48  Show Profile  Reply
Hi

Does it only fail when printing to "Print to PDF"?

How large is the image?

What is the value of ImageEnPrint.PrintingFilterOnSubsampling? Does changing it affect the issue?

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

Audax

Slovenia
5 Posts

Posted - Feb 25 2022 :  05:18:36  Show Profile  Reply
Hi,

I've set the PrintingFilterOnSubsampling to rfNone.
It works now, but it seems to me that the quality of the print is not as good as it used to be.

We are printing radiology photos with high resolution and at this point
I don't know which type of printing filter would be best for our purpose.

Do you have any suggestion?


Best regards.
Go to Top of Page

xequte

38608 Posts

Posted - Feb 27 2022 :  14:45:12  Show Profile  Reply
Hi

Do you enable the PrintLayers or PrintAnnotations parameters when calling ImageEnView1.IO.DoPrintPreviewDialog()?

Prior to printing, what is the value of "b":

b := (ImageEnView1.IEBitmap.HasAlphaChannel and not ImageEnView1.IEBitmap.AlphaChannel.Full)?

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

Audax

Slovenia
5 Posts

Posted - Mar 03 2022 :  08:06:23  Show Profile  Reply
Hi

I am not using IO.DoPrintPreviewDialog,
but TPrintDialog/TPrinterSetupDialog (from Vcl.Dialogs) in combination with ImageEnIO.PrintImage.
As written in the first post.

I didn't know that DoPrintPreviewDialog exist, will try it now.

The value of b is True.

Best regards.
Go to Top of Page

xequte

38608 Posts

Posted - Mar 03 2022 :  21:12:58  Show Profile  Reply
Sorry, I meant PrintImage() rather than DoPrintPreviewDialog().

The main difference between 6.3.0 and 9.2.0, is that printing is now alpha channel aware, so if the image contains an alpha channel, a copy is made of the bitmap.

Can you try removing the alpha channel so it functions the same as v6.3.0?

e.g. tmpBmp.RemoveAlphaChannel( True, clWhite );

https://www.imageen.com/help/TIEBitmap.RemoveAlphaChannel.html


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

Audax

Slovenia
5 Posts

Posted - Mar 04 2022 :  07:27:26  Show Profile  Reply
Hi

I've removed the alpha channel.

But now I have another question...
I've decided to remove the print preview and go directly to printing.
So, I used the IO.PrintImage(), but every approach I've tried gave me the same error:

ExceptionMessage="Printer is not currently printing"
ExceptionName="EPrinter"
ExceptionDisplayName="EPrinter"

I even tried one of your sugestions I've found on this forum.
https://www.imageen.com/ieforum/topic.asp?TOPIC_ID=2473&SearchTerms=PrintImage(

with TImageEnView.Create(nil) do
begin
IEBitmap.Assign(ImageEnPrint.IEBitmap);
ImageEnPrint.DrawObjectsToBitmap(IEBitmap);
IO.PrintImage(Printer.Canvas, 0, 0, 0, 0, ievpCenter, iehpCenter, iesNormal);
Free();
end;

It's strange, because the bottom code works just fine and I never get that error.

ImageEnPrint.LayersCurrent:= 0;
tmpBmp:= TIEBitmap.Create(ImageEnPrint.IEBitmap.Width, ImageEnPrint.IEBitmap.Height);

try
tmpBmp.AssignImage(ImageEnPrint.IEBitmap);
tmpBmp.RemoveAlphaChannel( True, clWhite );
ImageEnIO.AttachedIEBitmap:= tmpBmp;

ImageEnPrint.LayersDrawTo(tmpBmp);

if cbxPortrait.Checked then
Printer.Orientation:= poPortrait
else
Printer.Orientation:= poLandscape;

ImageEnIO.PrintPreviewParams.MarginTop := 0;
ImageEnIO.PrintPreviewParams.MarginBottom := 0;
ImageEnIO.PrintPreviewParams.MarginLeft := 0;
ImageEnIO.PrintPreviewParams.MarginRight := 0;

ImageEnIO.DoPrintPreviewDialog;

finally
tmpBmp.Free;
end;

Any idea?

Best regards.
Go to Top of Page

Audax

Slovenia
5 Posts

Posted - Mar 04 2022 :  10:14:22  Show Profile  Reply
Hi,

Bdw, I have forgotten to mention in the previous post,
that if I remove the alfa chanel using
tmpBmp.RemoveAlphaChannel( True, clWhite );
and leave PrintingFilterOnSubsampling as it is and do not set it to rfNone.
I still get out of memmory.
Looks like alfa channel is not he problem.

I have also noticed that the problem appears on average PCs.
On powerfull PCs there is no "out of memory" .
By average PCs I mean still preety good ones.
Those same PCs that did't have any problem with printing the same kind of images in Imageen version 6.3.0.


Best regards.
Go to Top of Page

xequte

38608 Posts

Posted - Mar 05 2022 :  20:07:58  Show Profile  Reply
Hi

I cannot recall when we transitioned, but in v9.2.0 you may need still need to wrap your PrintImage() call with:

  Printer.BeginDoc();
  ImageEnView1.IO.PrintImage();
  Printer.EndDoc();


Regarding your memory issue, can you please forward me a sample image and let me see if I can reproduce it here.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: