MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / getHexString

Method getHexString

ij/src/main/java/ij/plugin/Colors.java:233–240  ·  view source on GitHub ↗

Returns the 6-digit hex string such as "aa55ff" for opaque colors or or 8-digit like "80aa55ff" for other colors (the first two hex digits are alpha). 'color' must not be null.

(Color color)

Source from the content-addressed store, hash-verified

231 * or 8-digit like "80aa55ff" for other colors (the first two hex digits are alpha).
232 * 'color' must not be null. */
233 private static String getHexString(Color color) {
234 int rgb = color.getRGB();
235 boolean isOpaque = (rgb & 0xff000000) == 0xff000000;
236 if (isOpaque)
237 rgb &= 0x00ffffff; //don't show alpha for opaque colors
238 String format = isOpaque? "%06x" : "%08x";
239 return String.format(format, rgb);
240 }
241
242 /** Returns an opaque color with the specified red, green, and blue values.
243 * Values is outside the 0-255 range are replaced by the nearest

Callers 2

colorToStringMethod · 0.95
colorToString2Method · 0.95

Calls 2

getRGBMethod · 0.80
formatMethod · 0.45

Tested by

no test coverage detected