Xpm color image utility class

This class is for converting Xpm format images into java Images. (Since a web search doesnt easily find someone else who did this yet. )

This class is both a simple RGB<->string converter, and a full xpm java image creator. If you have a file with a "creative" name like "DarkOrange2", you can use this to get some actual RGB values. Or, in the unlikely event you'd like a name for an RGB tripplet, if it knows one, it can give you one.

A large portion of this class is basically a wrapper around the old "rgb.txt" file distributed with X11. So if you know what that means, rejoice, and help yourself.

You can grab the source, or if you're in a hurry, just grab the class directly, and play with it. [v1.9, last updated July 17, 2001: It should work with all sizes of xpm now!]


Class Xpm

This class converts to and from rgb color strings. It also has an XpmToImage(String) function.

Method index

(A slightly abbreviated list)

  • [static] String RGBToName(int val[3])

    Given a {red#, green#,blue#} int array, looks up a String representation of that triplet. Returns null if no match

  • [static] int[3] NameToRGB(String)

    Given a 'colorful' name, looks up an RGB triplet, and returns it as an int[3]. Returns null if no match.

  • [static] Image XpmToImage(String xpm)

    Given a string with a single xpm image, will convert it to an (java.awt.Image) object. (or null if truncated string passed in)