Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert DGN to JPEG, PNG, or TIFF Image Programmatically in C#
// Load input DGN file using Image class
Image image = Image.Load("template.dgn");
// Initialize an object of CadRasterizationOptions
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions()
{
PageWidth = 1600,
PageHeight = 1600
};
// Create an instance of JpegOptions
JpegOptions options = new JpegOptions();
// Set CadRasterizationOptions properties
options.VectorRasterizationOptions = rasterizationOptions;
// Convert DGN to JPG image
image.Save("output.jpg", options);
// Load DGN file using Image class
Image image = Image.Load("template.dgn");
// Create an instance of CadRasterizationOptions and set image height & width
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions()
{
PageWidth = 1600,
PageHeight = 1600
};
// Create an instance of PngOptions
PngOptions options = new PngOptions();
// Set the VectorRasterizationOptions property as CadRasterizationOptions
options.VectorRasterizationOptions = rasterizationOptions;
// Convert DGN to PNG Image
image.Save("output.png", options);
// Load input DGN file using Image class
Image image = Image.Load("template.dgn");
// Initialize an object of CadRasterizationOptions
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions()
{
PageWidth = 1600,
PageHeight = 1600
};
// Create an instance of TiffOptions
TiffOptions options = new TiffOptions(FileFormats.Tiff.Enums.TiffExpectedFormat.Default);
// Set the VectorRasterizationOptions property
options.VectorRasterizationOptions = rasterizationOptions;
// Convert DGN to TIFF Image
image.Save("output.tiff", options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment