Skiasharp 将画布导出为图像 [英] Skiasharp Export canvas to image

查看:41
本文介绍了Skiasharp 将画布导出为图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题.我有一个带有一些位图的skiasharp画布.现在我想将带有位图的画布导出到一个图像,但我不知道该怎么做,或者如果可能的话.

I have a question. I have a skiasharp canvas with a few bitmaps. Now I want to export the canvas with the bitmaps to an Image, but I have no idea how to do that, or if that is possible.

有人可以帮我吗?

推荐答案

您可能希望采用 表面快照.

using (var image = surface.Snapshot())
using (var data = image.Encode(SKEncodedImageFormat.Png, 80))
using (var stream = File.OpenWrite(Path.Combine(FolderPath, "1.png")))
{
    // save the data to a stream
    data.SaveTo(stream);
}

这与 MShah 的回答非常相似,但只是来自表面的快照,因为 surface 是对您的 Skia Surface 的引用.

This is very similar to MShah's answer, but just from a snapshot of the surface instead, given that surface is a reference to your Skia Surface.

这篇关于Skiasharp 将画布导出为图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆