1 17 18 19 20 package org.apache.fop.util; 21 22 import java.awt.color.ColorSpace ; 23 import java.awt.color.ICC_ColorSpace ; 24 import java.awt.color.ICC_Profile ; 25 import java.io.UnsupportedEncodingException ; 26 27 30 public class ColorProfileUtil { 31 32 37 public static String getICCProfileDescription(ICC_Profile profile) { 38 byte[] data = profile.getData(ICC_Profile.icSigProfileDescriptionTag); 39 if (data == null) { 40 return null; 41 } else { 42 int length = (data[8] << 3 * 8) | (data[9] << 2 * 8) | (data[10] << 8) | data[11]; 44 length--; try { 46 return new String (data, 12, length, "US-ASCII"); 47 } catch (UnsupportedEncodingException e) { 48 throw new UnsupportedOperationException ("Incompatible VM"); 49 } 50 } 51 } 52 53 59 public static boolean isDefaultsRGB(ICC_Profile profile) { 60 ColorSpace sRGB = ColorSpace.getInstance(ColorSpace.CS_sRGB); 61 ICC_Profile sRGBProfile = null; 62 if (sRGB instanceof ICC_ColorSpace ) { 63 sRGBProfile = ((ICC_ColorSpace )sRGB).getProfile(); 64 } 65 return profile == sRGBProfile; 66 } 67 68 } 69 | Popular Tags |