Java 8 ColorSpace - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 ColorSpace class.

This code example shows how to use the following methods:getNumComponents, getType
        if (!isEnabled()) { 
            return; 
        } 
 
        if (cs != null) {
            traceObjStart(label, cs, sb, indent);
            indent += INDENT_INCR;
 
            if (isFlagSet(traceMask, F_ATTRIBUTES)) {
                traceField("type", ImageUtils.getColorSpaceName(cs.getType()), sb, indent);
                traceField("numComponents", cs.getNumComponents(), sb, indent);
 
/* 
                appendLineStart(sb, indent); 
                sb.append("componentNames = { "); 
                for (int i = 0; i < cs.getNumComponents(); i++) { 
                    if (i > 0) sb.append(", "); 
                    sb.append(cs.getTypeID(i)); 
                } 
                sb.append(" }"); 

5
CodeRank
This code example shows how to use the following methods:getType, getClass
{ 
    private String colorSpaceTypeToName(ColorSpace cs)
    { 
        //        System.out.println(prefix + ": " + "type: " 
        //                + cs.getType() ); 
        switch (cs.getType())
        { 
            case ColorSpace.TYPE_CMYK :
                return "TYPE_CMYK"; 
            case ColorSpace.TYPE_RGB :
                return "TYPE_RGB"; 
 
            case ColorSpace.CS_sRGB :
                return "CS_sRGB"; 
            case ColorSpace.CS_GRAY :
                return "CS_GRAY"; 
            case ColorSpace.CS_CIEXYZ :
                return "CS_CIEXYZ"; 
            case ColorSpace.CS_LINEAR_RGB :
                return "CS_LINEAR_RGB"; 

5
CodeRank
This code example shows how to use the following methods:toCIEXYZ
    /** 
     * Convert the specified RGB color to XYZ color. 
     */ 
    public static float[] toXYZ(float[] rgb)
    { 
        return sRGB.toCIEXYZ(rgb);
    } 
 
    /** 
     * Convert the specified color to LAB color. 
     */ 
    public static float[] toLAB(Color c)
    { 
        return toLAB(c.getRGBColorComponents(null));
    } 
 
    /** 
     * Convert the specified RGB color to LAB color. 
     */ 
    public static float[] toLAB(float[] rgb)
2
CodeRank
This code example shows how to use the following methods:fromCIEXYZ
        return csRGB.toCIEXYZ(toRGB(colorvalue));
    } 
 
    @Override 
    public float[] fromCIEXYZ(float[] xyzvalue) {
        return fromRGB(csRGB.fromCIEXYZ(xyzvalue));
    } 
} 
4
CodeRank
This code example shows how to use the following methods:fromRGB
        //       return sRGB.fromCIEXYZ(ciexyz); 
    } 
 
    @Override 
    public float[] fromRGB(float[] rgbvalue) {
        float[] ciexyz = sRGB.fromRGB(rgbvalue);
        return fromCIEXYZ(ciexyz);
    } 
 
    /** 
     * Lab to XYZ. 
     * <pre> 
     * X = xr*Xr; 
     * Y = yr*Yr; 
     * Z = zr*Zr; 
     * </pre> 
     * where 
     * <pre> 
     * xr = fx^3, if fx^3 &gt; eps 
     *    = (116*fx - 16)/k, if fx^3 &lt;= eps 
3
CodeRank
This code example shows how to use the following methods:fromRGB
 
    /** Returns the color components in the specified color space from 
     * RGB values. 
     */ 
    public static float[] fromRGB(ColorSpace colorSpace, int r, int g, int b) {
        return colorSpace.fromRGB(new float[]{r / 255f, g / 255f, b / 255f});
    } 
 
    /** Returns an rgb value from color components in the specified color space. 
     */ 
    public static int toRGB(ColorSpace colorSpace, float... components) {
        float[] rgb = colorSpace.toRGB(components);
 
        // If the color is not displayable in RGB, we return transparent black. 
        if (rgb[0]<0f||rgb[1]<0f||rgb[2]<0f||rgb[0]>1f||rgb[1]>1f||rgb[2]>1f) {
            return 0; 
        } 
        return 0xff000000 | ((int) (rgb[0] * 255f) << 16) | ((int) (rgb[1] * 255f) << 8) | (int) (rgb[2] * 255f);
    } 
 
3
CodeRank
This code example shows how to use the following methods:getType
import org.apache.pdfbox.contentstream.operator.color.SetStrokingColorSpace; 
import org.apache.pdfbox.contentstream.operator.color.SetStrokingDeviceRGBColor; 
import org.apache.pdfbox.contentstream.operator.text.SetTextLeading; 
import org.apache.pdfbox.contentstream.operator.text.SetTextRenderingMode; 
import org.apache.pdfbox.contentstream.operator.text.SetTextRise; 
import org.apache.pdfbox.contentstream.operator.text.SetWordSpacing; 
 
/** 
 * This class inherits from org.apache.pdfbox.util.PDFStreamEngine to allow the validation of specific rules in 
 * ContentStream. 
 */ 
public abstract class PreflightStreamEngine extends PDFStreamEngine 
{ 
    private enum ColorSpaceType 
    { 
        RGB, CMYK, ALL
    } 
 
    protected PreflightContext context = null;
    protected COSDocument cosDocument = null;
2
CodeRank
This code example shows how to use the following methods:fromCIEXYZ
  } 
 
  @Override 
  public float[] toRGB(float[] colorvalue) {
    // convert to XYZ first, then to sRGB 
    return RGB.fromCIEXYZ(toCIEXYZ(colorvalue));
  } 
 
} 
4
CodeRank
This code example shows how to use the following methods:fromRGB
        return new float[] { (float) L, (float) a, (float) b };
    } 
 
    @Override 
    public float[] fromRGB(float[] rgbvalue) {
        float[] xyz = CIEXYZ.fromRGB(rgbvalue);
        return fromCIEXYZ(xyz);
    } 
 
    @Override 
    public float getMaxValue(int component) {
        return 128f; 
    } 
 
    @Override 
    public float getMinValue(int component) {
        return (component == 0) ? 0f : -128f;
    } 
 
    @Override 
4
CodeRank
This code example shows how to use the following methods:fromCIEXYZ
     * Relative colorimetric needs to happen through CIEXYZ 
     * conversion 
     */ 
    public float[] relativeColorimetricToRGB(float[] values){
        float[] ciexyz = toCIEXYZ(values);
        return sRGB.fromCIEXYZ(ciexyz);
    } 
 
    /** 
     * Absolute colorimetric. NOT IMPLEMENTED. 
     * Temporarily returns same as perceptual 
     */ 
    public float[] absoluteColorimetricToRGB(float[] values){
        return perceptualToRGB(values);
    } 
 
    /** 
     * Saturation. NOT IMPLEMENTED. Temporarily returns same 
     * as perceptual. 
     */ 
4
CodeRank
See Code Examples for Java 8 ColorSpace Methods: