Demonstrates how to generate and save an image of a model.
Overview
In this example we create a View.ImageWriter object which allows us to generate and save an image of ModelData.Model .
Implementation
The main function will have the following structure:
Model aModel = new Model();
if (!new ModelReader().Read(new UTF16String(aSource), aModel))
{
Console.WriteLine("Failed to read the file " + aSource);
return 1;
}
ImageWriter aWriter = new ImageWriter();
ImageWriterParameters aWriterParameters = new ImageWriterParameters();
aWriterParameters.SetImageWidth(1280);
aWriterParameters.SetImageHeight(720);
aWriterParameters.SetViewIsFitAll(true);
var aBackground = new ColorBackgroundStyle(new Color(255, 255, 255));
aWriterParameters.SetViewBackground(aBackground);
aWriter.SetParameters(aWriterParameters);
- Generate an image of a model and save it into a file:
if (!aWriter.WriteFile(aModel, new UTF16String(aDest)))
{
Console.WriteLine("Failed to write the file " + aDest);
return 1;
}
Files