001: /*
002: * Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package sun.java2d.cmm.lcms;
027:
028: import java.awt.color.ColorSpace;
029: import java.awt.color.ICC_Profile;
030: import java.awt.color.CMMException;
031: import sun.java2d.cmm.ColorTransform;
032: import sun.java2d.cmm.PCMM;
033: import sun.java2d.cmm.lcms.LCMS;
034: import sun.java2d.cmm.lcms.LCMSTransform;
035:
036: public class LCMS implements PCMM {
037:
038: /* methods invoked from ICC_Profile */
039: public native long loadProfile(byte[] data);
040:
041: public native void freeProfile(long profileID);
042:
043: public native synchronized int getProfileSize(long profileID);
044:
045: public native synchronized void getProfileData(long profileID,
046: byte[] data);
047:
048: public native synchronized int getTagSize(long profileID,
049: int tagSignature);
050:
051: public native synchronized void getTagData(long profileID,
052: int tagSignature, byte[] data);
053:
054: public native synchronized void setTagData(long profileID,
055: int tagSignature, byte[] data);
056:
057: public static native long getProfileID(ICC_Profile profile);
058:
059: public static native long createNativeTransform(long[] profileIDs,
060: int renderType, Object disposerRef);
061:
062: /**
063: * Constructs ColorTransform object corresponding to an ICC_profile
064: */
065: public ColorTransform createTransform(ICC_Profile profile,
066: int renderType, int transformType) {
067: return new LCMSTransform(profile, renderType, renderType);
068: }
069:
070: /**
071: * Constructs an ColorTransform object from a list of ColorTransform
072: * objects
073: */
074: public synchronized ColorTransform createTransform(
075: ColorTransform[] transforms) {
076: return new LCMSTransform(transforms);
077: }
078:
079: /* methods invoked from LCMSTransform */
080: public static native void colorConvert(LCMSTransform trans,
081: LCMSImageLayout src, LCMSImageLayout dest);
082:
083: public static native void freeTransform(long ID);
084:
085: public static native void initLCMS(Class Trans, Class IL, Class Pf);
086:
087: /* the class initializer which loads the CMM */
088: static {
089: java.security.AccessController
090: .doPrivileged(new java.security.PrivilegedAction() {
091: public Object run() {
092: /* We need to load awt here because of usage trace and
093: * disposer frameworks
094: */
095: System.loadLibrary("awt");
096: System.loadLibrary("lcms");
097: return null;
098: }
099: });
100:
101: initLCMS(LCMSTransform.class, LCMSImageLayout.class,
102: ICC_Profile.class);
103: }
104: }
|