Closed Charltsing closed 3 months ago
Not sure what you mean by that. What is RenderTarget?
There is no CreatBitmapBrush definition in ID2D1RenderTargetExtension
RenderTarget is ID2D1HwndRenderTarget
there is CreatBmpBrush in ID2D1HwndRenderTarget
I want to create a BitmapBrush using a ID2D1Bitmap1, and then draw this ID2D1Bitmap1 onto another ID2D1Bitmap1.
These are extension methods and they are not defined for all (~2000) interfaces in DirectN and they are not necessarily exposing all interface raw members, as they are added manually.
But their usage is always optional, and a missing extension method never prevents you from using the raw method since IComObject
exposes the Object
property which is a reference on the native interface. For example like this:
IComObject<ID2D1RenderTarget> rt = ... get from somewhere
rt.Object.CreateBitmapBrush( ... etc. ...).ThrowOnError( throwOnError or not):
You can also define your own extension methods if you're missing some, eg:
public static IComObject<ID2D1BitmapBrush> CreateBitmapBrush(this IComObject<ID2D1RenderTarget> renterTarget, IComObject<ID2D1Bitmap> bitmap, D2D1_BITMAP_BRUSH_PROPERTIES bitmapBrushProperties, D2D1_BRUSH_PROPERTIES? properties = null) => CreateBitmapBrush<ID2D1BitmapBrush>(renterTarget?.Object, bitmap?.Object, bitmapBrushProperties, properties);
public static IComObject<T> CreateBitmapBrush<T>(this IComObject<ID2D1RenderTarget> renterTarget, IComObject<ID2D1Bitmap> bitmap, D2D1_BITMAP_BRUSH_PROPERTIES bitmapBrushProperties, D2D1_BRUSH_PROPERTIES? properties = null) where T : ID2D1BitmapBrush => CreateBitmapBrush<T>(renterTarget?.Object, bitmap?.Object, bitmapBrushProperties, properties);
public static IComObject<T> CreateBitmapBrush<T>(this ID2D1RenderTarget renterTarget, ID2D1Bitmap bitmap, D2D1_BITMAP_BRUSH_PROPERTIES bitmapBrushProperties, D2D1_BRUSH_PROPERTIES? properties = null) where T : ID2D1BitmapBrush
{
if (renterTarget == null)
throw new ArgumentNullException(nameof(renterTarget));
// handles null or not null value types
using (var bbMem = new ComMemory(bitmapBrushProperties))
{
using (var pMem = new ComMemory(properties))
{
renterTarget.CreateBitmapBrush(bitmap, bbMem.Pointer, pMem.Pointer, out var brush).ThrowOnError();
return new ComObject<T>((T)brush);
}
}
}
you can make pull requests for them if you want.
I have added CreateBitmapBrush with this commit https://github.com/smourier/DirectN/commit/fa9b24e103f5dd1c7ce25a2727b941d8505e6e4b
thanks for your help
How to use RenderTarget.CreatBitmapBrush ?