pygtk:在gtk.gdk.Pixbuf上画线 [英] pygtk: Draw lines onto a gtk.gdk.Pixbuf
问题描述
我在PIL中使用pygtk。我已经想出了一种将PIL Image
s转换为 gtk.gdk.Pixbuf
s的方法。我做什么来显示pixbuf是我创建一个 gtk.gdk.Image
,然后使用 img.set_from_pixbuf
。我现在想在这张图上画几行。显然我需要一个 Drawable
来做到这一点。我已经开始浏览文档,但是我已经打开了8-10个窗口,并且它不是简单的。
所以 - 我需要输入什么魔法才能获得代表我的图片的Drawable,然后将其绘制成 gdk.Image
所以我可以在我的应用程序中显示它? 我正在做类似的事情(绘制到gdk.Drawable),并且我发现set_foreground不起作用。要使用我想要的颜色进行绘制,我使用了以下内容:
#Red!
gc.set_rgb_fg_color(gtk.gdk.Color(0xff,0x0,0x0))
I'm using pygtk with PIL. I've already figured out a way to convert PIL Image
s to gtk.gdk.Pixbuf
s. What I do to display the pixbuf is I create a gtk.gdk.Image
, and then use img.set_from_pixbuf
. I now want to draw a few lines onto this image. Apparently I need a Drawable
to do that. I've started looking through the docs but already I have 8-10 windows open and it is not being straightforward at all.
So - what magic do I need to type to get a Drawable representing my picture, draw some things on to it, and then turn it into a gdk.Image
so I can display it on my app?
I was doing something similar (drawing to a gdk.Drawable), and I found that set_foreground doesn't work. To actually draw using the color I wanted, I used the following:
# Red!
gc.set_rgb_fg_color(gtk.gdk.Color(0xff, 0x0, 0x0))
这篇关于pygtk:在gtk.gdk.Pixbuf上画线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!