1

What would be the correct way to create a Bitmap (eventually I want to save a jpg) from the current view in a HelixViewport3D?

I'm currently using this (simplified) class as a DataContext to load a STL File to the ViewPort:

public class StlFile : INotifyPropertyChanged
{
    Model3D file;
    Model3DGroup objectToShow = new Model3DGroup();

    public event PropertyChangedEventHandler PropertyChanged;

    public Model3DGroup Model
    {
        get
        {
            return objectToShow;
        }

        set
        {
            objectToShow = value;    
            OnPropertyChanged("Model");
        }
    }

    public void LoadFile(string path)
    {
        Material material = new DiffuseMaterial(new SolidColorBrush(Colors.Beige));
        ModelImporter importer = new ModelImporter();
        importer.DefaultMaterial = material;

        file = importer.Load(path);
        objectToShow.Children.Add(file);
        Model = objectToShow;
    }

    protected void OnPropertyChanged(string info)
    {
        if (PropertyChanged != null)
            PropertyChanged(this, new PropertyChangedEventArgs(info));
    }
}

And this XAML Code:

<HelixToolkit:HelixViewport3D ZoomExtentsWhenLoaded="True" Margin="0,63,0,0" Name="helixViewport" ShowViewCube="False" IsMoveEnabled="True">
    <HelixToolkit:SunLight/>
    <ModelVisual3D Content="{Binding Model}"/>
</HelixToolkit:HelixViewport3D>

All of this is working fine so far. What I want to do now is to save the current view of the HelixViewport3d to a jpg file. I'searched in the docs but can't really find anything about it. Thank you for your Help!

CSDev
  • 3,177
  • 6
  • 19
  • 37
Romano Zumbé
  • 7,893
  • 4
  • 33
  • 55

0 Answers0