0

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.

asked Jan 22, 2014 at 14:00

1 Answer 1

1

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.

answered Jan 22, 2014 at 18:24
Sign up to request clarification or add additional context in comments.

2 Comments

I will check out that link. I now used the same factory to to create the WicRenderTarget. But now I get a WrongResourceDomain exception at the EndDraw(). Why is this?
This means some of the resource constraints were still violated. Check out the "Resources Overview" link.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.