I have tried many method,and received many suggest from the community,but the
problem is still not resolved.Could any one give me a hand?
Below is the code: the line color is different from the pixel get from the
.png picture on the window.
pixbuf=Gdk::Pixbuf::create_from_file("color.png");
int width, height, rowstride, n_channels;
guint8 *pixels, *p;
n_channels= pixbuf->get_n_channels();
width = pixbuf->get_width();
height = pixbuf->get_height();
rowstride = pixbuf->get_rowstride();
pixels= pixbuf->get_pixels();
p = pixels + y* rowstride + x * n_channels;
gushort red = p[0] * 0x0101u;
gushort green = p[1] * 0x0101u;
gushort blue = p[2] * 0x0101u;
Cairo::RefPtr<Cairo::Context> cr = get_window()->create_cairo_context();
cr->set_source_rgb(65535,65535,65535); //paint the background of the canvas
cr->paint();
cr->set_source_rgb(red,green,blue); //draw line,it's color get from the
pixel of above png picture
cr->set_line_width(2);
cr->move_to(0,0);
cr->line_to(100,100);
cr->stroke();
_______________________________________________
gtkmm-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtkmm-list