Hello, I am struggling with colors. Why does my window show up as bright blue instead of grey? I want to use grey colors and a GdkImage. I know that grey is obtained if the rgb values are all equal. My XServer has a depth of 24 bits. My application creates a GdkImage from the default visual. the bytes per line returned is 4096 the bits per pixel returned is 32 the bytes per pixel returned is 4 the byte order enum value is 0 the cgrey0 pixel value is 0 the cgrey1 pixel value is 3289650 (32 32 32 in hex) the cgrey2 pixel value is 8224125 (7D 7D 7D in hex) I was assuming from this that the rgb format was :- MSB aaaa aaaa rrrr rrrr gggg gggg bbbb bbbb LSB Annoyingly the grey color I attempt to draw shows up bright blue!!! I have created a colormap and allocated 3 or 4 colors to it using :- m_refVisual = Gdk::Visual::get_system(); // get system's default visual for default GDK screen m_refGdkImage = Gdk::Image::create(Gdk::IMAGE_FASTEST, m_refVisual, m_XRes, m_YRes); char* pImage = (char*)(m_refGdkImage->get_mem()); guint16 bytesPerLine = m_refGdkImage->get_bpl(); guint16 bytesPerPixel = m_refGdkImage->get_bpp(); std::cout << "bytes per line, bpl=" << bytesPerLine << std::endl; std::cout << "bits per pixel, bpp=" << m_refGdkImage->get_bits_per_pixel() << std::endl; std::cout << "bytes per pixel, bpp=" << bytesPerPixel << std::endl; std::cout << "byte order=" << m_refGdkImage->get_byte_order() << std::endl; //create grayscale colormap for default system visual... windowColormap = Gdk::Colormap::create(m_refVisual,true); //create several grey colors Gdk::Color cGrey0; cGrey0.set_grey(0); Gdk::Color cGrey1; cGrey1.set_grey(12800); Gdk::Color cGrey2; cGrey2.set_grey(32000); Gdk::Color cGrey3; cGrey3.set_grey(64000); //allocate grayscale values to colormap bool allocSuccess = windowColormap->alloc_color(cGrey0);//, true, true); allocSuccess = windowColormap->alloc_color(cGrey1);//, true, true); allocSuccess = windowColormap->alloc_color(cGrey2);//, true, true); m_cGrey0PixelVal = cGrey0.get_pixel(); std::cout << "cGrey0 Pixel Value = " << m_cGrey0PixelVal << std::endl; m_cGrey1PixelVal = cGrey1.get_pixel(); std::cout << "cGrey1 Pixel Value = " << m_cGrey1PixelVal << std::endl; m_cGrey2PixelVal = cGrey2.get_pixel(); std::cout << "cGrey2 Pixel Value = " << m_cGrey2PixelVal << std::endl; m_refGdkImage->set_colormap(windowColormap); for (int y=0; y<m_YRes; y++) { for (int x=0; x<m_XRes; x++) { pImage[(y*bytesPerLine)+(x*bytesPerPixel)] = m_MlcGrey2PixelVal; } } window->draw_image(m_refGC, m_refGdkImage, 0, 0, 0, 0, -1, -1); *******************Internet Email Confidentiality Footer******************* The contents of this e-mail message (including any attachments hereto) are confidential to and are intended to be conveyed for the use of the recipient to whom it is addressed only. If you receive this transmission in error, please notify the sender of this immediately and delete the message from your system. Any distribution, reproduction or use of this message by someone other than recipient is not authorized and may be unlawful. _______________________________________________ gtkmm-list mailing list gtkmm-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtkmm-list