0
我正在绘制区域绘制的图像上绘制一条简单的直线。Gtkmm:在绘图区域绘制一条线时进行颜色交换
但是在一台unix机器上,画出的线条是黑色而不是红色。
以下是一段代码绘制直线:
Gdk::Color red("red");
//winPtr is type of Gtk::Window*
Glib::RefPtr<Gdk::GC> gc = winPtr->get_window()->get_style()->get_white_gc();
gc->set_line_attributes (2, (Gdk::LineStyle)0, (Gdk::CapStyle)2, (Gdk::JoinStyle)1);
Glib::RefPtr<Gdk::Visual> some_visual;
some_visual = Gdk::Visual::get_best();
Glib::RefPtr<Gdk::Colormap> some_colormap = Gdk::Colormap::create(some_visual, true);
some_colormap->alloc_color (red, false, true);
gc->set_colormap(some_colormap);
gc->set_foreground(red);
imgDispArea->get_window()->draw_line (gc, 100, 100, 200, 200);
PS: - 其中 “imgDispArea” 是一种类型的Gtk ::绘图区*
任何帮助表示赞赏。