Operations > OP_CAD2D |
OP_CAD2D: Convert a CAD Drawing File to a DIB
The purpose of OP_CAD2D (see opcode specific data structure) is to convert CAD drawing files to DIBs. This opcode supports conversion of the following types of files:
The overall processing flow for this opcode is as follows:
This opcode supports multiple, successive REQ_EXEC operations, without intervening REQ_TERM or REQ_INIT operations. This is useful for multiple renderings of the same image, for example, if zooming or panning around the image. Executing multiple REQ_EXEC operations is more efficient in that it eliminates the need to perform the REQ_INIT processing. Of course, if a different CAD file is to be processing, then REQ_INIT must be executed for the new file.
A CAD drawing file can contain multiple layouts, however, only a single layout can be rendered to a DIB at one time. The LayoutToRender field is used to select the desired layout. It defaults to the active layout. The active layout is the layout that was last active in the CAD application when the drawing file was saved. To render the Model Space layout, the LayoutToRender field may be set to the value RENDER_MODEL_SPACE.
A CAD drawing file can also contain multiple layers. The drawing layers are specified in the Layers array element field. To exclude a layer from the rendered bitmap, set the Layer[n].Off field to TRUE. Multiple layers may be excluded from the output. Also, if layers turned off in the input file, these layers can be included in the output bitmap by setting the Layer[n].Off field to FALSE.
The dimensions of the output DIB are specified by setting RenderWidth and RenderHeight. These fields must be set by the client application.
The bit depth of the output DIB can be specified by setting RenderBitDepth. The default is 8bpp. Allowable values are 1, 4, 8, 24, and 32 bpp.
The background color of the output DIB can be specified by setting BackgroundColor. This field is an RGBQUAD structure that allows setting the Red, Green, and Blue values. The default is white (255, 255, 255).
The output DIB can be cropped to a specified subrectangle by setting F_InputCrop in PicParm.Flags and setting PicParm.IOCropXoff, PicParm.IOCropYoff, PicParm.IOCropWidth, and PicParm.IOCropHeight to describe the subrectangle. PicParm.IOCropXoff and PicParm.IOCropYoff are offsets within the image dimensions specified with the RenderWidth and RenderHeight fields.
Set CAD.PicFlags |= PF_NoDibPad to avoid any padding of output lines otherwise output lines are padded to a multiple of 4 bytes.
To set the width of the output line to be other than no padding or padding to a multiple of 4 bytes, set CAD.PicFlags |= PF_WidthPadKnown, and set CAD.WidthPad to the desired width in bytes.
CAD files may contain embedded thumbnail previews. If requested, the opcode will return the thumbnail in the form of a DIB. In order to request a thumbnail, set CAD.PicFlags |= PF_ExpandThumbnail prior to invoking REQ_INIT processing. If the CAD file contains a thumbnail, the opcode will return the the DIB information in the PicParm.Head field. The DIB can then be obtained by issuing REQ_EXEC, with CAD.PicFlags |= PF_ExpandThumbnail. If the file does not contain a thumbnail, the opcode will return ERR_MISSING_TNUMBNAIL in response to the REQ_INIT. Support is not currently provided for obtaining thumbnails from DWF files. If the file contains a thumbnail, but it is in a format other than an uncompressed bitmap, the opcode will return ERR_UNSUPPORTED_THUMBNAIL_FORMAT.
CAD drawings may contain text elements that rely upon specific fonts. If the specified fonts are not installed on the machine that is running the opcode, the associated text fields may not render as expected.
A CAD drawing may contain Architectural Desktop elements. The opcode does not currently support Architectural Desktop elements, so these elements may not render as expected. Support for Architectural Desktop elements is planned for a future release.