Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active October 12, 2021 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/412be21b594854e6ab040987c3c498b2 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/412be21b594854e6ab040987c3c498b2 to your computer and use it in GitHub Desktop.
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