Question

I've create everything needed to draw to a SharpDX.Direct2D1.BitmapRenderTarget.

I can access the bitmap itself by using the targets .bitmap attribute.

My question is now, how to draw this bitmap using another WicRenderTarget?

Something like:

var wicFactory = new ImagingFactory();
var d2dFactory = new SharpDX.Direct2D1.Factory();
var wicBitmap = new Bitmap(wicFactory, width, height, SharpDX.WIC.PixelFormat.Format32bppBGR, BitmapCreateCacheOption.CacheOnLoad);
var d2dRenderTarget = new WicRenderTarget(d2dFactory, wicBitmap, renderTargetProperties);

d2dRenderTarget.BeginDraw();
d2dRenderTarget.Clear(SharpDX.Color.Black);
d2dRenderTarget.FillGeometry(rectangleGeometry, solidColorBrush, null);
d2dRenderTarget.DrawBitmap(MY BITMAPRENDERTARGET.BITMAP_FROM OTHER D2D FACTORY);
d2dRenderTarget.EndDraw();

But this throws me an "UNKOWN_FACTORY" exception in the EndDraw().

How can I achieve want I want to do?

I used the code from the following link to create everything needed for the WIC output: https://github.com/sharpdx/SharpDX/blob/master/Samples/Direct2D1/RenderToWicApp/Program.cs

Instead of writing a geometry I want to write my bitmaprendertarget bitmap.

Was it helpful?

Solution

You can't draw bitmap created by another D2D factory. Create it using your factory. If you don't control how the other bitmap is created, get it's factory via GetFactory method and use it to create your objects.

See Resources Overview for more information of what can be shared within render targets or factories.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top