Search in sources :

Example 1 with ICC_Profile

use of java.awt.color.ICC_Profile in project jdk8u_jdk by JetBrains.

the class DisposalCrashTest method main.

public static void main(String[] args) {
    int[] ids = new int[] { CS_sRGB, CS_CIEXYZ, CS_GRAY, CS_LINEAR_RGB, CS_PYCC };
    for (int id : ids) {
        ICC_Profile p = getCopyOf(id);
    }
    while (!v.isEmpty()) {
        System.gc();
        System.out.println(".");
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
        }
        ;
        final Reference<? extends ICC_Profile> ref = queue.poll();
        System.out.println("Got reference: " + ref);
        v.remove(ref);
    }
    System.out.println("Test PASSED.");
}
Also used : ICC_Profile(java.awt.color.ICC_Profile)

Example 2 with ICC_Profile

use of java.awt.color.ICC_Profile in project jdk8u_jdk by JetBrains.

the class ImageTypeProducer method setImageData.

/*
     * Called by the native code whenever an image header has been
     * read.  Whether we read metadata or not, we always need this
     * information, so it is passed back independently of
     * metadata, which may never be read.
     */
private void setImageData(int width, int height, int colorSpaceCode, int outColorSpaceCode, int numComponents, byte[] iccData) {
    this.width = width;
    this.height = height;
    this.colorSpaceCode = colorSpaceCode;
    this.outColorSpaceCode = outColorSpaceCode;
    this.numComponents = numComponents;
    if (iccData == null) {
        iccCS = null;
        return;
    }
    ICC_Profile newProfile = null;
    try {
        newProfile = ICC_Profile.getInstance(iccData);
    } catch (IllegalArgumentException e) {
        /*
             * Color profile data seems to be invalid.
             * Ignore this profile.
             */
        iccCS = null;
        warningOccurred(WARNING_IGNORE_INVALID_ICC);
        return;
    }
    byte[] newData = newProfile.getData();
    ICC_Profile oldProfile = null;
    if (iccCS instanceof ICC_ColorSpace) {
        oldProfile = ((ICC_ColorSpace) iccCS).getProfile();
    }
    byte[] oldData = null;
    if (oldProfile != null) {
        oldData = oldProfile.getData();
    }
    /*
         * At the moment we can't rely on the ColorSpace.equals()
         * and ICC_Profile.equals() because they do not detect
         * the case when two profiles are created from same data.
         *
         * So, we have to do data comparison in order to avoid
         * creation of different ColorSpace instances for the same
         * embedded data.
         */
    if (oldData == null || !java.util.Arrays.equals(oldData, newData)) {
        iccCS = new ICC_ColorSpace(newProfile);
        // verify new color space
        try {
            float[] colors = iccCS.fromRGB(new float[] { 1f, 0f, 0f });
        } catch (CMMException e) {
            /*
                 * Embedded profile seems to be corrupted.
                 * Ignore this profile.
                 */
            iccCS = null;
            cbLock.lock();
            try {
                warningOccurred(WARNING_IGNORE_INVALID_ICC);
            } finally {
                cbLock.unlock();
            }
        }
    }
}
Also used : ICC_ColorSpace(java.awt.color.ICC_ColorSpace) ICC_Profile(java.awt.color.ICC_Profile) CMMException(java.awt.color.CMMException)

Example 3 with ICC_Profile

use of java.awt.color.ICC_Profile in project jdk8u_jdk by JetBrains.

the class CMMTests method getColorSpace.

protected static ColorSpace getColorSpace(TestEnvironment env) {
    ColorSpace cs;
    //(Boolean)env.getModifier(usePlatfromProfiles);
    Boolean usePlatfrom = true;
    int cs_code = env.getIntValue(csList);
    if (usePlatfrom) {
        cs = ColorSpace.getInstance(cs_code);
    } else {
        String resource = "profiles/";
        switch(cs_code) {
            case ColorSpace.CS_CIEXYZ:
                resource += "CIEXYZ.pf";
                break;
            case ColorSpace.CS_GRAY:
                resource += "GRAY.pf";
                break;
            case ColorSpace.CS_LINEAR_RGB:
                resource += "LINEAR_RGB.pf";
                break;
            case ColorSpace.CS_PYCC:
                resource += "PYCC.pf";
                break;
            case ColorSpace.CS_sRGB:
                resource += "sRGB.pf";
                break;
            default:
                throw new RuntimeException("Unknown color space: " + cs_code);
        }
        try {
            InputStream is = CMMTests.class.getResourceAsStream(resource);
            ICC_Profile p = ICC_Profile.getInstance(is);
            cs = new ICC_ColorSpace(p);
        } catch (IOException e) {
            throw new RuntimeException("Unable load profile from resource " + resource, e);
        }
    }
    return cs;
}
Also used : ICC_ColorSpace(java.awt.color.ICC_ColorSpace) ICC_ColorSpace(java.awt.color.ICC_ColorSpace) ColorSpace(java.awt.color.ColorSpace) InputStream(java.io.InputStream) IOException(java.io.IOException) ICC_Profile(java.awt.color.ICC_Profile)

Example 4 with ICC_Profile

use of java.awt.color.ICC_Profile in project jdk8u_jdk by JetBrains.

the class ColConvTest method isOpenProfile.

public static boolean isOpenProfile() {
    if (isOpenProfile == null) {
        ICC_Profile p = ICC_Profile.getInstance(ColorSpace.CS_sRGB);
        byte[] h = p.getData(ICC_Profile.icSigHead);
        if (h == null || h.length < 128) {
            throw new RuntimeException("Test failed: invalid sRGB header");
        }
        final byte[] lcmsID = new byte[] { // l
        (byte) 0x6c, // c
        (byte) 0x63, // m
        (byte) 0x6d, // s
        (byte) 0x73 };
        int off = ICC_Profile.icHdrCmmId;
        isOpenProfile = ((h[off + 0] == lcmsID[0]) && (h[off + 1] == lcmsID[1]) && (h[off + 2] == lcmsID[2]) && (h[off + 3] == lcmsID[3]));
    }
    return isOpenProfile;
}
Also used : ICC_Profile(java.awt.color.ICC_Profile)

Example 5 with ICC_Profile

use of java.awt.color.ICC_Profile in project jdk8u_jdk by JetBrains.

the class InvalidRenderIntentTest method main.

public static void main(String[] args) {
    ICC_Profile pSRGB = ICC_Profile.getInstance(CS_sRGB);
    byte[] raw_data = pSRGB.getData();
    setRenderingIntent(0x1000000, raw_data);
    ICC_Profile p = ICC_Profile.getInstance(raw_data);
    ICC_ColorSpace cs = new ICC_ColorSpace(p);
    // perfrom test color conversion
    ColorConvertOp op = new ColorConvertOp(cs, ColorSpace.getInstance(CS_sRGB), null);
    BufferedImage src = new BufferedImage(1, 1, TYPE_3BYTE_BGR);
    BufferedImage dst = new BufferedImage(1, 1, TYPE_3BYTE_BGR);
    try {
        op.filter(src.getRaster(), dst.getRaster());
    } catch (CMMException e) {
        throw new RuntimeException("Test failed.", e);
    }
    System.out.println("Test passed.");
}
Also used : ICC_ColorSpace(java.awt.color.ICC_ColorSpace) ColorConvertOp(java.awt.image.ColorConvertOp) ICC_Profile(java.awt.color.ICC_Profile) CMMException(java.awt.color.CMMException) BufferedImage(java.awt.image.BufferedImage)

Aggregations

ICC_Profile (java.awt.color.ICC_Profile)8 ICC_ColorSpace (java.awt.color.ICC_ColorSpace)3 CMMException (java.awt.color.CMMException)2 ColorSpace (java.awt.color.ColorSpace)1 BufferedImage (java.awt.image.BufferedImage)1 ColorConvertOp (java.awt.image.ColorConvertOp)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 WeakReference (java.lang.ref.WeakReference)1