Example usage for org.apache.poi.xssf.usermodel XSSFColor getRGBWithTint

List of usage examples for org.apache.poi.xssf.usermodel XSSFColor getRGBWithTint

Introduction

In this page you can find the example usage for org.apache.poi.xssf.usermodel XSSFColor getRGBWithTint.

Prototype

public byte[] getRGBWithTint() 

Source Link

Usage

From source file:org.tiefaces.components.websheet.utility.ColorUtility.java

License:MIT License

/**
 * Convert xssfcolor to triple let numbers.
 * /*  ww w . j a v a  2 s  . co m*/
 * @param xssfColor
 *            xssf color.
 * @return triple lets.
 */
public static short[] getTripletFromXSSFColor(final XSSFColor xssfColor) {

    short[] rgbfix = { RGB8BITS, RGB8BITS, RGB8BITS };
    if (xssfColor != null) {
        byte[] rgb = xssfColor.getRGBWithTint();
        if (rgb == null) {
            rgb = xssfColor.getRGB();
        }
        // Bytes are signed, so values of 128+ are negative!
        // 0: red, 1: green, 2: blue
        rgbfix[0] = (short) ((rgb[0] < 0) ? (rgb[0] + RGB8BITS) : rgb[0]);
        rgbfix[1] = (short) ((rgb[1] < 0) ? (rgb[1] + RGB8BITS) : rgb[1]);
        rgbfix[2] = (short) ((rgb[2] < 0) ? (rgb[2] + RGB8BITS) : rgb[2]);
    }
    return rgbfix;
}