On Monday 11 May 2009 03:47:00 pm Albert Astals Cid wrote:
> A Dimarts, 12 de maig de 2009, Hal V. Engel va escriure:
> > On Monday 11 May 2009 12:10:30 pm Albert Astals Cid wrote:
> > > Hi, let's discuss the Poppler 0.12 release schedule:
> > >
> > > * May 11 (Today) Poppler 0.11.0 (0.12 Alpha 1)
> > > * May 25 (+2 weeks) Poppler 0.11.1 (0.12 Beta 1)
> > > * June 8 (+2 weeks) Poppler 0.11.2 (0.12 Beta 2)
> > > * June 22 (+2 weeks) Poppler 0.11.3 (0.12 RC)
> > > * July 6 (+2 weeks) Poppler 0.12.0
> > >
> > > We could accept new features until Beta 2. Afterwards it's just
> > > bugfixing.
> > >
> > > What i'd like to see in:
> > > * Fix for bug 19670, i'm halfway in regression testing, needs someone
> > > with Cairo knowledge to do the Cairo part though
> > > * Better Color Management support (Hal you were working on this, how's
> > > it going)
> >
> > I have Qt4 support working and have the Qt4 demo more or less working
> > including being able to get and use the X11 _ICC_PROFILE atom (similar
> > code will need to be written for Mac and Windows). I do have an issue
> > with not being able to get the CM support to setup a new transform if I
> > move between displays. I am preparing patches for the changes against
> > current git. I will email these to this list soon.
>
> Cool :-)
>
> Albert
>
> > > And of course there are lots of bugs i'd like to see fixed but we lack
> > > manpower so i'll keep going at my slow pace (help is always welcome)
> > >
> > > Comments?
> > >
> > > Albert
Here it is. This patch applies and builds on git head as of this afternoon.
Comments:
1. I am not a cmake expert so I had to hack on qt4/src/CMakeLists.txt so that
USE_CMS was defined for the qt4 stuff. Someone with more cmake expertise
almost for sure needs to fix my hack.
2. I did some renaming in the existing CM code in GfxState to make it clearer.
This is along the lines of the earlier patch I sent to the list but I think
this patch is cleaner.
3. For some reason I can not change the GfxTransform after it has been created
the first time. This fails silently when it happens. This needs to be fixed
but I have not been able to locate why/where this is happening.
4. Someone with Windows and/or Mac expertise needs to write versions of
qt4/demos/viewer.cpp cmsHPROFILE PdfViewer::getProfileAtom () for those other
OS's for this to work on Windows and on the Mac. It might also be useful to
move these functions to a support library so that they are available to anyone
who uses the library.
5. I am not a gkt programmer so I made no attempt to update any of the gtk
stuff to support CM. But the Qt4 code should provide enough clues for a gtk
programmer to do the same basic stuff as I did with the Qt4 support library
and the demo viewer.
6. There are probably additional CM related things that could be done with the
demo viewer. These include:
a. Allowing the user to specify an output profile for the display to either
over ride the system setting or to use if they have not set this up in the
system.
b. Allowing the user to print using a user defined printer (or other device)
profile.
c. Allow the user to query the output profile or perhaps including information
about it in the meta data view.
Hal
*** poppler/GfxState.h Mon May 11 15:09:07 2009
--- poppler/GfxState.h Mon May 11 15:52:28 2009
***************
*** 172,177 ****
--- 172,178 ----
}
~GfxColorTransform() {
cmsDeleteTransform(transform);
+ refCount = 0;
}
void ref() {
refCount++;
***************
*** 224,255 ****
// Return the name of the <idx>th color space mode.
static char *getColorSpaceModeName(int idx);
!
! private:
#ifdef USE_CMS
protected:
static cmsHPROFILE RGBProfile;
! static GooString *displayProfileName; // display profile file Name
! static cmsHPROFILE displayProfile; // display profile
! static unsigned int displayPixelType;
! static GfxColorTransform *XYZ2DisplayTransform;
// convert color space signature to cmsColor type
static unsigned int getCMSColorSpaceType(icColorSpaceSignature cs);
static unsigned int getCMSNChannels(icColorSpaceSignature cs);
static cmsHPROFILE loadColorProfile(const char *fileName);
public:
static int setupColorProfiles();
! static void setDisplayProfile(cmsHPROFILE displayProfileA) {
! displayProfile = displayProfileA;
}
! static void setDisplayProfileName(GooString *name) {
! displayProfileName = name->copy();
}
static cmsHPROFILE getRGBProfile() {
return RGBProfile;
}
! static cmsHPROFILE getDisplayProfile() {
! return displayProfile;
}
#endif
};
--- 225,257 ----
// Return the name of the <idx>th color space mode.
static char *getColorSpaceModeName(int idx);
!
#ifdef USE_CMS
protected:
static cmsHPROFILE RGBProfile;
! static GooString *outputProfileName; // output device profile file Name
! static cmsHPROFILE outputProfile; // output device profile
! static unsigned int outputPixelType;
! static GfxColorTransform *XYZ2OutputTransform;
// convert color space signature to cmsColor type
static unsigned int getCMSColorSpaceType(icColorSpaceSignature cs);
static unsigned int getCMSNChannels(icColorSpaceSignature cs);
static cmsHPROFILE loadColorProfile(const char *fileName);
public:
static int setupColorProfiles();
! static void setOutputProfile(cmsHPROFILE outputProfileA) {
! if (outputProfile)
! cmsCloseProfile(outputProfile);
! outputProfile = outputProfileA;
}
! static void setOutputProfileName(GooString *name) {
! outputProfileName = name->copy();
}
static cmsHPROFILE getRGBProfile() {
return RGBProfile;
}
! static cmsHPROFILE getOutputProfile() {
! return outputProfile;
}
#endif
};
*** poppler/GfxState.cc Mon May 11 15:09:07 2009
--- poppler/GfxState.cc Mon May 11 16:24:30 2009
***************
*** 228,237 ****
#ifdef USE_CMS
cmsHPROFILE GfxColorSpace::RGBProfile = NULL;
! cmsHPROFILE GfxColorSpace::displayProfile = NULL;
! GooString *GfxColorSpace::displayProfileName = NULL;
! unsigned int GfxColorSpace::displayPixelType = 0;
! GfxColorTransform *GfxColorSpace::XYZ2DisplayTransform = NULL;
cmsHPROFILE GfxColorSpace::loadColorProfile(const char *fileName)
{
--- 228,237 ----
#ifdef USE_CMS
cmsHPROFILE GfxColorSpace::RGBProfile = NULL;
! cmsHPROFILE GfxColorSpace::outputProfile = NULL;
! GooString *GfxColorSpace::outputProfileName = NULL;
! unsigned int GfxColorSpace::outputPixelType = 0;
! GfxColorTransform *GfxColorSpace::XYZ2OutputTransform = NULL;
cmsHPROFILE GfxColorSpace::loadColorProfile(const char *fileName)
{
***************
*** 279,323 ****
int GfxColorSpace::setupColorProfiles()
{
! static GBool initialized = gFalse;
! cmsHTRANSFORM transform;
unsigned int nChannels;
// do only once
! if (initialized) return 0;
! initialized = gTrue;
// set error handlor
cmsSetErrorHandler(CMSError);
! if (displayProfile == NULL) {
// load display profile if it was not already loaded.
! if (displayProfileName == NULL) {
! displayProfile = loadColorProfile("display.icc");
! } else if (displayProfileName->getLength() > 0) {
! displayProfile = loadColorProfile(displayProfileName->getCString());
}
}
! // load RGB profile
! RGBProfile = loadColorProfile("RGB.icc");
if (RGBProfile == NULL) {
/* use built in sRGB profile */
RGBProfile = cmsCreate_sRGBProfile();
}
// create transforms
! if (displayProfile != NULL) {
! displayPixelType = getCMSColorSpaceType(cmsGetColorSpace(displayProfile));
! nChannels = getCMSNChannels(cmsGetColorSpace(displayProfile));
// create transform from XYZ
cmsHPROFILE XYZProfile = cmsCreateXYZProfile();
if ((transform = cmsCreateTransform(XYZProfile, TYPE_XYZ_DBL,
! displayProfile,
! COLORSPACE_SH(displayPixelType) |
CHANNELS_SH(nChannels) | BYTES_SH(1),
INTENT_RELATIVE_COLORIMETRIC,0)) == 0) {
! error(-1, "Can't create Lab transform");
} else {
! XYZ2DisplayTransform = new GfxColorTransform(transform);
}
cmsCloseProfile(XYZProfile);
}
--- 279,333 ----
int GfxColorSpace::setupColorProfiles()
{
! // static GBool initialized = gFalse;
! cmsHTRANSFORM transform = NULL;
unsigned int nChannels;
// do only once
! // No this should be done when ever the calling applications
! // wants to use a different transform
! // FIXME for some reason only the first time works.
! // if (initialized) return 0;
! // initialized = gTrue;
// set error handlor
cmsSetErrorHandler(CMSError);
! if (outputProfile == NULL) {
// load display profile if it was not already loaded.
! if (outputProfileName == NULL) {
! // FIXME this does not make sense as this will
! // not be valid for most users
! outputProfile = loadColorProfile("display.icc");
! } else if (outputProfileName->getLength() > 0) {
! outputProfile = loadColorProfile(outputProfileName->getCString());
}
}
! // load fall back default RGB profile if not set.
! // This will work for users who have not setup
! // their display ICC profiles correctly
if (RGBProfile == NULL) {
/* use built in sRGB profile */
RGBProfile = cmsCreate_sRGBProfile();
}
+
// create transforms
! if (outputProfile != NULL) {
! outputPixelType = getCMSColorSpaceType(cmsGetColorSpace(outputProfile));
! nChannels = getCMSNChannels(cmsGetColorSpace(outputProfile));
!
// create transform from XYZ
cmsHPROFILE XYZProfile = cmsCreateXYZProfile();
+
if ((transform = cmsCreateTransform(XYZProfile, TYPE_XYZ_DBL,
! outputProfile,
! COLORSPACE_SH(outputPixelType) |
CHANNELS_SH(nChannels) | BYTES_SH(1),
INTENT_RELATIVE_COLORIMETRIC,0)) == 0) {
! error(-1, "Can't create output transform\n");
} else {
! delete XYZ2OutputTransform;
! XYZ2OutputTransform = new GfxColorTransform(transform);
}
cmsCloseProfile(XYZProfile);
}
***************
*** 612,618 ****
GfxRGB rgb;
#ifdef USE_CMS
! if (XYZ2DisplayTransform != NULL && displayPixelType == PT_GRAY) {
Guchar out[gfxColorMaxComps];
double in[gfxColorMaxComps];
double X, Y, Z;
--- 622,628 ----
GfxRGB rgb;
#ifdef USE_CMS
! if (XYZ2OutputTransform != NULL && outputPixelType == PT_GRAY) {
Guchar out[gfxColorMaxComps];
double in[gfxColorMaxComps];
double X, Y, Z;
***************
*** 621,627 ****
in[0] = clip01(X);
in[1] = clip01(Y);
in[2] = clip01(Z);
! XYZ2DisplayTransform->doTransform(in,out,1);
*gray = byteToCol(out[0]);
return;
}
--- 631,637 ----
in[0] = clip01(X);
in[1] = clip01(Y);
in[2] = clip01(Z);
! XYZ2OutputTransform->doTransform(in,out,1);
*gray = byteToCol(out[0]);
return;
}
***************
*** 638,651 ****
getXYZ(color,&X,&Y,&Z);
#ifdef USE_CMS
! if (XYZ2DisplayTransform != NULL && displayPixelType == PT_RGB) {
Guchar out[gfxColorMaxComps];
double in[gfxColorMaxComps];
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]);
rgb->b = byteToCol(out[2]);
--- 648,661 ----
getXYZ(color,&X,&Y,&Z);
#ifdef USE_CMS
! if (XYZ2OutputTransform != NULL && outputPixelType == PT_RGB) {
Guchar out[gfxColorMaxComps];
double in[gfxColorMaxComps];
in[0] = clip01(X);
in[1] = clip01(Y);
in[2] = clip01(Z);
! XYZ2OutputTransform->doTransform(in,out,1);
rgb->r = byteToCol(out[0]);
rgb->g = byteToCol(out[1]);
rgb->b = byteToCol(out[2]);
***************
*** 670,676 ****
GfxColorComp c, m, y, k;
#ifdef USE_CMS
! if (XYZ2DisplayTransform != NULL && displayPixelType == PT_CMYK) {
double in[gfxColorMaxComps];
Guchar out[gfxColorMaxComps];
double X, Y, Z;
--- 680,686 ----
GfxColorComp c, m, y, k;
#ifdef USE_CMS
! if (XYZ2OutputTransform != NULL && outputPixelType == PT_CMYK) {
double in[gfxColorMaxComps];
Guchar out[gfxColorMaxComps];
double X, Y, Z;
***************
*** 680,686 ****
in[1] = clip01(Y);
in[2] = clip01(Z);
! XYZ2DisplayTransform->doTransform(in,out,1);
cmyk->c = byteToCol(out[0]);
cmyk->m = byteToCol(out[1]);
cmyk->y = byteToCol(out[2]);
--- 690,696 ----
in[1] = clip01(Y);
in[2] = clip01(Z);
! XYZ2OutputTransform->doTransform(in,out,1);
cmyk->c = byteToCol(out[0]);
cmyk->m = byteToCol(out[1]);
cmyk->y = byteToCol(out[2]);
***************
*** 908,914 ****
GfxRGB rgb;
#ifdef USE_CMS
! if (XYZ2DisplayTransform != NULL && displayPixelType == PT_GRAY) {
Guchar out[gfxColorMaxComps];
double in[gfxColorMaxComps];
double X, Y, Z;
--- 918,924 ----
GfxRGB rgb;
#ifdef USE_CMS
! if (XYZ2OutputTransform != NULL && outputPixelType == PT_GRAY) {
Guchar out[gfxColorMaxComps];
double in[gfxColorMaxComps];
double X, Y, Z;
***************
*** 917,923 ****
in[0] = clip01(X);
in[1] = clip01(Y);
in[2] = clip01(Z);
! XYZ2DisplayTransform->doTransform(in,out,1);
*gray = byteToCol(out[0]);
return;
}
--- 927,933 ----
in[0] = clip01(X);
in[1] = clip01(Y);
in[2] = clip01(Z);
! XYZ2OutputTransform->doTransform(in,out,1);
*gray = byteToCol(out[0]);
return;
}
***************
*** 934,947 ****
getXYZ(color,&X,&Y,&Z);
#ifdef USE_CMS
! if (XYZ2DisplayTransform != NULL && displayPixelType == PT_RGB) {
Guchar out[gfxColorMaxComps];
double in[gfxColorMaxComps];
in[0] = clip01(X/whiteX);
in[1] = clip01(Y/whiteY);
in[2] = clip01(Z/whiteZ);
! XYZ2DisplayTransform->doTransform(in,out,1);
rgb->r = byteToCol(out[0]);
rgb->g = byteToCol(out[1]);
rgb->b = byteToCol(out[2]);
--- 944,957 ----
getXYZ(color,&X,&Y,&Z);
#ifdef USE_CMS
! if (XYZ2OutputTransform != NULL && outputPixelType == PT_RGB) {
Guchar out[gfxColorMaxComps];
double in[gfxColorMaxComps];
in[0] = clip01(X/whiteX);
in[1] = clip01(Y/whiteY);
in[2] = clip01(Z/whiteZ);
! XYZ2OutputTransform->doTransform(in,out,1);
rgb->r = byteToCol(out[0]);
rgb->g = byteToCol(out[1]);
rgb->b = byteToCol(out[2]);
***************
*** 962,968 ****
GfxColorComp c, m, y, k;
#ifdef USE_CMS
! if (XYZ2DisplayTransform != NULL && displayPixelType == PT_CMYK) {
double in[gfxColorMaxComps];
Guchar out[gfxColorMaxComps];
double X, Y, Z;
--- 972,978 ----
GfxColorComp c, m, y, k;
#ifdef USE_CMS
! if (XYZ2OutputTransform != NULL && outputPixelType == PT_CMYK) {
double in[gfxColorMaxComps];
Guchar out[gfxColorMaxComps];
double X, Y, Z;
***************
*** 971,977 ****
in[0] = clip01(X);
in[1] = clip01(Y);
in[2] = clip01(Z);
! XYZ2DisplayTransform->doTransform(in,out,1);
cmyk->c = byteToCol(out[0]);
cmyk->m = byteToCol(out[1]);
cmyk->y = byteToCol(out[2]);
--- 981,987 ----
in[0] = clip01(X);
in[1] = clip01(Y);
in[2] = clip01(Z);
! XYZ2OutputTransform->doTransform(in,out,1);
cmyk->c = byteToCol(out[0]);
cmyk->m = byteToCol(out[1]);
cmyk->y = byteToCol(out[2]);
***************
*** 1205,1216 ****
GfxRGB rgb;
#ifdef USE_CMS
! if (XYZ2DisplayTransform != NULL && displayPixelType == PT_GRAY) {
Guchar out[gfxColorMaxComps];
double in[gfxColorMaxComps];
getXYZ(color, &in[0], &in[1], &in[2]);
! XYZ2DisplayTransform->doTransform(in,out,1);
*gray = byteToCol(out[0]);
return;
}
--- 1215,1226 ----
GfxRGB rgb;
#ifdef USE_CMS
! if (XYZ2OutputTransform != NULL && outputPixelType == PT_GRAY) {
Guchar out[gfxColorMaxComps];
double in[gfxColorMaxComps];
getXYZ(color, &in[0], &in[1], &in[2]);
! XYZ2OutputTransform->doTransform(in,out,1);
*gray = byteToCol(out[0]);
return;
}
***************
*** 1257,1270 ****
getXYZ(color, &X, &Y, &Z);
#ifdef USE_CMS
! if (XYZ2DisplayTransform != NULL && displayPixelType == PT_RGB) {
Guchar out[gfxColorMaxComps];
double in[gfxColorMaxComps];
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]);
rgb->b = byteToCol(out[2]);
--- 1267,1280 ----
getXYZ(color, &X, &Y, &Z);
#ifdef USE_CMS
! if (XYZ2OutputTransform != NULL && outputPixelType == PT_RGB) {
Guchar out[gfxColorMaxComps];
double in[gfxColorMaxComps];
in[0] = clip01(X);
in[1] = clip01(Y);
in[2] = clip01(Z);
! XYZ2OutputTransform->doTransform(in,out,1);
rgb->r = byteToCol(out[0]);
rgb->g = byteToCol(out[1]);
rgb->b = byteToCol(out[2]);
***************
*** 1288,1299 ****
GfxColorComp c, m, y, k;
#ifdef USE_CMS
! if (XYZ2DisplayTransform != NULL && displayPixelType == PT_CMYK) {
double in[gfxColorMaxComps];
Guchar out[gfxColorMaxComps];
getXYZ(color, &in[0], &in[1], &in[2]);
! XYZ2DisplayTransform->doTransform(in,out,1);
cmyk->c = byteToCol(out[0]);
cmyk->m = byteToCol(out[1]);
cmyk->y = byteToCol(out[2]);
--- 1298,1309 ----
GfxColorComp c, m, y, k;
#ifdef USE_CMS
! if (XYZ2OutputTransform != NULL && outputPixelType == PT_CMYK) {
double in[gfxColorMaxComps];
Guchar out[gfxColorMaxComps];
getXYZ(color, &in[0], &in[1], &in[2]);
! XYZ2OutputTransform->doTransform(in,out,1);
cmyk->c = byteToCol(out[0]);
cmyk->m = byteToCol(out[1]);
cmyk->y = byteToCol(out[2]);
***************
*** 1495,1501 ****
if (hp == 0) {
error(-1, "read ICCBased color space profile error");
} else {
! cmsHPROFILE dhp = displayProfile;
if (dhp == NULL) dhp = RGBProfile;
unsigned int cst = getCMSColorSpaceType(cmsGetColorSpace(hp));
unsigned int dNChannels = getCMSNChannels(cmsGetColorSpace(dhp));
--- 1505,1511 ----
if (hp == 0) {
error(-1, "read ICCBased color space profile error");
} else {
! cmsHPROFILE dhp = outputProfile;
if (dhp == NULL) dhp = RGBProfile;
unsigned int cst = getCMSColorSpaceType(cmsGetColorSpace(hp));
unsigned int dNChannels = getCMSNChannels(cmsGetColorSpace(dhp));
***************
*** 1532,1538 ****
void GfxICCBasedColorSpace::getGray(GfxColor *color, GfxGray *gray) {
#ifdef USE_CMS
! if (transform != 0 && displayPixelType == PT_GRAY) {
Guchar in[gfxColorMaxComps];
Guchar out[gfxColorMaxComps];
--- 1542,1548 ----
void GfxICCBasedColorSpace::getGray(GfxColor *color, GfxGray *gray) {
#ifdef USE_CMS
! if (transform != 0 && outputPixelType == PT_GRAY) {
Guchar in[gfxColorMaxComps];
Guchar out[gfxColorMaxComps];
***************
*** 1556,1562 ****
void GfxICCBasedColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
#ifdef USE_CMS
if (transform != 0
! && (displayProfile == NULL || displayPixelType == PT_RGB)) {
Guchar in[gfxColorMaxComps];
Guchar out[gfxColorMaxComps];
--- 1566,1572 ----
void GfxICCBasedColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
#ifdef USE_CMS
if (transform != 0
! && (outputProfile == NULL || outputPixelType == PT_RGB)) {
Guchar in[gfxColorMaxComps];
Guchar out[gfxColorMaxComps];
***************
*** 1596,1602 ****
void GfxICCBasedColorSpace::getCMYK(GfxColor *color, GfxCMYK *cmyk) {
#ifdef USE_CMS
! if (transform != NULL && displayPixelType == PT_CMYK) {
Guchar in[gfxColorMaxComps];
Guchar out[gfxColorMaxComps];
--- 1606,1612 ----
void GfxICCBasedColorSpace::getCMYK(GfxColor *color, GfxCMYK *cmyk) {
#ifdef USE_CMS
! if (transform != NULL && outputPixelType == PT_CMYK) {
Guchar in[gfxColorMaxComps];
Guchar out[gfxColorMaxComps];
*** qt4/src/poppler-qt4.h Mon May 11 15:09:07 2009
--- qt4/src/poppler-qt4.h Mon May 11 18:18:06 2009
***************
*** 23,28 ****
--- 23,30 ----
#ifndef __POPPLER_QT_H__
#define __POPPLER_QT_H__
+ #include <config.h>
+
#include "poppler-annotation.h"
#include "poppler-link.h"
#include "poppler-optcontent.h"
***************
*** 34,39 ****
--- 36,45 ----
#include <QtXml/QDomDocument>
#include "poppler-export.h"
+ #ifdef USE_CMS
+ #include <lcms.h>
+ #endif
+
class EmbFile;
class Sound;
class AnnotMovie;
***************
*** 552,558 ****
\since 0.6
**/
QString label() const;
!
private:
Q_DISABLE_COPY(Page)
--- 558,564 ----
\since 0.6
**/
QString label() const;
!
private:
Q_DISABLE_COPY(Page)
***************
*** 649,656 ****
--- 655,683 ----
Antialiasing = 0x00000001, ///< Antialiasing for graphics
TextAntialiasing = 0x00000002 ///< Antialiasing for text
};
+
Q_DECLARE_FLAGS( RenderHints, RenderHint )
+ /**
+
+ Color Management support functions.
+ These are wrapper functions for GfxState functions.
+
+ These are used to set and query the output device profile.
+ First call either setDocumentProfile() or setDocumentProfileName()
+ then call setupDocumentColorProfiles() to configure the output
+ colorspace.
+
+ */
+
+ #ifdef USE_CMS
+ int setupDocumentColorProfiles();
+ void setDocumentProfile(cmsHPROFILE outputProfileA);
+ void setDocumentProfileName(QString name);
+ cmsHPROFILE getDocumentRGBProfile();
+ cmsHPROFILE getDocumentProfile();
+ #endif
+
/**
Load the document from a file on disk
***************
*** 1097,1107 ****
*/
QStringList scripts() const;
! /**
Destructor.
*/
~Document();
!
private:
Q_DISABLE_COPY(Document)
--- 1124,1134 ----
*/
QStringList scripts() const;
! /**
Destructor.
*/
~Document();
!
private:
Q_DISABLE_COPY(Document)
*** qt4/src/poppler-document.cc Mon May 11 15:09:07 2009
--- qt4/src/poppler-document.cc Mon May 11 16:13:24 2009
***************
*** 19,27 ****
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "poppler-qt4.h"
- #include <config.h>
#include <ErrorCodes.h>
#include <GlobalParams.h>
#include <Outline.h>
--- 19,28 ----
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
+ #include <config.h>
+ #include <GfxState.h>
#include "poppler-qt4.h"
#include <ErrorCodes.h>
#include <GlobalParams.h>
#include <Outline.h>
***************
*** 427,432 ****
--- 428,462 ----
m_doc->setPaperColor(color);
}
+ #ifdef USE_CMS
+ int Document::setupDocumentColorProfiles()
+ {
+ return GfxColorSpace::setupColorProfiles();
+ };
+
+
+ void Document::setDocumentProfile(cmsHPROFILE outputProfileA)
+ {
+ GfxColorSpace::setOutputProfile(outputProfileA);
+ }
+
+ void Document::setDocumentProfileName(QString name)
+ {
+ GooString * profileName = QStringToGooString( name );
+ GfxColorSpace::setOutputProfileName(profileName);
+ }
+
+ cmsHPROFILE Document::getDocumentRGBProfile()
+ {
+ return GfxColorSpace::getRGBProfile();
+ }
+
+ cmsHPROFILE Document::getDocumentProfile()
+ {
+ return GfxColorSpace::getOutputProfile() ;
+ }
+ #endif
+
QColor Document::paperColor() const
{
return m_doc->paperColor;
*** qt4/demos/viewer.h Mon May 11 15:09:07 2009
--- qt4/demos/viewer.h Mon May 11 13:01:52 2009
***************
*** 20,25 ****
--- 20,32 ----
#define PDFVIEWER_H
#include <QtGui/QMainWindow>
+ #include <QtGui/QDesktopWidget>
+
+ #include "config.h"
+
+ #ifdef USE_CMS
+ #include <lcms.h>
+ #endif
class QAction;
class QActionGroup;
***************
*** 54,59 ****
--- 61,69 ----
void slotRenderBackend(QAction *act);
private:
+ #ifdef USE_CMS
+ cmsHPROFILE getProfileAtom();
+ #endif
void setPage(int page);
int page() const;
***************
*** 68,73 ****
--- 78,84 ----
QList<DocumentObserver *> m_observers;
Poppler::Document *m_doc;
+ QDesktopWidget* desktop;
};
#endif
*** qt4/demos/viewer.cpp Mon May 11 15:09:07 2009
--- qt4/demos/viewer.cpp Mon May 11 16:13:24 2009
***************
*** 31,36 ****
--- 31,40 ----
#include <poppler-qt4.h>
+ #ifdef USE_CMS
+ #include <lcms.h>
+ #endif
+
#include <QtCore/QDir>
#include <QtGui/QAction>
#include <QtGui/QApplication>
***************
*** 40,45 ****
--- 44,55 ----
#include <QtGui/QMenuBar>
#include <QtGui/QMessageBox>
+ // Stuff needed to get the X11 _ICC_PROFILE atom
+ #include <QtGui/QX11Info>
+ #include <X11/Xlib.h>
+ #include <limits.h>
+ #include <X11/Xatom.h>
+
PdfViewer::PdfViewer()
: QMainWindow(), m_currentPage(0), m_doc(0)
{
***************
*** 156,161 ****
--- 166,175 ----
void PdfViewer::loadDocument(const QString &file)
{
+ #ifdef USE_CMS
+ cmsHPROFILE profile;
+ #endif
+
Poppler::Document *newdoc = Poppler::Document::load(file);
if (!newdoc) {
QMessageBox msgbox(QMessageBox::Critical, tr("Open Error"), tr("Cannot open:\n") + file,
***************
*** 180,185 ****
--- 194,205 ----
m_doc = newdoc;
+ #ifdef USE_CMS
+ // setup profile using X11 _ICC_PROFILE atom
+ m_doc -> setDocumentProfile(getProfileAtom ());
+ // m_doc -> setupDocumentColorProfiles(); // not needed as this happens automatically
+ #endif
+
m_doc->setRenderHint(Poppler::Document::TextAntialiasing, m_settingsTextAAAct->isChecked());
m_doc->setRenderHint(Poppler::Document::Antialiasing, m_settingsGfxAAAct->isChecked());
m_doc->setRenderBackend((Poppler::Document::RenderBackend)m_settingsRenderBackendGrp->checkedAction()->data().toInt());
***************
*** 209,214 ****
--- 229,276 ----
m_fileSaveCopyAct->setEnabled(false);
}
+ #ifdef USE_CMS
+ cmsHPROFILE PdfViewer::getProfileAtom ()
+ {
+ Atom ICCatom = 0;
+ Atom atomType = 0;
+ int format;
+ QString atomString;
+ unsigned long atomSize = 0;
+ unsigned long bytesAfter = 0;
+ LPVOID profileAtomBuffer;
+ cmsHPROFILE profile = NULL;
+
+ QDesktopWidget* desktop = new QDesktopWidget();
+
+ if (desktop -> numScreens() == 1 || desktop -> screenNumber(this) == 0)
+ atomString = "_ICC_PROFILE";
+ else
+ atomString = QString("_ICC_PROFILE_%1").arg(desktop -> screenNumber(this));
+
+ ICCatom = XInternAtom( QX11Info::display (), atomString.toLatin1(), False );
+
+ if( XGetWindowProperty ( QX11Info::display (),
+ QX11Info::appRootWindow(-1),
+ ICCatom, 0, INT_MAX, False,
+ XA_CARDINAL, &atomType, &format,
+ &atomSize, &bytesAfter,
+ (unsigned char **) &profileAtomBuffer) == Success)
+ {
+ profile = cmsOpenProfileFromMem(profileAtomBuffer, atomSize);
+ XFree (profileAtomBuffer);
+ if (profile)
+ qDebug("Profile creation succeeded. Profile description = %s", cmsTakeProductDesc(profile));
+ else
+ qDebug("Got X11 _ICC_PROFILE atom but profile creation failed, will use sRGB");
+ return profile;
+ }
+
+ qDebug("Failed to get X11 _ICC_PROFILE atom, will use sRGB");
+ return NULL;
+ }
+ #endif
+
void PdfViewer::slotOpenFile()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Open PDF Document"), QDir::homePath(), tr("PDF Documents (*.pdf)"));
*** qt4/src/CMakeLists.txt Mon May 11 15:09:07 2009
--- qt4/src/CMakeLists.txt Mon May 11 14:27:30 2009
***************
*** 1,5 ****
--- 1,9 ----
add_definitions(${QT4_DEFINITIONS})
+ #if(ENABLE_LCMS)
+ set(USE_CMS ON)
+ #endif(ENABLE_LCMS)
+
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${QT4_INCLUDE_DIR}
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler