我正在使用以下代码创建对象:
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对象转换为文件。
答案 0 :(得分:1)
请致电:
https://microsoft.github.io/Win2D/html/M_Microsoft_Graphics_Canvas_CanvasBitmap_SaveAsync.htm
顺便说一句,我没有尝试过这个,我只是用Google搜索了文档。但它确实看起来像你在寻找。