Java Code Examples for java.awt.color.ColorSpace#equals()

The following examples show how to use java.awt.color.ColorSpace#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestCompressionBI_BITFIELDS.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
protected void compareImages(BufferedImage src, BufferedImage dst) {
    ColorSpace srcCS = src.getColorModel().getColorSpace();
    ColorSpace dstCS = dst.getColorModel().getColorSpace();
    if (!srcCS.equals(dstCS) && srcCS.getType() == ColorSpace.TYPE_GRAY) {
        System.out.println("Workaround color difference with GRAY.");
        BufferedImage tmp  =
            new BufferedImage(src.getWidth(), src.getHeight(),
                              BufferedImage.TYPE_INT_RGB);
        Graphics g = tmp.createGraphics();
        g.drawImage(src, 0, 0, null);
        src = tmp;
    }
    int y = h / 2;
    for (int i = 0; i < colors.length; i++) {
        int x = dx * i + dx / 2;
        int srcRgb = src.getRGB(x, y);
        int dstRgb = dst.getRGB(x, y);

        if (srcRgb != dstRgb) {
            throw new RuntimeException("Test failed due to color difference: " +
                                       "src_pixel=" + Integer.toHexString(srcRgb) +
                                       "dst_pixel=" + Integer.toHexString(dstRgb));
        }
    }
}
 
Example 2
Source File: ImageUtil.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Returns <code>true</code> if the given <code>ColorSpace</code> object is
 * an instance of <code>ICC_ColorSpace</code> but is not one of the standard
 * <code>ColorSpace</code>s returned by <code>ColorSpace.getInstance()</code>.
 *
 * @param cs The <code>ColorSpace</code> to test.
 */
public static boolean isNonStandardICCColorSpace(ColorSpace cs) {
    boolean retval = false;

    try {
        // Check the standard ColorSpaces in decreasing order of
        // likelihood except check CS_PYCC last as in some JREs
        // PYCC.pf used not to be installed.
        retval =
            (cs instanceof ICC_ColorSpace) &&
            !(cs.isCS_sRGB() ||
              cs.equals(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB)) ||
              cs.equals(ColorSpace.getInstance(ColorSpace.CS_GRAY)) ||
              cs.equals(ColorSpace.getInstance(ColorSpace.CS_CIEXYZ)) ||
              cs.equals(ColorSpace.getInstance(ColorSpace.CS_PYCC)));
    } catch(IllegalArgumentException e) {
        // PYCC.pf not installed: ignore it - 'retval' is still 'false'.
    }

    return retval;
}
 
Example 3
Source File: ImageUtil.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns <code>true</code> if the given <code>ColorSpace</code> object is
 * an instance of <code>ICC_ColorSpace</code> but is not one of the standard
 * <code>ColorSpace</code>s returned by <code>ColorSpace.getInstance()</code>.
 *
 * @param cs The <code>ColorSpace</code> to test.
 */
public static boolean isNonStandardICCColorSpace(ColorSpace cs) {
    boolean retval = false;

    try {
        // Check the standard ColorSpaces in decreasing order of
        // likelihood except check CS_PYCC last as in some JREs
        // PYCC.pf used not to be installed.
        retval =
            (cs instanceof ICC_ColorSpace) &&
            !(cs.isCS_sRGB() ||
              cs.equals(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB)) ||
              cs.equals(ColorSpace.getInstance(ColorSpace.CS_GRAY)) ||
              cs.equals(ColorSpace.getInstance(ColorSpace.CS_CIEXYZ)) ||
              cs.equals(ColorSpace.getInstance(ColorSpace.CS_PYCC)));
    } catch(IllegalArgumentException e) {
        // PYCC.pf not installed: ignore it - 'retval' is still 'false'.
    }

    return retval;
}
 
Example 4
Source File: TestCompressionBI_BITFIELDS.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
protected void compareImages(BufferedImage src, BufferedImage dst) {
    ColorSpace srcCS = src.getColorModel().getColorSpace();
    ColorSpace dstCS = dst.getColorModel().getColorSpace();
    if (!srcCS.equals(dstCS) && srcCS.getType() == ColorSpace.TYPE_GRAY) {
        System.out.println("Workaround color difference with GRAY.");
        BufferedImage tmp  =
            new BufferedImage(src.getWidth(), src.getHeight(),
                              BufferedImage.TYPE_INT_RGB);
        Graphics g = tmp.createGraphics();
        g.drawImage(src, 0, 0, null);
        src = tmp;
    }
    int y = h / 2;
    for (int i = 0; i < colors.length; i++) {
        int x = dx * i + dx / 2;
        int srcRgb = src.getRGB(x, y);
        int dstRgb = dst.getRGB(x, y);

        if (srcRgb != dstRgb) {
            throw new RuntimeException("Test failed due to color difference: " +
                                       "src_pixel=" + Integer.toHexString(srcRgb) +
                                       "dst_pixel=" + Integer.toHexString(dstRgb));
        }
    }
}
 
Example 5
Source File: JPEG.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns <code>true</code> if the given <code>ColorSpace</code>
 * object is an instance of ICC_ColorSpace but is not one of the
 * standard <code>ColorSpaces</code> returned by
 * <code>ColorSpace.getInstance()</code>.
 */
static boolean isNonStandardICC(ColorSpace cs) {
    boolean retval = false;
    if ((cs instanceof ICC_ColorSpace)
        && (!cs.isCS_sRGB())
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_CIEXYZ)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_GRAY)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_PYCC)))
        ) {
        retval = true;
    }
    return retval;
}
 
Example 6
Source File: JPEG.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Returns <code>true</code> if the given <code>ColorSpace</code>
 * object is an instance of ICC_ColorSpace but is not one of the
 * standard <code>ColorSpaces</code> returned by
 * <code>ColorSpace.getInstance()</code>.
 */
static boolean isNonStandardICC(ColorSpace cs) {
    boolean retval = false;
    if ((cs instanceof ICC_ColorSpace)
        && (!cs.isCS_sRGB())
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_CIEXYZ)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_GRAY)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_PYCC)))
        ) {
        retval = true;
    }
    return retval;
}
 
Example 7
Source File: JPEG.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns <code>true</code> if the given <code>ColorSpace</code>
 * object is an instance of ICC_ColorSpace but is not one of the
 * standard <code>ColorSpaces</code> returned by
 * <code>ColorSpace.getInstance()</code>.
 */
static boolean isNonStandardICC(ColorSpace cs) {
    boolean retval = false;
    if ((cs instanceof ICC_ColorSpace)
        && (!cs.isCS_sRGB())
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_CIEXYZ)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_GRAY)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_PYCC)))
        ) {
        retval = true;
    }
    return retval;
}
 
Example 8
Source File: JPEG.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns <code>true</code> if the given <code>ColorSpace</code>
 * object is an instance of ICC_ColorSpace but is not one of the
 * standard <code>ColorSpaces</code> returned by
 * <code>ColorSpace.getInstance()</code>.
 */
static boolean isNonStandardICC(ColorSpace cs) {
    boolean retval = false;
    if ((cs instanceof ICC_ColorSpace)
        && (!cs.isCS_sRGB())
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_CIEXYZ)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_GRAY)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_PYCC)))
        ) {
        retval = true;
    }
    return retval;
}
 
Example 9
Source File: JPEG.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns <code>true</code> if the given <code>ColorSpace</code>
 * object is an instance of ICC_ColorSpace but is not one of the
 * standard <code>ColorSpaces</code> returned by
 * <code>ColorSpace.getInstance()</code>.
 */
static boolean isNonStandardICC(ColorSpace cs) {
    boolean retval = false;
    if ((cs instanceof ICC_ColorSpace)
        && (!cs.isCS_sRGB())
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_CIEXYZ)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_GRAY)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_PYCC)))
        ) {
        retval = true;
    }
    return retval;
}
 
Example 10
Source File: JPEG.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns <code>true</code> if the given <code>ColorSpace</code>
 * object is an instance of ICC_ColorSpace but is not one of the
 * standard <code>ColorSpaces</code> returned by
 * <code>ColorSpace.getInstance()</code>.
 */
static boolean isNonStandardICC(ColorSpace cs) {
    boolean retval = false;
    if ((cs instanceof ICC_ColorSpace)
        && (!cs.isCS_sRGB())
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_CIEXYZ)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_GRAY)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_PYCC)))
        ) {
        retval = true;
    }
    return retval;
}
 
Example 11
Source File: JPEG.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns <code>true</code> if the given <code>ColorSpace</code>
 * object is an instance of ICC_ColorSpace but is not one of the
 * standard <code>ColorSpaces</code> returned by
 * <code>ColorSpace.getInstance()</code>.
 */
static boolean isNonStandardICC(ColorSpace cs) {
    boolean retval = false;
    if ((cs instanceof ICC_ColorSpace)
        && (!cs.isCS_sRGB())
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_CIEXYZ)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_GRAY)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_PYCC)))
        ) {
        retval = true;
    }
    return retval;
}
 
Example 12
Source File: JPEG.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns <code>true</code> if the given <code>ColorSpace</code>
 * object is an instance of ICC_ColorSpace but is not one of the
 * standard <code>ColorSpaces</code> returned by
 * <code>ColorSpace.getInstance()</code>.
 */
static boolean isNonStandardICC(ColorSpace cs) {
    boolean retval = false;
    if ((cs instanceof ICC_ColorSpace)
        && (!cs.isCS_sRGB())
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_CIEXYZ)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_GRAY)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_PYCC)))
        ) {
        retval = true;
    }
    return retval;
}
 
Example 13
Source File: JPEG.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns {@code true} if the given {@code ColorSpace}
 * object is an instance of ICC_ColorSpace but is not one of the
 * standard {@code ColorSpaces} returned by
 * {@code ColorSpace.getInstance()}.
 */
static boolean isNonStandardICC(ColorSpace cs) {
    boolean retval = false;
    if ((cs instanceof ICC_ColorSpace)
        && (!cs.isCS_sRGB())
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_CIEXYZ)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_GRAY)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_PYCC)))
        ) {
        retval = true;
    }
    return retval;
}
 
Example 14
Source File: JPEG.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Returns {@code true} if the given {@code ColorSpace}
 * object is an instance of ICC_ColorSpace but is not one of the
 * standard {@code ColorSpaces} returned by
 * {@code ColorSpace.getInstance()}.
 */
static boolean isNonStandardICC(ColorSpace cs) {
    boolean retval = false;
    if ((cs instanceof ICC_ColorSpace)
        && (!cs.isCS_sRGB())
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_CIEXYZ)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_GRAY)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_PYCC)))
        ) {
        retval = true;
    }
    return retval;
}
 
Example 15
Source File: JPEG.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns <code>true</code> if the given <code>ColorSpace</code>
 * object is an instance of ICC_ColorSpace but is not one of the
 * standard <code>ColorSpaces</code> returned by
 * <code>ColorSpace.getInstance()</code>.
 */
static boolean isNonStandardICC(ColorSpace cs) {
    boolean retval = false;
    if ((cs instanceof ICC_ColorSpace)
        && (!cs.isCS_sRGB())
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_CIEXYZ)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_GRAY)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_PYCC)))
        ) {
        retval = true;
    }
    return retval;
}
 
Example 16
Source File: JPEG.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns <code>true</code> if the given <code>ColorSpace</code>
 * object is an instance of ICC_ColorSpace but is not one of the
 * standard <code>ColorSpaces</code> returned by
 * <code>ColorSpace.getInstance()</code>.
 */
static boolean isNonStandardICC(ColorSpace cs) {
    boolean retval = false;
    if ((cs instanceof ICC_ColorSpace)
        && (!cs.isCS_sRGB())
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_CIEXYZ)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_GRAY)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_PYCC)))
        ) {
        retval = true;
    }
    return retval;
}
 
Example 17
Source File: JPEG.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Returns <code>true</code> if the given <code>ColorSpace</code>
 * object is an instance of ICC_ColorSpace but is not one of the
 * standard <code>ColorSpaces</code> returned by
 * <code>ColorSpace.getInstance()</code>.
 */
static boolean isNonStandardICC(ColorSpace cs) {
    boolean retval = false;
    if ((cs instanceof ICC_ColorSpace)
        && (!cs.isCS_sRGB())
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_CIEXYZ)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_GRAY)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_PYCC)))
        ) {
        retval = true;
    }
    return retval;
}
 
Example 18
Source File: JPEG.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns <code>true</code> if the given <code>ColorSpace</code>
 * object is an instance of ICC_ColorSpace but is not one of the
 * standard <code>ColorSpaces</code> returned by
 * <code>ColorSpace.getInstance()</code>.
 */
static boolean isNonStandardICC(ColorSpace cs) {
    boolean retval = false;
    if ((cs instanceof ICC_ColorSpace)
        && (!cs.isCS_sRGB())
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_CIEXYZ)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_GRAY)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_PYCC)))
        ) {
        retval = true;
    }
    return retval;
}
 
Example 19
Source File: JPEG.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns <code>true</code> if the given <code>ColorSpace</code>
 * object is an instance of ICC_ColorSpace but is not one of the
 * standard <code>ColorSpaces</code> returned by
 * <code>ColorSpace.getInstance()</code>.
 */
static boolean isNonStandardICC(ColorSpace cs) {
    boolean retval = false;
    if ((cs instanceof ICC_ColorSpace)
        && (!cs.isCS_sRGB())
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_CIEXYZ)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_GRAY)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_PYCC)))
        ) {
        retval = true;
    }
    return retval;
}
 
Example 20
Source File: JPEG.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns <code>true</code> if the given <code>ColorSpace</code>
 * object is an instance of ICC_ColorSpace but is not one of the
 * standard <code>ColorSpaces</code> returned by
 * <code>ColorSpace.getInstance()</code>.
 */
static boolean isNonStandardICC(ColorSpace cs) {
    boolean retval = false;
    if ((cs instanceof ICC_ColorSpace)
        && (!cs.isCS_sRGB())
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_CIEXYZ)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_GRAY)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB)))
        && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_PYCC)))
        ) {
        retval = true;
    }
    return retval;
}