Search the FAQ Archives

3 - A - B - C - D - E - F - G - H - I - J - K - L - M
N - O - P - Q - R - S - T - U - V - W - X - Y - Z
faqs.org - Internet FAQ Archives

Motif FAQ (Part 5 of 9)
Section - 141) Why does XpmCreatePixmapFromData fail with a pixmap containing

( Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Part8 - Part9 - Single Page )
[ Usenet FAQs | Web FAQs | Documents | RFC Index | Houses ]


Top Document: Motif FAQ (Part 5 of 9)
Previous Document: 140) Can I use XmGetPixmap in Motif 1.2 to create colored images?
Next Document: 142) How can I convert a Sun/GIF/TIFF image to a pixmap?
See reader questions & answers on this topic! - Help others by sharing your knowledge
a large number of colors?  XpmCreatePixmapFromData gives me a -4 errno (which
is XpmColorFailed) when I try using a pixmap with 242 colors
[Last modified: Oct 95]

Answer: Ramiro Estrugo (restrugo@fateware.com) writes:

If you are allocating 242 colors in an 8 bit display, then you are likely to
run out of colors.  If you carefully read the Xpm manual, you will notice that
one of the Xpm values that you can modify is the "closeness".  This value will
control the actual closness of the colors allocated by the Xpm library.
According to the Xpm manual:

o The "closeness" field(s) (when set) control if and how colors
are found when they failed to be allocated.  If the color cannot
be allocated, Xpm looks in the colormap for a color that matches
the desired closeness.

o The value is an integer in the range 0 (black) - 65535 (white)

o A closeness of less than 10000 will cause only "close" colors to
match.

o A cliseness of more than 50000 will allow quite disimilar colors
to match.

o A closeness of more than 65535 will allow any color to match.

o A value of 40000 seems reasonable for many situations requiring
reasonable but not perfect color matches.

Try it and your application is less likely to die or look "ugly" due to the
lack of colors.  The worst that can happed is that the colors you get are not
100% what you wanted them to be.  Most of the time, you might not even notice
the difference.  This is usually due to badly designed icons or duplicate
color entries (close rgb values) in .xpm files.

NOTE: for even more control over Xpm color allocation, you can control the
closeness of each RGB color component individually.

For example:

XpmAttributes   attrib;
int             valuemask;
attrib.valuemask |= XpmCloseness;
attrib.closeness = 40000;

/* also */

attrib.valuemask |= XpmRGBCloseness;
attrib.red_closeness = RED_CLOSENESS;
attrib.green_closeness = GREEN_CLOSENESS;
attrib.blue_closeness = BLUE_CLOSENESS;
pix = XpmCreateXYZFromABC(...,&attrib);

Also, look in the Xpm documentation for more color control parameters.

User Contributions:

Comment about this article, ask questions, or add new information about this topic:

CAPTCHA




Top Document: Motif FAQ (Part 5 of 9)
Previous Document: 140) Can I use XmGetPixmap in Motif 1.2 to create colored images?
Next Document: 142) How can I convert a Sun/GIF/TIFF image to a pixmap?

Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Part8 - Part9 - Single Page

[ Usenet FAQs | Web FAQs | Documents | RFC Index ]

Send corrections/additions to the FAQ Maintainer:
kenton@rahul.net (Ken Lee)





Last Update March 27 2014 @ 02:11 PM