// -----------------------------------------------------------------------
//
// Copyright 2015 MIT Licence. See licence.md for more information.
//
// -----------------------------------------------------------------------
namespace Perspex.Media.Imaging
{
using System;
using Perspex.Platform;
using Splat;
///
/// A bitmap that holds the rendering of a .
///
public class RenderTargetBitmap : Bitmap, IDisposable
{
///
/// Initializes a new instance of the class.
///
/// The width of the bitmap.
/// The height of the bitmap.
public RenderTargetBitmap(int width, int height)
: base(CreateImpl(width, height))
{
}
///
/// Gets the platform-specific bitmap implementation.
///
public new IRenderTargetBitmapImpl PlatformImpl
{
get { return (IRenderTargetBitmapImpl)base.PlatformImpl; }
}
///
/// Renders an into the bitmap.
///
/// The visual to render.
///
/// Before calling this method, ensure that has been measured.
///
public void Render(IVisual visual)
{
this.PlatformImpl.Render(visual);
}
///
/// Disposes of the bitmap.
///
public void Dispose()
{
this.PlatformImpl.Dispose();
}
///
/// Creates a platform-specific imlementation for a .
///
/// The width of the bitmap.
/// The height of the bitmap.
/// The platform-specific implementation.
private static IBitmapImpl CreateImpl(int width, int height)
{
IPlatformRenderInterface factory = Locator.Current.GetService();
return factory.CreateRenderTargetBitmap(width, height);
}
}
}