سؤال

I'm looking for an easy way to create images out of Direct2D1 BitmapRenderTarget.

I do have a BitmapRenderTarget like this one:

var bitmapRenderTarget = new SharpDX.Direct2D1.BitmapRenderTarget(m_d2dRenderTarget, CompatibleRenderTargetOptions.None, new SharpDX.Direct2D1.PixelFormat(Format.B8G8R8A8_UNorm, AlphaMode.Premultiplied));

I can access the Direct2D1 bitmap itself by using bitmapRenderTarget.Bitmap. Though I'm not able to create a PNG,JPEG,... out of it without using WIC. Could anyone provide me a way to create a System.Drawing.Image out of it?

I would be happy to see an example because of PixelFormat incompatibility.

هل كانت مفيدة؟

المحلول

No apparently there is no way without WIC.

Within SharpDX Samples there are two example project which illustrate how to encode images.

There is a new(ish) one which "can" leverage the hardware by using a Direct3D11.Device https://github.com/sharpdx/SharpDX-Samples/tree/master/Desktop/Direct2D1/OfflineImageProcessingApp/Program.cs

And the old one https://github.com/sharpdx/SharpDX-Samples/blob/master/Desktop/Direct2D1/RenderToWicApp/Program.cs using the WicRenderTarget

If you take the code from the first one, you should actually get what you want, still you need Wic to encode the Bitmap to the destination image format (jpg, png...)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top