尝试从 ImageSurface 创建 Pixbuf,但我得到的只是黑色像素。有任何想法吗?
Cairo.ImageSurface surface = mysurface;
int w = surface.Width;
int h = surface.Height;
Gdk.Pixmap pixmap = new Gdk.Pixmap(null, w, h, 24);
using (Cairo.Context cr = Gdk.CairoHelper.Create(pixmap)) {
cr.Operator = Cairo.Operator.Source;
cr.SetSource(surface);
cr.Paint();
}
_pixbuf = Gdk.Pixbuf.FromDrawable(pixmap, Gdk.Colormap.System, 0, 0, 0, 0, w, h);