Hide menu
Loading...
Searching...
No Matches
Thumbnail Generation Example

Table of Contents

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();
// Opening and converting the file
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();
// Set writer parameters
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:
// Generate the model image and save it into the file
if (!aWriter.WriteFile(aModel, new UTF16String(aDest)))
{
Console.WriteLine("Failed to write the file " + aDest);
return 1;
}

Files