Browse Source

Make it possible to construct a Direct2D BitmapImpl from a ID2D1Bitmap directly, instead of only via WIC imaging factories.

pull/859/head
Jeremy Koritzinsky 10 years ago
parent
commit
17a43dacfa
  1. 20
      src/Windows/Avalonia.Direct2D1/Media/Imaging/BitmapImpl.cs

20
src/Windows/Avalonia.Direct2D1/Media/Imaging/BitmapImpl.cs

@ -64,6 +64,21 @@ namespace Avalonia.Direct2D1.Media
BitmapCreateCacheOption.CacheOnLoad); BitmapCreateCacheOption.CacheOnLoad);
} }
/// <summary>
/// Initialize a new instance of the <see cref="BitmapImpl"/> class
/// with a bitmap backed by GPU memory.
/// </summary>
/// <param name="d2DBitmap">The GPU bitmap.</param>
/// <remarks>
/// This bitmap must be either from the same render target,
/// or if the render target is a <see cref="SharpDX.Direct2D1.DeviceContext"/>,
/// the device associated with this context, to be renderable.
/// </remarks>
public BitmapImpl(SharpDX.Direct2D1.Bitmap d2DBitmap)
{
_direct2D = d2DBitmap;
}
/// <summary> /// <summary>
/// Gets the width of the bitmap, in pixels. /// Gets the width of the bitmap, in pixels.
/// </summary> /// </summary>
@ -77,14 +92,13 @@ namespace Avalonia.Direct2D1.Media
public virtual void Dispose() public virtual void Dispose()
{ {
WicImpl.Dispose(); WicImpl.Dispose();
_direct2D?.Dispose();
} }
/// <summary> /// <summary>
/// Gets the WIC implementation of the bitmap. /// Gets the WIC implementation of the bitmap.
/// </summary> /// </summary>
public Bitmap WicImpl public Bitmap WicImpl { get; }
{
get; }
/// <summary> /// <summary>
/// Gets a Direct2D bitmap to use on the specified render target. /// Gets a Direct2D bitmap to use on the specified render target.

Loading…
Cancel
Save