//--------------------------------------------------------------------------------------------------------- /// <summary> /// Обновление ресурса Direct2D /// </summary> /// <param name="forced">Принудительное создание ресурса Direct2D</param> //--------------------------------------------------------------------------------------------------------- public override void UpdateDirect2DResource(Boolean forced = false) { if (XDirect2DManager.D2DRenderTarget != null) { // Принудительное создание ресурса if (forced) { XDisposer.SafeDispose(ref mD2DBrush); } if (mD2DBrush == null) { SharpDX.Direct2D1.BitmapBrushProperties bbp = new SharpDX.Direct2D1.BitmapBrushProperties(); bbp.ExtendModeX = (SharpDX.Direct2D1.ExtendMode)mExtendModeX; bbp.ExtendModeY = (SharpDX.Direct2D1.ExtendMode)mExtendModeY; bbp.InterpolationMode = SharpDX.Direct2D1.BitmapInterpolationMode.NearestNeighbor; mD2DBrush = new SharpDX.Direct2D1.BitmapBrush(XDirect2DManager.D2DRenderTarget, XDirect2DManager.LoadFromResource(mResourceName), bbp); mD2DBrush.Transform = SharpDX.Matrix3x2.Scaling(mScale); } else { SharpDX.Direct2D1.BitmapBrush d2d_image_brush = mD2DBrush as SharpDX.Direct2D1.BitmapBrush; d2d_image_brush.Bitmap = XDirect2DManager.LoadFromResource(mResourceName); d2d_image_brush.ExtendModeX = (SharpDX.Direct2D1.ExtendMode)mExtendModeX; d2d_image_brush.ExtendModeY = (SharpDX.Direct2D1.ExtendMode)mExtendModeY; d2d_image_brush.Transform = SharpDX.Matrix3x2.Scaling(mScale); d2d_image_brush.InterpolationMode = SharpDX.Direct2D1.BitmapInterpolationMode.NearestNeighbor; } } }
/// <summary> /// Creates an <see cref="SharpDX.Direct2D1.BitmapBrush"/> from the specified bitmap. /// </summary> /// <param name="renderTarget">an instance of <see cref = "SharpDX.Direct2D1.RenderTarget" /></param> /// <param name="bitmap">The bitmap contents of the new brush.</param> /// <param name="bitmapBrushProperties">The extend modes and interpolation mode of the new brush, or NULL. If this parameter is NULL, the brush defaults to the <see cref="SharpDX.Direct2D1.ExtendMode.Clamp"/> horizontal and vertical extend modes and the <see cref="SharpDX.Direct2D1.BitmapInterpolationMode.Linear"/> interpolation mode. </param> /// <unmanaged>HRESULT ID2D1RenderTarget::CreateBitmapBrush([In] ID2D1Bitmap* bitmap,[In, Optional] const D2D1_BITMAP_BRUSH_PROPERTIES* bitmapBrushProperties,[In, Optional] const D2D1_BRUSH_PROPERTIES* brushProperties,[Out, Fast] ID2D1BitmapBrush** bitmapBrush)</unmanaged> public BitmapBrush(RenderTarget renderTarget, SharpDX.Direct2D1.Bitmap bitmap, SharpDX.Direct2D1.BitmapBrushProperties bitmapBrushProperties) : this(renderTarget, bitmap, bitmapBrushProperties, null) { }