DGN files are two-dimensional or three-dimensional (2D/3D) drawings supported by construction CAD applications. In certain cases, you may need to convert a DGN file to an image for previewing it in different system environments. This article covers how to convert DGN to JPEG, PNG, or TIFF image with all the important details:
- DGN to JPEG, PNG, or TIFF Image Converter – C# API Installation
- Convert DGN File to JPEG Image Programmatically with C#
- Convert DGN to PNG Image Programmatically using C#
- DGN to TIFF Image Conversion Programmatically in C#
DGN to JPEG, PNG, or TIFF Image Converter – C# API Installation
Aspose.CAD for .NET API supports creating, editing, and manipulating DGN files and several other file formats. You can configure the API by downloading the DLL file from the New Releases, or using the following NuGet installation command:
PM> Install-Package Aspose.CAD
Convert DGN File to JPEG Image Programmatically with C#
You can convert a DGN file to a JPEG image with the following steps:
- Load input DGN file using the Image class.
- Initialize an object of CadRasterizationOptions class.
- Create an instance of JpegOptions class.
- Convert the DGN to a JPG image with the Save method.
The following code snippet shows how to convert a DGN file to a JPEG image programmatically using C#:
Convert DGN to PNG Image Programmatically using C#
You can convert a DGN file to a PNG image with the steps below:
- Load input DGN file with the Image class.
- Create an instance of CadRasterizationOptions and set image height & width.
- Create an instance of PngOptions and set VectorRasterizationOptions.
- Convert the DGN to a PNG Image using Image.Save method.
The code sample below explains how to convert a DGN file to a PNG image programmatically with C#:
DGN to TIFF Image Conversion Programmatically in C#
You can convert a DGN file to a TIFF image with the below steps:
- Load input DGN file using the Image class.
- Initialize an object of CadRasterizationOptions class.
- Create an instance of TiffOptions type.
- Set the VectorRasterizationOptions property.
- Convert the DGN to a TIFF image with the Save method.
The following code snippet shows how to convert a DGN file to a TIFF image programmatically in C#:
Get Free Temporary License
You can evaluate the API without any limitations by requesting a Free Temporary License.
Conclusion
In this article, you have learned how to convert a DGN file to different image formats like JPEG, PNG, or TIFF programmatically using C#. You can take a look at several other features of the API by visiting the Documentation. In case of any queries, please get in touch with us at the Free Support Forum.