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 ::繪圖區*
任何幫助表示讚賞。