0

我正在使用以下代码创建对象:

CompositionDrawingSurface uiElementBitmapSurface;
            using (var canvasBitmap = CanvasBitmap.CreateFromBytes(
                    canvasDevice, pixels,
                    bitmap.PixelWidth,
                    bitmap.PixelHeight,
                    DirectXPixelFormat.B8G8R8A8UIntNormalized,
                    dpi)
            )
            {
                var areaToRender = new Rect(100, 100, Control.ActualWidth, Control.ActualHeight);
                Windows.UI.Composition.CompositionDrawingSurface surface = compositionDevice.CreateDrawingSurface(
                                        new Size(areaToRender.Width, areaToRender.Height),
                                        DirectXPixelFormat.B8G8R8A8UIntNormalized, DirectXAlphaMode.Premultiplied);

                using (var session = CanvasComposition.CreateDrawingSession(uiElementBitmapSurface))
                {
                    session.DrawImage(canvasBitmap, 0, 0, areaToRender);
                }
            }

请帮助将 uiElementBitmapSurface 对象转换为文件。

4

1 回答 1

1

调用这个:

https://microsoft.github.io/Win2D/html/M_Microsoft_Graphics_Canvas_CanvasBitmap_SaveAsync.htm

顺便说一句,我自己没有尝试过,我只是用谷歌搜索了文档。但它确实看起来像您正在寻找的东西。

于 2017-05-16T12:07:39.133 回答