On Saturday 23 May 2009 02:55:29 am Albert Astals Cid wrote: > > According to the PDF spec. the Y white point value should always be 1.0. > > So it might be possible to just do the correction to X and Z since this > > would make the code slightly more efficient. Also I now think it would > > be better to do this in GfxCalGrayColorSpace::getXYZ() and > > GfxLabColorSpace::setXYZ() instead of in the locations right after calls > > to these functions. > > When i mean no difference i mean "diff" says the files are exactly the > same, not that i'm not able to see a difference in them. > > May it be because i'm not using any color profile? > > Albert
It could be but the current code base defaults to sRGB as the output profile if one is not specified by the calling app. So if poppler was built using USE_CMS then by default it should be using sRGB as the output color space for CIELab, Cal* and ICC objects. To confirm that you are using a profile you might consider modifying your code so that it explicitly sets the output profile by calling setOutputProfileName() or setOutputProfile() before opening the document. For additional testing I am attaching a profile intended for testing that causes the colors to be transformed in a way that is unmistakable because it transforms blues into reds and reds into blues. Using this profile it should be easy to confirm that your code is actually using an output profile and also which parts of the rendered output are using the output profile. No matter what output profile is being used there should be at least some difference in the resulting RGB values of CIELab and CalGray objects if the white point of the object is NOT X = Y = Z = 1.0. I have placed printf() statements in the code to confirm that this is altering the XYZ values of the CIELab objects in the altona pdf and it is. I have also confirmed through testing that this makes a visible difference in the rendered output at least if the white point is significantly different from X = Y =Z = 1.0. Also I cleaned up the white point code so that the white point correction is now taking place in the getXYZ() functions which is where is really belongs. I have attached a patch with this set of changes. Hal
BGR.icc
Description: application/icc
diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc
index 1ca3289..5931fe8 100644
--- a/poppler/GfxState.cc
+++ b/poppler/GfxState.cc
@@ -597,15 +597,14 @@ GfxColorSpace *GfxCalGrayColorSpace::parse(Array *arr) {
}
// convert CalGray to media XYZ color space
-// (not multiply by the white point)
void GfxCalGrayColorSpace::getXYZ(GfxColor *color,
double *pX, double *pY, double *pZ) {
double A;
A = colToDbl(color->c[0]);
- *pX = pow(A,gamma);
+ *pX = pow(A,gamma) * whiteX;
*pY = pow(A,gamma);
- *pZ = pow(A,gamma);
+ *pZ = pow(A,gamma) * whiteY;
}
void GfxCalGrayColorSpace::getGray(GfxColor *color, GfxGray *gray) {
@@ -652,9 +651,6 @@ void GfxCalGrayColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
return;
}
#endif
- X *= whiteX;
- Y *= whiteY;
- Z *= whiteZ;
// convert XYZ to RGB, including gamut mapping and gamma correction
r = xyzrgb[0][0] * X + xyzrgb[0][1] * Y + xyzrgb[0][2] * Z;
g = xyzrgb[1][0] * X + xyzrgb[1][1] * Y + xyzrgb[1][2] * Z;
@@ -938,9 +934,9 @@ void GfxCalRGBColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
Guchar out[gfxColorMaxComps];
double in[gfxColorMaxComps];
- in[0] = clip01(X/whiteX);
- in[1] = clip01(Y/whiteY);
- in[2] = clip01(Z/whiteZ);
+ in[0] = clip01(X);
+ in[1] = clip01(Y);
+ in[2] = clip01(Z);
XYZ2DisplayTransform->doTransform(in,out,1);
rgb->r = byteToCol(out[0]);
rgb->g = byteToCol(out[1]);
@@ -1222,7 +1218,6 @@ void GfxLabColorSpace::getGray(GfxColor *color, GfxGray *gray) {
}
// convert L*a*b* to media XYZ color space
-// (not multiply by the white point)
void GfxLabColorSpace::getXYZ(GfxColor *color,
double *pX, double *pY, double *pZ) {
double X, Y, Z;
@@ -1246,9 +1241,9 @@ void GfxLabColorSpace::getXYZ(GfxColor *color,
} else {
Z = (108.0 / 841.0) * (t2 - (4.0 / 29.0));
}
- *pX = X;
+ *pX = X * whiteX;
*pY = Y;
- *pZ = Z;
+ *pZ = Z * whiteZ;
}
void GfxLabColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
@@ -1260,6 +1255,7 @@ void GfxLabColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
if (XYZ2DisplayTransform != NULL && displayPixelType == PT_RGB) {
Guchar out[gfxColorMaxComps];
double in[gfxColorMaxComps];
+ printf("convert lab to RGB use a profile");
in[0] = clip01(X);
in[1] = clip01(Y);
@@ -1271,9 +1267,6 @@ void GfxLabColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
return;
}
#endif
- X *= whiteX;
- Y *= whiteY;
- Z *= whiteZ;
// convert XYZ to RGB, including gamut mapping and gamma correction
r = xyzrgb[0][0] * X + xyzrgb[0][1] * Y + xyzrgb[0][2] * Z;
g = xyzrgb[1][0] * X + xyzrgb[1][1] * Y + xyzrgb[1][2] * Z;
_______________________________________________ poppler mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/poppler
