Getting error while converting dwg file into JPEG image

1
Sachin Tripathi
1/24/2020 8:06 AM

Hi Wout,

We are getting error while converting dwg(in case of larger file size 2.6MB or more) file into jpeg image using code below:

C# Code:
Size maxSize = new Size(4800, 3600);
Image<Rgba64> imageBitmap = ImageExporter.CreateAutoSizedBitmap<Rgba64>(dxfModel, Matrix4D.Identity, GraphicsConfig.AcadLikeWithWhiteBackground, maxSize ); 

Error below:

{"An error occurred when processing the image using FillRegionProcessor`1. See the inner exception for more detail."}

at SixLabors.ImageSharp.Processing.Processors.ImageProcessor`1.Apply(Image`1 source, Rectangle sourceRectangle)
at SixLabors.ImageSharp.Processing.DefaultInternalImageProcessorContext`1.ApplyProcessor(IImageProcessor`1 processor, Rectangle rectangle)
at SixLabors.ImageSharp.Processing.DefaultInternalImageProcessorContext`1.ApplyProcessor(IImageProcessor`1 processor)
at SixLabors.ImageSharp.Processing.DrawPathExtensions.Draw[TPixel](IImageProcessingContext`1 source, IPen`1 pen, IPath path)
at WW.Cad.Drawing.NetCore.NetCoreGraphics3D.`1.(IImageProcessingContext`1 )
at SixLabors.ImageSharp.Processing.ProcessingExtensions.Mutate[TPixel](Image`1 source, Action`1 operation)
at WW.Cad.Drawing.NetCore.NetCoreGraphics3D.Draw[TPixel](Image`1 bitmap, Rectangle drawingBounds, Matrix4D transform, ArgbColor backColor)
at WW.Cad.IO.ImageExporter.CreateBitmap[TPixel](DxfModel model, Matrix4D transform, GraphicsConfig graphicsConfig, ImageRenderOptions renderOptions, Int32 width, Int32 height)
at WW.Cad.IO.ImageExporter.CreateAutoSizedBitmap[TPixel](DxfModel model, Matrix4D transform, GraphicsConfig graphicsConfig, ImageRenderOptions renderOptions, Size maxSize)
at WW.Cad.IO.ImageExporter.CreateAutoSizedBitmap[TPixel](DxfModel model, Matrix4D transform, GraphicsConfig graphicsConfig, Size maxSize)


We are using WW.Cad.NetStandard(Version-1.0.0-rc44).
If you required that dwg file for debugging, I'll share in different email thread.

Regards,
Sachin

Wout
1/24/2020 11:18 AM

When you post a topic on the forum, a text is shown that describes what the forum post should contain, please follow those instructions.

Thank you,

- Wout

Sachin Tripathi
1/31/2020 8:46 AM

Hi Wout,

I sent an email with sample code & input file that will help to reproduce.
Note: We are also facing performance issue while converting dwg file into jpeg images. That is impacting our user experience. Do we have any other workaround or documentation for converting drawing file to jpeg?

Thank you.
Sachin

Sachin Tripathi
2/6/2020 7:09 AM

Hi Wout,

I hope you received that email with sample code & file and able to replicate this issue.
Do we have any update on this?

Regards,
Sachin

Wout
2/6/2020 3:30 PM

Hi,

I can't reproduce the problem with the latest WW.Cad version on Windows 10. Since you're using almost the latest version I don't quite understand why the problem occurs on your machine but not on mine.

- Wout

Edit: attached is the generated jpg.

Wout
2/6/2020 3:35 PM

This looks very similar to an issue that was present in the ImageSharp version 1.0.0-beta0006, which I reported last year in June and that has been fixed in a later ImageSharp version. Can you make sure you're not using an older WW.Cad/ImageSharp version?

See here the original report.

Note that you did not report the exception that occurred on your side. The one in the issue I just mentioned is the IndexOutOfRangeException.

- Wout

Wout
2/6/2020 3:41 PM

By the way, do you have an absolute need for this many pixels?

It's a rather unusually large bitmap, and you're probably better off just inserting an block XREF into your other drawing.

- Wout

Sachin Tripathi
2/10/2020 7:06 AM

Hi Wout,

Yes, we need to convert dwg file into large JPEG image (ArchE size 48*36 inches or 4800*3600 pixels) that's why we are using that method. Can you please suggest if we have any other way to achieve this? Also this method is taking too much time to convert into JPEG image.

FYI, we are using resources on Azure like Win 2016 and IIS 8.5+ where we are getting this error.

Regards,
Sachin

Wout
2/11/2020 11:23 AM

You could get a similar image with for example 1200 * 900 pixels, and divide the GraphicsConfig.DotsPerInch value that you're using by 4. Obviously it's less pixels, and thus less detail information, maybe it's good enough, maybe not. That's why I asked why you were specifically using the number of pixels that you were using.

On .NET Core the rendering is using software rendering, which was the only option available at the time, so it's considerably slower than CadLib's GDI+ rendering. A few months ago System.Drawing.Common became available, which uses GDI+, but I haven't had time to look at it yet. I'll probably check it out in the second half of this year.

- Wout

1