Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print SCP intermittent error #12

Open
iamps opened this issue Sep 8, 2017 · 15 comments
Open

Print SCP intermittent error #12

iamps opened this issue Sep 8, 2017 · 15 comments
Labels

Comments

@iamps
Copy link

iamps commented Sep 8, 2017

Print scp intermittently throws following error even if same job is sent to it which was just printed:

Print Job 5581685231640871 Status Failure: Printing failed, exception: System.ArgumentException: Parameter is not valid.
   at System.Drawing.Image.get_Height()
   at Dicom.Printing.ImageBoxExtensions.DrawBitmap(Graphics graphics, RectF box, Image bitmap, Int32 imageResolution, String emptyImageDensity) in C:\fo-dicom\DICOM\Printing\ImageBoxExtensions.cs:line 129
   at Dicom.Printing.ImageBoxExtensions.Print(ImageBox imageBox, Graphics graphics, RectF box, Int32 imageResolution) in C:\fo-dicom\DICOM\Printing\ImageBoxExtensions.cs:line 55
   at Dicom.Printing.FilmBoxExtensions.Print(FilmBox filmBox, Graphics graphics, Rectangle marginBounds, Int32 imageResolution) in C:\fo-dicom\DICOM\Printing\FilmBoxExtensions.cs:line 92
   at Dicom.Printing.PrintJob.OnPrintPage(Object sender, PrintPageEventArgs e) in F:\fo-dicom 06Sept2017\fo-dicom-samples-master\Desktop\Print SCP\PrintJob.cs:line 350
   at System.Drawing.Printing.PrintDocument.OnPrintPage(PrintPageEventArgs e)
   at System.Drawing.Printing.PrintDocument._OnPrintPage(PrintPageEventArgs e)
   at System.Drawing.Printing.PrintController.PrintLoop(PrintDocument document)
   at System.Drawing.Printing.PrintController.Print(PrintDocument document)
   at System.Drawing.Printing.PrintDocument.Print()
   at Dicom.Printing.PrintJob.DoPrint() in F:\fo-dicom 06Sept2017\fo-dicom-samples-master\Desktop\Print SCP\PrintJob.cs:line 325

What could be the reason.

@anders9ustafsson
Copy link
Contributor

Thanks for reporting, @iamps. I have occasionally seen a similar error, and I suspect that it has something to do either with ownership or disposal of the rendered Bitmap. Which version of the fo-dicom NuGet package are you using?

@iamps
Copy link
Author

iamps commented Sep 8, 2017 via email

@anders9ustafsson
Copy link
Contributor

Sorry for being unclear. I meant which fo-dicom version are you using?

@iamps
Copy link
Author

iamps commented Sep 8, 2017 via email

@iamps
Copy link
Author

iamps commented Sep 8, 2017 via email

@anders9ustafsson
Copy link
Contributor

The samples have not been updated to use 3.1.0-alpha. It would help though if you could publish the errors you are getting with that version. Is it compilation errors or runtime errors?

@iamps
Copy link
Author

iamps commented Sep 8, 2017 via email

@iamps
Copy link
Author

iamps commented Sep 8, 2017 via email

@iamps
Copy link
Author

iamps commented Sep 9, 2017

Please suggest correction.

@iamps
Copy link
Author

iamps commented Sep 9, 2017

I think I was using wrong Dicomcore.dll.
Used ver 3.0.0.4 , also the original issue of bitmap resolved.

Thanks

@gofal
Copy link
Contributor

gofal commented Jan 19, 2018

So is this issue now still open, or can it be closed?

@tartinesKiller
Copy link

tartinesKiller commented Mar 13, 2018

In fact, I'm victim of theses errors, and I can't find a way to solve them. My version is 3.0.2.
I'm using the same Bitmap object (created from RenderImage().AsBitmap()) to save the image in multiple resolutions, and I've noticed the error never occurs on the first .Save() call. I'm not calling .Dispose() on anything before having finished.
Maybe the issue is related? Do you think calling RenderImage().AsBitmap() for every save is necessary?

@gofal
Copy link
Contributor

gofal commented Mar 13, 2018

This relates to the issue in fo-dicom fo-dicom/fo-dicom#634
There is already a pull request solving this issue. Of course you did not dispose the Bitmap. But the RenderImage().AsBitmap() returns a Bitmap that does NOT own its own memory but instead points to the memory owned by the IImage object (the one with the method RenderImage()). If then the garbage collector dispose this IImage object, then the memory containing the pixel data is erased and the Bitmaps pointer gets invalid.
Until the fix is published in next release, you could just keep the IImage instance in memory, eg as a member variable in the same scope as the Bitmap. Or you always create the Bitmap with RenderImage().AsBitmap().Clone() which immediatelly copies the whole pixel data into a new memory that is then owend by the Bitmap.

@tartinesKiller
Copy link

Thanks for the great explanation! I didn't find the existing issue, sorry.

@gofal gofal added the bug label Mar 15, 2018
@GeovaneW96
Copy link

Is it resolved?
I still get the error using AsClonedBitmap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants