int numPixels = tmpData.length;
// First transform...
if (sequence[0] instanceof ICC_Transform) { // ICC
ICC_Transform t = (ICC_Transform)sequence[0];
cc.translateColor(t, tmpData, srcCS, xyzCS, numPixels);
} else { // non ICC
for (int k=0; k<numPixels; k++) {
tmpData[k] = srcCS.toCIEXYZ(tmpData[k]);
}
cc.loadScalingData(xyzCS); // prepare for scaling XYZ
}
for (Object element : sequence) {
if (element instanceof ICC_Transform) {
ICC_Transform t = (ICC_Transform)element;
cc.translateColor(t, tmpData, null, null, numPixels);
} else {
ColorSpace cs = (ColorSpace) element;
for (int k=0; k<numPixels; k++) {
tmpData[k] = cs.fromCIEXYZ(tmpData[k]);
tmpData[k] = cs.toCIEXYZ(tmpData[k]);
}
}
}
// Last transform...
if (sequence[sequence.length-1] instanceof ICC_Transform) { // ICC
ICC_Transform t = (ICC_Transform)sequence[sequence.length-1];
cc.translateColor(t, tmpData, xyzCS, dstCS, numPixels);
} else { // non ICC
for (int k=0; k<numPixels; k++) {
tmpData[k] = dstCS.fromCIEXYZ(tmpData[k]);
}