新手:将 RGB 渲染为 GTK 小部件 - 如何?
大图:我想在 Linux 机器上通过 GTK 渲染 RGB 图像。
我是一个沮丧的 GTK 新手,所以请原谅我。
我假设我应该创建一个 Drawable_area 来渲染图像——正确吗?
然后我是否必须创建附加到该区域的图形上下文?如何?
我的简单应用程序(甚至还没有解决 RGB 问题,是这样的:
int main(int argc, char** argv) {
GdkGC * gc = NULL;
GtkWidget * window = NULL;
GtkDrawingArea * dpage = NULL;
GtkWidget * page = NULL;
gtk_init( &argc, & argv );
window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
page = gtk_drawing_area_new( );
dpage = GTK_DRAWING_AREA( page );
gtk_widget_set_size_request( page, PAGE_WIDTH, PAGE_HEIGHT );
gc = gdk_gc_new( GTK_DRAWABLE( dpage ) );
gtk_widget_show( window );
gtk_main();
return (EXIT_SUCCESS);
}
我的 dpage 显然不是“可绘制”(尽管它是一个绘图区域)。我是对于以下问题感到困惑:a)如何获取/创建后续函数调用所需的图形上下文? b) 我是否接近解决方案,或者我是否已经完全*#&@&错误的是没有希望 c) 婴儿学步教程。 (我以 hello world 为基础开始,所以我已经做到了这一点)。
任何和所有的帮助表示赞赏。
BP
Big picture: I want to render an RGB image via GTK on a linux box.
I'm a frustrated GTK newbie, so please forgive me.
I assume that I should create a Drawable_area in which to render the image -- correct?
Do I then have to create a graphics context attached to that area? How?
my simple app (which doesn't even address the rgb issue yet is this:
int main(int argc, char** argv) {
GdkGC * gc = NULL;
GtkWidget * window = NULL;
GtkDrawingArea * dpage = NULL;
GtkWidget * page = NULL;
gtk_init( &argc, & argv );
window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
page = gtk_drawing_area_new( );
dpage = GTK_DRAWING_AREA( page );
gtk_widget_set_size_request( page, PAGE_WIDTH, PAGE_HEIGHT );
gc = gdk_gc_new( GTK_DRAWABLE( dpage ) );
gtk_widget_show( window );
gtk_main();
return (EXIT_SUCCESS);
}
my dpage is apparently not a 'drawable' (though it is a drawing area). I am confused as to a) how do I get/create the graphics context which is required in subsequent function calls?
b) am I close to a solution, or am I so completely *#&@& wrong that there is no hope
c) a baby steps tutorial. (I started with hello world as my base, so I got that far).
any and all help appreciated.
bp
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您至少应该阅读一下涂鸦教程 ( http://library. gnome.org/devel/gtk-tutorial/stable/c2422.html ),如果不是其中一部分的较大教程。
既然您将问题标记为 c++,我建议使用 gtkmm,如果您已经非常了解 C++,您会发现开发起来要容易得多。还有一个教程: http://library.gnome.org/开发/gtkmm-tutorial/stable/
You should go through the scribble tutorial at least ( http://library.gnome.org/devel/gtk-tutorial/stable/c2422.html ), if not the larger tutorial of which this a part.
Since you tagged your question c++, I'd recommend using gtkmm, you'll find it much easier to develop in if you already know C++ pretty well. There is a tutorial for it as well: http://library.gnome.org/devel/gtkmm-tutorial/stable/