CADImage.SaveToStream

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
Yoshitoki
Posts: 5
Joined: 30 Jan 2014, 10:39

CADImage.SaveToStream

Post by Yoshitoki » 14 Feb 2014, 08:05

Hello,

I have a trouble.
In the CADImage.SaveToStream(xx, xx, CADImport.DRect, xx) of CAD Import .NET V9,
I would like to set more 10,000 x 10,000 pixel at DRect.

But I cannot do it.

Error Code
at System.Drawing.Graphics.GetHdc()
at CADImport.CADGraphicsGDI.SetSpecialparameters()
at CADImport.CADPainter'1.(CADImage,DRect)


Please help me.

Yoshitoki,

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: CADImage.SaveToStream

Post by support » 17 Feb 2014, 17:31

Hello Yoshitoki,

Please, post your code here, so we could check it.


Mikhail.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Yoshitoki
Posts: 5
Joined: 30 Jan 2014, 10:39

Re: CADImage.SaveToStream

Post by Yoshitoki » 17 Feb 2014, 18:45

Hello Mikhail,

Code is here.
Please check it.
I'd like to covert to a 300Dpi TIFF from a A0 size drawing.

Code: Select all

fileDpi = 300;
'DrawingSize = A0size, Width 1189mm(millimeter),Hight 841mm

curRect     = New DRect(cadImage.Extents.left   / _LENGTH_INCH * fileDpi,
		cadImage.Extents.top       / _LENGTH_INCH * fileDpi,
		cadImage.Extents.right     / _LENGTH_INCH * fileDpi,
		cadImage.Extents.bottom / _LENGTH_INCH * fileDpi)

clipRect    = New DRect((cadImage.Extents.left + Abs(cadImage.Extents.left - cadImage.PureExtents.left)                             ) / _LENGTH_INCH * fileDpi,
		(cadImage.Extents.top  + Abs(cadImage.Extents.top    - cadImage.PureExtents.top)                              ) / _LENGTH_INCH * fileDpi,
		(cadImage.Extents.left + Abs(cadImage.Extents.left    - cadImage.PureExtents.left)  + cadImage.PureExtents.Width ) / _LENGTH_INCH * fileDpi,
		(cadImage.Extents.top  + Abs(cadImage.Extents.top    - cadImage.PureExtents.top)  + cadImage.PureExtents.Height) / _LENGTH_INCH * fileDpi )

imageStream = New MemoryStream()
cadImage.SaveToStream(imageStream,Imaging.ImageFormat.Tiff,curRect,clipRect,Imaging.PixelFormat.Format1bppIndexed)


support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: CADImage.SaveToStream

Post by support » 19 Feb 2014, 17:09

Hello Yoshitoki,

What is the _LENGTH_INCH value in your code?


Mikhail.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Yoshitoki
Posts: 5
Joined: 30 Jan 2014, 10:39

Re: CADImage.SaveToStream

Post by Yoshitoki » 20 Feb 2014, 13:10

Hello Mikhail,

_LENGTH_INCHI As Double = 25.4

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: CADImage.SaveToStream

Post by support » 25 Mar 2014, 13:09

Hello Yoshitoki.

Please take our apologies for the delayed reply.

Unfortunately CAD drawing format not mentioned. For example, DWG and DXF formats are unitless. Such drawings measured in drawing units, not in millimeters or inches. A layout in your drawing can include print settings with A0 paper size defined. However drawing width and height can be much greater. Please check cadImage.Extents for the mentioned drawing.

CAD coordinates increase from left to right and from bottom to top. Calculation of clipRect in your code is incorrect. Resulting Drect object will envelop space that is above layout extents.
Also please note, clipRect must have Rectangle type, not DRect. This is a possible cause of the problem. And if you need to save full layout, then use SaveToStream(Stream, ImageFormat, DRect, PixelFormat) method version. SaveToStream(Stream, ImageFormat, DRect, Rectangle) must be used to save a specified part of source cadImage.

Please note, cadImage.Extents only difference from cadImage.PureExtents is visual border. This border is not a part of drawing, but added for better cadImage visualization. The border is customizable: cadImage.IsWithoutMargins switches it off and BorderType/BorderSize allow to set its size. So you can just customize and use cadImage.Extents if you need a border or cadImage.PureExtents if not.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply