Full Error: D2D DEBUG ERROR - An operation failed because a device-dependent resource is associated with the wrong ID2D1Device (resource domain).
I may be going about this completely wrong - I want a surface that I can draw to so that I can then draw that whole surface to the screen, and also save it as a file via WIC. I couldn't find any samples that do anything similar, and this code seems to follow patterns that I've seen in CommonDX.
Any ideas?
var bitmapProperties = new BitmapProperties1();
bitmapProperties.DpiX = _deviceManager.Dpi;
bitmapProperties.DpiY = _deviceManager.Dpi;
bitmapProperties.PixelFormat = new SharpDX.Direct2D1.PixelFormat(SharpDX.DXGI.Format.R8G8B8A8_UNorm, SharpDX.Direct2D1.AlphaMode.Premultiplied);
bitmapProperties.BitmapOptions = BitmapOptions.Target;
if (_d2dSurfaceBitmap == null)
_d2dSurfaceBitmap = new Bitmap1(_deviceManager.ContextDirect2D, new DrawingSize(1000, 800), bitmapProperties);
RenderTargetProperties rtProps = new RenderTargetProperties();
rtProps.DpiX = _deviceManager.Dpi;
rtProps.DpiY = _deviceManager.Dpi;
rtProps.PixelFormat = new PixelFormat(SharpDX.DXGI.Format.R8G8B8A8_UNorm, AlphaMode.Premultiplied);
rtProps.Type = RenderTargetType.Default;
RenderTarget renderTarget = new RenderTarget(_bmpDeviceManager.FactoryDirect2D, _d2dSurfaceBitmap.Surface, rtProps);
renderTarget.BeginDraw();
renderTarget.DrawLine(point0, point1, _bmpSceneColorBrush);
renderTarget.EndDraw();