我有以下在Pixbuf上绘制的代码
private Pixbuf drawOnPixbuf(Pixbuf original)
{
Surface surface = new ImageSurface(Format.Argb32, original.Width, original.Height);
Context ctx = new Context(surface);
CairoHelper.SetSourcePixbuf(ctx, original, 0, 0);
// Draw on the surface here. Not shown since not relevant.
// Here, I want to convert the surface back to pixbuf.
Pixbuf finishedPixbuf = ...;
ctx.GetTarget().Dispose();
ctx.Dispose();
return finishedPixbuf;
}我找不到如何将Surface转换回Pixbuf。
发布于 2020-02-22 16:38:52
您正在寻找的函数似乎是Gdk的一部分:
cairo_surface_t *
gdk_cairo_surface_create_from_pixbuf (const GdkPixbuf *pixbuf,
int scale,
GdkWindow *for_window);具体地说,gdk_cairo_surface_create_from_pixbuf(pixbuf, 1, NULL)应该做你想做的事情。(对不起,我不知道如何在C#中表达。)
https://stackoverflow.com/questions/60290573
复制相似问题