2016-01-20 76 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」而不是「紅色」。