2016-01-20 74 views
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 ::绘图区*

任何帮助表示赞赏。

回答

0

我在这里最好的猜测是有问题的UNIX机器X11 rgb.txt文件是不同的。每GdkColor文档:

字符串既可以大集的标准名称(从X11 rgb.txt中的文件获得),或者......一个

我的建议是指定颜色为“#FF0000”而不是“红色”。