java.awt.color.ColorSpace#toRGB ( )源码实例Demo

下面列出了java.awt.color.ColorSpace#toRGB ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jdk1.8-source-analysis   文件: Color.java
/**
 * Creates a color in the specified <code>ColorSpace</code>
 * with the color components specified in the <code>float</code>
 * array and the specified alpha.  The number of components is
 * determined by the type of the <code>ColorSpace</code>.  For
 * example, RGB requires 3 components, but CMYK requires 4
 * components.
 * @param cspace the <code>ColorSpace</code> to be used to
 *                  interpret the components
 * @param components an arbitrary number of color components
 *                      that is compatible with the <code>ColorSpace</code>
 * @param alpha alpha value
 * @throws IllegalArgumentException if any of the values in the
 *         <code>components</code> array or <code>alpha</code> is
 *         outside of the range 0.0 to 1.0
 * @see #getComponents
 * @see #getColorComponents
 */
public Color(ColorSpace cspace, float components[], float alpha) {
    boolean rangeError = false;
    String badComponentString = "";
    int n = cspace.getNumComponents();
    fvalue = new float[n];
    for (int i = 0; i < n; i++) {
        if (components[i] < 0.0 || components[i] > 1.0) {
            rangeError = true;
            badComponentString = badComponentString + "Component " + i
                                 + " ";
        } else {
            fvalue[i] = components[i];
        }
    }
    if (alpha < 0.0 || alpha > 1.0) {
        rangeError = true;
        badComponentString = badComponentString + "Alpha";
    } else {
        falpha = alpha;
    }
    if (rangeError) {
        throw new IllegalArgumentException(
            "Color parameter outside of expected range: " +
            badComponentString);
    }
    frgbvalue = cspace.toRGB(fvalue);
    cs = cspace;
    value = ((((int)(falpha*255)) & 0xFF) << 24) |
            ((((int)(frgbvalue[0]*255)) & 0xFF) << 16) |
            ((((int)(frgbvalue[1]*255)) & 0xFF) << 8)  |
            ((((int)(frgbvalue[2]*255)) & 0xFF) << 0);
}
 
源代码2 项目: openjdk-8   文件: DataConversionTests.java
public void runTest(Object ctx, int numReps) {
    final Context ictx = (Context) ctx;
    final ColorSpace cs = ictx.cs;

    final float[] val = ictx.val;

    do {
        try {
            cs.toRGB(val);
        } catch (Exception e) {
            e.printStackTrace();
        }
    } while (--numReps >= 0);
}
 
源代码3 项目: hottub   文件: Color.java
/**
 * Creates a color in the specified <code>ColorSpace</code>
 * with the color components specified in the <code>float</code>
 * array and the specified alpha.  The number of components is
 * determined by the type of the <code>ColorSpace</code>.  For
 * example, RGB requires 3 components, but CMYK requires 4
 * components.
 * @param cspace the <code>ColorSpace</code> to be used to
 *                  interpret the components
 * @param components an arbitrary number of color components
 *                      that is compatible with the <code>ColorSpace</code>
 * @param alpha alpha value
 * @throws IllegalArgumentException if any of the values in the
 *         <code>components</code> array or <code>alpha</code> is
 *         outside of the range 0.0 to 1.0
 * @see #getComponents
 * @see #getColorComponents
 */
public Color(ColorSpace cspace, float components[], float alpha) {
    boolean rangeError = false;
    String badComponentString = "";
    int n = cspace.getNumComponents();
    fvalue = new float[n];
    for (int i = 0; i < n; i++) {
        if (components[i] < 0.0 || components[i] > 1.0) {
            rangeError = true;
            badComponentString = badComponentString + "Component " + i
                                 + " ";
        } else {
            fvalue[i] = components[i];
        }
    }
    if (alpha < 0.0 || alpha > 1.0) {
        rangeError = true;
        badComponentString = badComponentString + "Alpha";
    } else {
        falpha = alpha;
    }
    if (rangeError) {
        throw new IllegalArgumentException(
            "Color parameter outside of expected range: " +
            badComponentString);
    }
    frgbvalue = cspace.toRGB(fvalue);
    cs = cspace;
    value = ((((int)(falpha*255)) & 0xFF) << 24) |
            ((((int)(frgbvalue[0]*255)) & 0xFF) << 16) |
            ((((int)(frgbvalue[1]*255)) & 0xFF) << 8)  |
            ((((int)(frgbvalue[2]*255)) & 0xFF) << 0);
}
 
源代码4 项目: jdk8u-jdk   文件: Color.java
/**
 * Creates a color in the specified <code>ColorSpace</code>
 * with the color components specified in the <code>float</code>
 * array and the specified alpha.  The number of components is
 * determined by the type of the <code>ColorSpace</code>.  For
 * example, RGB requires 3 components, but CMYK requires 4
 * components.
 * @param cspace the <code>ColorSpace</code> to be used to
 *                  interpret the components
 * @param components an arbitrary number of color components
 *                      that is compatible with the <code>ColorSpace</code>
 * @param alpha alpha value
 * @throws IllegalArgumentException if any of the values in the
 *         <code>components</code> array or <code>alpha</code> is
 *         outside of the range 0.0 to 1.0
 * @see #getComponents
 * @see #getColorComponents
 */
public Color(ColorSpace cspace, float components[], float alpha) {
    boolean rangeError = false;
    String badComponentString = "";
    int n = cspace.getNumComponents();
    fvalue = new float[n];
    for (int i = 0; i < n; i++) {
        if (components[i] < 0.0 || components[i] > 1.0) {
            rangeError = true;
            badComponentString = badComponentString + "Component " + i
                                 + " ";
        } else {
            fvalue[i] = components[i];
        }
    }
    if (alpha < 0.0 || alpha > 1.0) {
        rangeError = true;
        badComponentString = badComponentString + "Alpha";
    } else {
        falpha = alpha;
    }
    if (rangeError) {
        throw new IllegalArgumentException(
            "Color parameter outside of expected range: " +
            badComponentString);
    }
    frgbvalue = cspace.toRGB(fvalue);
    cs = cspace;
    value = ((((int)(falpha*255)) & 0xFF) << 24) |
            ((((int)(frgbvalue[0]*255)) & 0xFF) << 16) |
            ((((int)(frgbvalue[1]*255)) & 0xFF) << 8)  |
            ((((int)(frgbvalue[2]*255)) & 0xFF) << 0);
}
 
源代码5 项目: TencentKona-8   文件: Color.java
/**
 * Creates a color in the specified <code>ColorSpace</code>
 * with the color components specified in the <code>float</code>
 * array and the specified alpha.  The number of components is
 * determined by the type of the <code>ColorSpace</code>.  For
 * example, RGB requires 3 components, but CMYK requires 4
 * components.
 * @param cspace the <code>ColorSpace</code> to be used to
 *                  interpret the components
 * @param components an arbitrary number of color components
 *                      that is compatible with the <code>ColorSpace</code>
 * @param alpha alpha value
 * @throws IllegalArgumentException if any of the values in the
 *         <code>components</code> array or <code>alpha</code> is
 *         outside of the range 0.0 to 1.0
 * @see #getComponents
 * @see #getColorComponents
 */
public Color(ColorSpace cspace, float components[], float alpha) {
    boolean rangeError = false;
    String badComponentString = "";
    int n = cspace.getNumComponents();
    fvalue = new float[n];
    for (int i = 0; i < n; i++) {
        if (components[i] < 0.0 || components[i] > 1.0) {
            rangeError = true;
            badComponentString = badComponentString + "Component " + i
                                 + " ";
        } else {
            fvalue[i] = components[i];
        }
    }
    if (alpha < 0.0 || alpha > 1.0) {
        rangeError = true;
        badComponentString = badComponentString + "Alpha";
    } else {
        falpha = alpha;
    }
    if (rangeError) {
        throw new IllegalArgumentException(
            "Color parameter outside of expected range: " +
            badComponentString);
    }
    frgbvalue = cspace.toRGB(fvalue);
    cs = cspace;
    value = ((((int)(falpha*255)) & 0xFF) << 24) |
            ((((int)(frgbvalue[0]*255)) & 0xFF) << 16) |
            ((((int)(frgbvalue[1]*255)) & 0xFF) << 8)  |
            ((((int)(frgbvalue[2]*255)) & 0xFF) << 0);
}
 
源代码6 项目: jdk8u60   文件: DataConversionTests.java
public void runTest(Object ctx, int numReps) {
    final Context ictx = (Context) ctx;
    final ColorSpace cs = ictx.cs;

    final float[] val = ictx.val;

    do {
        try {
            cs.toRGB(val);
        } catch (Exception e) {
            e.printStackTrace();
        }
    } while (--numReps >= 0);
}
 
源代码7 项目: jdk8u60   文件: Color.java
/**
 * Creates a color in the specified <code>ColorSpace</code>
 * with the color components specified in the <code>float</code>
 * array and the specified alpha.  The number of components is
 * determined by the type of the <code>ColorSpace</code>.  For
 * example, RGB requires 3 components, but CMYK requires 4
 * components.
 * @param cspace the <code>ColorSpace</code> to be used to
 *                  interpret the components
 * @param components an arbitrary number of color components
 *                      that is compatible with the <code>ColorSpace</code>
 * @param alpha alpha value
 * @throws IllegalArgumentException if any of the values in the
 *         <code>components</code> array or <code>alpha</code> is
 *         outside of the range 0.0 to 1.0
 * @see #getComponents
 * @see #getColorComponents
 */
public Color(ColorSpace cspace, float components[], float alpha) {
    boolean rangeError = false;
    String badComponentString = "";
    int n = cspace.getNumComponents();
    fvalue = new float[n];
    for (int i = 0; i < n; i++) {
        if (components[i] < 0.0 || components[i] > 1.0) {
            rangeError = true;
            badComponentString = badComponentString + "Component " + i
                                 + " ";
        } else {
            fvalue[i] = components[i];
        }
    }
    if (alpha < 0.0 || alpha > 1.0) {
        rangeError = true;
        badComponentString = badComponentString + "Alpha";
    } else {
        falpha = alpha;
    }
    if (rangeError) {
        throw new IllegalArgumentException(
            "Color parameter outside of expected range: " +
            badComponentString);
    }
    frgbvalue = cspace.toRGB(fvalue);
    cs = cspace;
    value = ((((int)(falpha*255)) & 0xFF) << 24) |
            ((((int)(frgbvalue[0]*255)) & 0xFF) << 16) |
            ((((int)(frgbvalue[1]*255)) & 0xFF) << 8)  |
            ((((int)(frgbvalue[2]*255)) & 0xFF) << 0);
}
 
源代码8 项目: JDKSourceCode1.8   文件: Color.java
/**
 * Creates a color in the specified <code>ColorSpace</code>
 * with the color components specified in the <code>float</code>
 * array and the specified alpha.  The number of components is
 * determined by the type of the <code>ColorSpace</code>.  For
 * example, RGB requires 3 components, but CMYK requires 4
 * components.
 * @param cspace the <code>ColorSpace</code> to be used to
 *                  interpret the components
 * @param components an arbitrary number of color components
 *                      that is compatible with the <code>ColorSpace</code>
 * @param alpha alpha value
 * @throws IllegalArgumentException if any of the values in the
 *         <code>components</code> array or <code>alpha</code> is
 *         outside of the range 0.0 to 1.0
 * @see #getComponents
 * @see #getColorComponents
 */
public Color(ColorSpace cspace, float components[], float alpha) {
    boolean rangeError = false;
    String badComponentString = "";
    int n = cspace.getNumComponents();
    fvalue = new float[n];
    for (int i = 0; i < n; i++) {
        if (components[i] < 0.0 || components[i] > 1.0) {
            rangeError = true;
            badComponentString = badComponentString + "Component " + i
                                 + " ";
        } else {
            fvalue[i] = components[i];
        }
    }
    if (alpha < 0.0 || alpha > 1.0) {
        rangeError = true;
        badComponentString = badComponentString + "Alpha";
    } else {
        falpha = alpha;
    }
    if (rangeError) {
        throw new IllegalArgumentException(
            "Color parameter outside of expected range: " +
            badComponentString);
    }
    frgbvalue = cspace.toRGB(fvalue);
    cs = cspace;
    value = ((((int)(falpha*255)) & 0xFF) << 24) |
            ((((int)(frgbvalue[0]*255)) & 0xFF) << 16) |
            ((((int)(frgbvalue[1]*255)) & 0xFF) << 8)  |
            ((((int)(frgbvalue[2]*255)) & 0xFF) << 0);
}
 
源代码9 项目: openjdk-jdk8u   文件: DataConversionTests.java
public void runTest(Object ctx, int numReps) {
    final Context ictx = (Context) ctx;
    final ColorSpace cs = ictx.cs;

    final float[] val = ictx.val;

    do {
        try {
            cs.toRGB(val);
        } catch (Exception e) {
            e.printStackTrace();
        }
    } while (--numReps >= 0);
}
 
源代码10 项目: openjdk-8-source   文件: Color.java
/**
 * Creates a color in the specified <code>ColorSpace</code>
 * with the color components specified in the <code>float</code>
 * array and the specified alpha.  The number of components is
 * determined by the type of the <code>ColorSpace</code>.  For
 * example, RGB requires 3 components, but CMYK requires 4
 * components.
 * @param cspace the <code>ColorSpace</code> to be used to
 *                  interpret the components
 * @param components an arbitrary number of color components
 *                      that is compatible with the <code>ColorSpace</code>
 * @param alpha alpha value
 * @throws IllegalArgumentException if any of the values in the
 *         <code>components</code> array or <code>alpha</code> is
 *         outside of the range 0.0 to 1.0
 * @see #getComponents
 * @see #getColorComponents
 */
public Color(ColorSpace cspace, float components[], float alpha) {
    boolean rangeError = false;
    String badComponentString = "";
    int n = cspace.getNumComponents();
    fvalue = new float[n];
    for (int i = 0; i < n; i++) {
        if (components[i] < 0.0 || components[i] > 1.0) {
            rangeError = true;
            badComponentString = badComponentString + "Component " + i
                                 + " ";
        } else {
            fvalue[i] = components[i];
        }
    }
    if (alpha < 0.0 || alpha > 1.0) {
        rangeError = true;
        badComponentString = badComponentString + "Alpha";
    } else {
        falpha = alpha;
    }
    if (rangeError) {
        throw new IllegalArgumentException(
            "Color parameter outside of expected range: " +
            badComponentString);
    }
    frgbvalue = cspace.toRGB(fvalue);
    cs = cspace;
    value = ((((int)(falpha*255)) & 0xFF) << 24) |
            ((((int)(frgbvalue[0]*255)) & 0xFF) << 16) |
            ((((int)(frgbvalue[1]*255)) & 0xFF) << 8)  |
            ((((int)(frgbvalue[2]*255)) & 0xFF) << 0);
}
 
源代码11 项目: openjdk-jdk8u-backup   文件: DataConversionTests.java
public void runTest(Object ctx, int numReps) {
    final Context ictx = (Context) ctx;
    final ColorSpace cs = ictx.cs;

    final float[] val = ictx.val;

    do {
        try {
            cs.toRGB(val);
        } catch (Exception e) {
            e.printStackTrace();
        }
    } while (--numReps >= 0);
}
 
源代码12 项目: jdk8u-dev-jdk   文件: DataConversionTests.java
public void runTest(Object ctx, int numReps) {
    final Context ictx = (Context) ctx;
    final ColorSpace cs = ictx.cs;

    final float[] val = ictx.val;

    do {
        try {
            cs.toRGB(val);
        } catch (Exception e) {
            e.printStackTrace();
        }
    } while (--numReps >= 0);
}
 
源代码13 项目: Bytecoder   文件: Color.java
/**
 * Creates a color in the specified {@code ColorSpace}
 * with the color components specified in the {@code float}
 * array and the specified alpha.  The number of components is
 * determined by the type of the {@code ColorSpace}.  For
 * example, RGB requires 3 components, but CMYK requires 4
 * components.
 * @param cspace the {@code ColorSpace} to be used to
 *                  interpret the components
 * @param components an arbitrary number of color components
 *                      that is compatible with the {@code ColorSpace}
 * @param alpha alpha value
 * @throws IllegalArgumentException if any of the values in the
 *         {@code components} array or {@code alpha} is
 *         outside of the range 0.0 to 1.0
 * @see #getComponents
 * @see #getColorComponents
 */
public Color(ColorSpace cspace, float[] components, float alpha) {
    boolean rangeError = false;
    String badComponentString = "";
    int n = cspace.getNumComponents();
    fvalue = new float[n];
    for (int i = 0; i < n; i++) {
        if (components[i] < 0.0 || components[i] > 1.0) {
            rangeError = true;
            badComponentString = badComponentString + "Component " + i
                                 + " ";
        } else {
            fvalue[i] = components[i];
        }
    }
    if (alpha < 0.0 || alpha > 1.0) {
        rangeError = true;
        badComponentString = badComponentString + "Alpha";
    } else {
        falpha = alpha;
    }
    if (rangeError) {
        throw new IllegalArgumentException(
            "Color parameter outside of expected range: " +
            badComponentString);
    }
    frgbvalue = cspace.toRGB(fvalue);
    cs = cspace;
    value = ((((int)(falpha*255)) & 0xFF) << 24) |
            ((((int)(frgbvalue[0]*255)) & 0xFF) << 16) |
            ((((int)(frgbvalue[1]*255)) & 0xFF) << 8)  |
            ((((int)(frgbvalue[2]*255)) & 0xFF) << 0);
}
 
源代码14 项目: jdk8u_jdk   文件: Color.java
/**
 * Creates a color in the specified <code>ColorSpace</code>
 * with the color components specified in the <code>float</code>
 * array and the specified alpha.  The number of components is
 * determined by the type of the <code>ColorSpace</code>.  For
 * example, RGB requires 3 components, but CMYK requires 4
 * components.
 * @param cspace the <code>ColorSpace</code> to be used to
 *                  interpret the components
 * @param components an arbitrary number of color components
 *                      that is compatible with the <code>ColorSpace</code>
 * @param alpha alpha value
 * @throws IllegalArgumentException if any of the values in the
 *         <code>components</code> array or <code>alpha</code> is
 *         outside of the range 0.0 to 1.0
 * @see #getComponents
 * @see #getColorComponents
 */
public Color(ColorSpace cspace, float components[], float alpha) {
    boolean rangeError = false;
    String badComponentString = "";
    int n = cspace.getNumComponents();
    fvalue = new float[n];
    for (int i = 0; i < n; i++) {
        if (components[i] < 0.0 || components[i] > 1.0) {
            rangeError = true;
            badComponentString = badComponentString + "Component " + i
                                 + " ";
        } else {
            fvalue[i] = components[i];
        }
    }
    if (alpha < 0.0 || alpha > 1.0) {
        rangeError = true;
        badComponentString = badComponentString + "Alpha";
    } else {
        falpha = alpha;
    }
    if (rangeError) {
        throw new IllegalArgumentException(
            "Color parameter outside of expected range: " +
            badComponentString);
    }
    frgbvalue = cspace.toRGB(fvalue);
    cs = cspace;
    value = ((((int)(falpha*255)) & 0xFF) << 24) |
            ((((int)(frgbvalue[0]*255)) & 0xFF) << 16) |
            ((((int)(frgbvalue[1]*255)) & 0xFF) << 8)  |
            ((((int)(frgbvalue[2]*255)) & 0xFF) << 0);
}
 
源代码15 项目: openjdk-jdk9   文件: Color.java
/**
 * Creates a color in the specified {@code ColorSpace}
 * with the color components specified in the {@code float}
 * array and the specified alpha.  The number of components is
 * determined by the type of the {@code ColorSpace}.  For
 * example, RGB requires 3 components, but CMYK requires 4
 * components.
 * @param cspace the {@code ColorSpace} to be used to
 *                  interpret the components
 * @param components an arbitrary number of color components
 *                      that is compatible with the {@code ColorSpace}
 * @param alpha alpha value
 * @throws IllegalArgumentException if any of the values in the
 *         {@code components} array or {@code alpha} is
 *         outside of the range 0.0 to 1.0
 * @see #getComponents
 * @see #getColorComponents
 */
public Color(ColorSpace cspace, float components[], float alpha) {
    boolean rangeError = false;
    String badComponentString = "";
    int n = cspace.getNumComponents();
    fvalue = new float[n];
    for (int i = 0; i < n; i++) {
        if (components[i] < 0.0 || components[i] > 1.0) {
            rangeError = true;
            badComponentString = badComponentString + "Component " + i
                                 + " ";
        } else {
            fvalue[i] = components[i];
        }
    }
    if (alpha < 0.0 || alpha > 1.0) {
        rangeError = true;
        badComponentString = badComponentString + "Alpha";
    } else {
        falpha = alpha;
    }
    if (rangeError) {
        throw new IllegalArgumentException(
            "Color parameter outside of expected range: " +
            badComponentString);
    }
    frgbvalue = cspace.toRGB(fvalue);
    cs = cspace;
    value = ((((int)(falpha*255)) & 0xFF) << 24) |
            ((((int)(frgbvalue[0]*255)) & 0xFF) << 16) |
            ((((int)(frgbvalue[1]*255)) & 0xFF) << 8)  |
            ((((int)(frgbvalue[2]*255)) & 0xFF) << 0);
}
 
源代码16 项目: jdk8u-jdk   文件: DataConversionTests.java
public void runTest(Object ctx, int numReps) {
    final Context ictx = (Context) ctx;
    final ColorSpace cs = ictx.cs;

    final float[] val = ictx.val;

    do {
        try {
            cs.toRGB(val);
        } catch (Exception e) {
            e.printStackTrace();
        }
    } while (--numReps >= 0);
}
 
源代码17 项目: jdk8u-jdk   文件: Color.java
/**
 * Creates a color in the specified <code>ColorSpace</code>
 * with the color components specified in the <code>float</code>
 * array and the specified alpha.  The number of components is
 * determined by the type of the <code>ColorSpace</code>.  For
 * example, RGB requires 3 components, but CMYK requires 4
 * components.
 * @param cspace the <code>ColorSpace</code> to be used to
 *                  interpret the components
 * @param components an arbitrary number of color components
 *                      that is compatible with the <code>ColorSpace</code>
 * @param alpha alpha value
 * @throws IllegalArgumentException if any of the values in the
 *         <code>components</code> array or <code>alpha</code> is
 *         outside of the range 0.0 to 1.0
 * @see #getComponents
 * @see #getColorComponents
 */
public Color(ColorSpace cspace, float components[], float alpha) {
    boolean rangeError = false;
    String badComponentString = "";
    int n = cspace.getNumComponents();
    fvalue = new float[n];
    for (int i = 0; i < n; i++) {
        if (components[i] < 0.0 || components[i] > 1.0) {
            rangeError = true;
            badComponentString = badComponentString + "Component " + i
                                 + " ";
        } else {
            fvalue[i] = components[i];
        }
    }
    if (alpha < 0.0 || alpha > 1.0) {
        rangeError = true;
        badComponentString = badComponentString + "Alpha";
    } else {
        falpha = alpha;
    }
    if (rangeError) {
        throw new IllegalArgumentException(
            "Color parameter outside of expected range: " +
            badComponentString);
    }
    frgbvalue = cspace.toRGB(fvalue);
    cs = cspace;
    value = ((((int)(falpha*255)) & 0xFF) << 24) |
            ((((int)(frgbvalue[0]*255)) & 0xFF) << 16) |
            ((((int)(frgbvalue[1]*255)) & 0xFF) << 8)  |
            ((((int)(frgbvalue[2]*255)) & 0xFF) << 0);
}
 
源代码18 项目: jdk8u_jdk   文件: DataConversionTests.java
public void runTest(Object ctx, int numReps) {
    final Context ictx = (Context) ctx;
    final ColorSpace cs = ictx.cs;

    final float[] val = ictx.val;

    do {
        try {
            cs.toRGB(val);
        } catch (Exception e) {
            e.printStackTrace();
        }
    } while (--numReps >= 0);
}
 
源代码19 项目: hottub   文件: DataConversionTests.java
public void runTest(Object ctx, int numReps) {
    final Context ictx = (Context) ctx;
    final ColorSpace cs = ictx.cs;

    final float[] val = ictx.val;

    do {
        try {
            cs.toRGB(val);
        } catch (Exception e) {
            e.printStackTrace();
        }
    } while (--numReps >= 0);
}
 
源代码20 项目: MyBox   文件: ImageConvert.java
public static BufferedImage cmyk2rgb(final byte[] buffer, final int w,
        final int h) throws IOException {

    final ColorSpace CMYK = ImageValue.adobeCmykColorSpace();

    final int pixelCount = w * h * 4;
    int C, M, Y, K, lastC = -1, lastM = -1, lastY = -1, lastK = -1;

    int j = 0;
    float[] RGB = new float[]{0f, 0f, 0f};
    //turn YCC in Buffer to CYM using profile
    for (int i = 0; i < pixelCount; i = i + 4) {

        C = (buffer[i] & 255);
        M = (buffer[i + 1] & 255);
        Y = (buffer[i + 2] & 255);
        K = (buffer[i + 3] & 255);

        // System.out.println(C+" "+M+" "+Y+" "+K);
        if (C == lastC && M == lastM && Y == lastY && K == lastK) {
            //no change so use last value
        } else { //new value

            RGB = CMYK.toRGB(new float[]{C / 255f, M / 255f, Y / 255f, K / 255f});

            //flag so we can just reuse if next value the same
            lastC = C;
            lastM = M;
            lastY = Y;
            lastK = K;
        }

        //put back as CMY
        buffer[j] = (byte) (RGB[0] * 255f);
        buffer[j + 1] = (byte) (RGB[1] * 255f);
        buffer[j + 2] = (byte) (RGB[2] * 255f);

        j = j + 3;

    }

    /**
     * create CMYK raster from buffer
     */
    final Raster raster = Raster.createInterleavedRaster(new DataBufferByte(buffer, j), w, h, w * 3, 3, new int[]{0, 1, 2}, null);

    //data now sRGB so create image
    final BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    image.setData(raster);

    return image;
}