EVALUATION
This problem happens because inaccuracy inside the littleCMS library. The same inaccuracy happens with both jdk and openJDK color profiles. Here is minimized java and native testcases showing the problem with GRAY -> sRGB transform.
--------------GrayTest.java------------------
import java.awt.color.ColorSpace;
public class GrayTest {
final static int [] cols = {1, 2, 3, 4, 5, 6, 7};
public static void main(String [] args) {
ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
float [] p = new float[1];
for (int i = 0; i < cols.length; i++) {
p[0] = cols[i]/255.0f;
float [] r = cs.toRGB(p);
for (int j = 0; j < r.length; j++) {
System.out.print((int)(r[j]*255) + ",");
}
System.out.println();
}
}
}
-------------------gray.cpp---------------------
#include <stdio.h>
#include "lcms.h"
char pixels[] = {1, 2, 3, 4, 5, 6, 7};
int main(int argc, char* argv[]) {
char* in = pixels;
char out[3];
cmsHPROFILE profiles[2];
profiles[0] = cmsOpenProfileFromFile("KCMS\\GRAY.pf", "r");
profiles[1] = cmsOpenProfileFromFile("KCMS\\sRGB.pf", "r");
cmsHTRANSFORM trans = cmsCreateMultiprofileTransform(
profiles,2,BYTES_SH(1) | CHANNELS_SH(1), BYTES_SH(1) | CHANNELS_SH(3),
0/* perceptual*/,0);
for (int i = 0; i < sizeof(pixels)/sizeof(char); i++) {
cmsDoTransform(trans, in++, out, 1);
printf("%d,%d,%d\n", out[0], out[1], out[2]);
}
}
output from JDK6,7 with GrayTest:
12,12,12,
21,21,21,
28,28,28,
33,33,33,
38,38,38,
42,42,42,
46,46,46,
output from openJDK with GrayTest and native testcase:
6,6,6,
12,12,12,
18,18,18,
24,24,24,
31,31,31,
37,37,37,
43,43,43,
|