// --------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) 2014 OxyPlot contributors
//
//
// Represents a control that displays a .
//
// --------------------------------------------------------------------------------------------------------------------
namespace OxyPlot.Avalonia
{
using global::Avalonia.Media.Imaging;
using System.IO;
///
/// Represents a control that displays a .
///
public partial class PlotBase
{
///
/// Saves the PlotView as a bitmap.
///
/// Stream to which to write the bitmap.
public void SaveBitmap(Stream stream)
{
SaveBitmap(stream, -1, -1, ActualModel.Background);
}
///
/// Saves the PlotView as a bitmap.
///
/// Stream to which to write the bitmap.
/// The width.
/// The height.
/// The background.
public void SaveBitmap(Stream stream, int width, int height, OxyColor background)
{
if (width <= 0)
{
width = (int)Bounds.Width;
}
if (height <= 0)
{
height = (int)Bounds.Height;
}
if (!background.IsVisible())
{
background = Background.ToOxyColor();
}
PngExporter.Export(ActualModel, stream, width, height, background);
}
///
/// Renders the PlotView to a bitmap.
///
/// A bitmap.
public Bitmap ToBitmap()
{
var background = ActualModel.Background.IsVisible() ? ActualModel.Background : Background.ToOxyColor();
return PngExporter.ExportToBitmap(ActualModel, (int)Bounds.Width, (int)Bounds.Height, background);
}
}
}