public override void FillRectangle(Brush brush, RectangleF rect) { var textureBrushCache = _renderTargetCache[_renderTarget].TextureBrushCache; var textureBrush = brush as TextureBrush; SharpDX.Direct2D1.BitmapBrush bitmapBrush; if (!textureBrushCache.TryGetValue(textureBrush, out bitmapBrush)) { Bitmap bitmap = textureBrush.Image as Bitmap; bitmapBrush = new SharpDX.Direct2D1.BitmapBrush(_renderTarget, bitmap.ToD2DBitmap(_renderTarget), new SharpDX.Direct2D1.BitmapBrushProperties { ExtendModeX = SharpDX.Direct2D1.ExtendMode.Wrap, ExtendModeY = SharpDX.Direct2D1.ExtendMode.Wrap, InterpolationMode = SharpDX.Direct2D1.BitmapInterpolationMode.Linear }); textureBrushCache[textureBrush] = bitmapBrush; } _renderTarget.FillRectangle(rect.ToD2DRectangleF(), bitmapBrush); }
public override void DrawImage(Image image, RectangleF rect) { using (var bitmap = new Bitmap(image)) using (var d2dBitmap = bitmap.ToD2DBitmap(_renderTarget)) { _renderTarget.DrawBitmap(d2dBitmap, rect.ToD2DRectangleF(), 1.0f, SharpDX.Direct2D1.BitmapInterpolationMode.Linear); } }