ImageGear for Java
ImageGear Color Profile API

ImageGear for Java offers two ways to specify color profiles to use for color conversion operations.

Both ways are easy to use, and you should use whichever one suits your particular application's needs.

To enable implicit or "automatic" usage of color profiles for color conversion operations, use the ImGearColorProfileManager Class. The ImGearColorProfileManager Class and its methods allow enabling and disabling the automatic use of global color profiles for color space conversion and display operations. You can enable or disable global profiles using the enableProfiles method, and specify global color profiles via the setCmykProfile method and setRgbProfile method. Once you have done this, these profiles will be used for the color space conversion. If a profile is associated with a particular image via the ImGearRasterPage.setColorProfile method, that profile will be used instead of a global profile as the source profile in a color space conversion. For example, the following code sets the global profiles and converts an image from CMYK to RGB:

Example
Copy Code
ImGearColorProfileManager.setEnableProfiles(true);
IGStream igStream = null;

try {
    igStream = new ImGearFileStream("ig_cmyk_profile.icm", "r");
    ImGearColorProfile cmyk = new ImGearColorProfile(igStream);
    ImGearColorProfileManager.setCmykProfile(cmyk);
} finally {
    if (igStream != null) {
        igStream.close();
        igStream = null;
    }
}

try {
    igStream = new ImGearFileStream("ig_rgb_profile.icm", "r");
    ImGearColorProfile rgb = new ImGearColorProfile(igStream);
    ImGearColorProfileManager.setRgbProfile(rgb);
} finally {
    if (igStream != null) {
        igStream.close();
        igStream = null;
    }
}

ImGearRasterProcessing.ConvertColorSpace((ImGearRasterPage) igPage,
        new ImGearColorSpace(ImGearColorSpaceIDs.RGB));

To use explicit specification of color profiles, call the method ImGearRasterProcessing.ConvertColorSpace Method or overload it. The conversion operation will use the color profiles specified by the parameters, ignoring any settings of the ImGearColorProfileManager Class object. For example, the following code converts an image from CMYK to RGB by explicitly specifying color profiles:

Example
Copy Code
ImGearColorProfileManager.setEnableProfiles(true);
IGStream igStream = null;

ImGearColorProfile igColorProfileSource, igColorProfileDest;

try {
    igStream = new ImGearFileStream("ig_cmyk_profile.icm", "r");
    igColorProfileSource = new ImGearColorProfile(igStream);
} finally {
    if (igStream != null) {
        igStream.close();
        igStream = null;
    }
}

try {
    igStream = new ImGearFileStream("ig_rgb_profile.icm", "r");
    igColorProfileDest = new ImGearColorProfile(igStream);
} finally {
    if (igStream != null) {
        igStream.close();
        igStream = null;
    }
}

ImGearRasterProcessing.ConvertColorSpace((ImGearRasterPage) igPage,
        new ImGearColorSpace(ImGearColorSpaceIDs.RGB),
        igColorProfileSource, igColorProfileDest, ImGearRenderingIntents.PERCEPTUAL);

 

 


©2016. Accusoft Corporation. All Rights Reserved.

Send Feedback