return null;
}
private IccProfileInfo readICCProfileInfo(InputStream is)
{
CachingInputStream cis = new CachingInputStream(is);
is = cis;
if (debug)
Debug.debug();
// setDebug(true);
// if (debug)
// Debug.debug("length: " + length);
try
{
int ProfileSize = read4Bytes("ProfileSize", is,
"Not a Valid ICC Profile");
// if (length != ProfileSize)
// {
// // Debug.debug("Unexpected Length data expected: " + Integer.toHexString((int) length)
// // + ", encoded: " + Integer.toHexString(ProfileSize));
// // Debug.debug("Unexpected Length data: " + length
// // + ", length: " + ProfileSize);
// // throw new Error("asd");
// return null;
// }
int CMMTypeSignature = read4Bytes("Signature", is,
"Not a Valid ICC Profile");
if (debug)
printCharQuad("CMMTypeSignature", CMMTypeSignature);
int ProfileVersion = read4Bytes("ProfileVersion", is,
"Not a Valid ICC Profile");
int ProfileDeviceClassSignature = read4Bytes(
"ProfileDeviceClassSignature", is,
"Not a Valid ICC Profile");
if (debug)
printCharQuad("ProfileDeviceClassSignature",
ProfileDeviceClassSignature);
int ColorSpace = read4Bytes("ColorSpace", is,
"Not a Valid ICC Profile");
if (debug)
printCharQuad("ColorSpace", ColorSpace);
int ProfileConnectionSpace = read4Bytes("ProfileConnectionSpace",
is, "Not a Valid ICC Profile");
if (debug)
printCharQuad("ProfileConnectionSpace", ProfileConnectionSpace);
skipBytes(is, 12, "Not a Valid ICC Profile");
int ProfileFileSignature = read4Bytes("ProfileFileSignature", is,
"Not a Valid ICC Profile");
if (debug)
printCharQuad("ProfileFileSignature", ProfileFileSignature);
int PrimaryPlatformSignature = read4Bytes(
"PrimaryPlatformSignature", is, "Not a Valid ICC Profile");
if (debug)
printCharQuad("PrimaryPlatformSignature",
PrimaryPlatformSignature);
int VariousFlags = read4Bytes("ProfileFileSignature", is,
"Not a Valid ICC Profile");
if (debug)
printCharQuad("ProfileFileSignature", ProfileFileSignature);
int DeviceManufacturer = read4Bytes("ProfileFileSignature", is,
"Not a Valid ICC Profile");
if (debug)
printCharQuad("DeviceManufacturer", DeviceManufacturer);
int DeviceModel = read4Bytes("DeviceModel", is,
"Not a Valid ICC Profile");
if (debug)
printCharQuad("DeviceModel", DeviceModel);
skipBytes(is, 8, "Not a Valid ICC Profile");
int RenderingIntent = read4Bytes("RenderingIntent", is,
"Not a Valid ICC Profile");
if (debug)
printCharQuad("RenderingIntent", RenderingIntent);
skipBytes(is, 12, "Not a Valid ICC Profile");
int ProfileCreatorSignature = read4Bytes("ProfileCreatorSignature",
is, "Not a Valid ICC Profile");
if (debug)
printCharQuad("ProfileCreatorSignature",
ProfileCreatorSignature);
byte ProfileID[] = null;
skipBytes(is, 16, "Not a Valid ICC Profile");
// readByteArray("ProfileID", 16, is,
// "Not a Valid ICC Profile");
// if (debug)
// System.out
// .println("ProfileID: '" + new String(ProfileID) + "'");
skipBytes(is, 28, "Not a Valid ICC Profile");
// this.setDebug(true);
int TagCount = read4Bytes("TagCount", is, "Not a Valid ICC Profile");
// ArrayList tags = new ArrayList();
IccTag tags[] = new IccTag[TagCount];
for (int i = 0; i < TagCount; i++)
{
int TagSignature = read4Bytes("TagSignature[" + i + "]", is,
"Not a Valid ICC Profile");
// Debug.debug("TagSignature t "
// + Integer.toHexString(TagSignature));
// this.printCharQuad("TagSignature", TagSignature);
int OffsetToData = read4Bytes("OffsetToData[" + i + "]", is,
"Not a Valid ICC Profile");
int ElementSize = read4Bytes("ElementSize[" + i + "]", is,
"Not a Valid ICC Profile");
IccTagType fIccTagType = getIccTagType(TagSignature);
// if (fIccTagType == null)
// throw new Error("oops.");
// System.out
// .println("\t["
// + i
// + "]: "
// + ((fIccTagType == null)
// ? "unknown"
// : fIccTagType.name));
// Debug.debug();
IccTag tag = new IccTag(TagSignature, OffsetToData,
ElementSize, fIccTagType);
// tag.dump("\t" + i + ": ");
tags[i] = tag;
// tags .add(tag);
}
{
// read stream to end, filling cache.
while (is.read() >= 0)
;
}
byte data[] = cis.getCache();
if (data.length < ProfileSize)
throw new IOException("Couldn't read ICC Profile.");
IccProfileInfo result = new IccProfileInfo(data, ProfileSize,