Add support for lcms2

pull/1/head
Slávek Banko 10 years ago
parent e76fc32e05
commit b34c4d8c33

@ -10,16 +10,21 @@
################################################# #################################################
# lcms # lcms
check_include_file( lcms.h HAVE_LCMS_H ) check_include_file( lcms2.h HAVE_LCMS2_H )
if( HAVE_LCMS_H ) if( HAVE_LCMS2_H )
set( LCMS_HEADER "lcms2.h" CACHE INTERNAL "" FORCE )
set( LCMS_LIBRARY lcms2 )
else( HAVE_LCMS2_H )
check_include_file( lcms.h HAVE_LCMS_H )
if( HAVE_LCMS_H )
set( LCMS_HEADER "lcms.h" CACHE INTERNAL "" FORCE ) set( LCMS_HEADER "lcms.h" CACHE INTERNAL "" FORCE )
endif( ) set( LCMS_LIBRARY lcms )
endif( HAVE_LCMS_H )
endif( HAVE_LCMS2_H )
if( LCMS_HEADER ) if( LCMS_HEADER )
check_library_exists( lcms VEC3init "" HAVE_LCMS ) check_library_exists( ${LCMS_LIBRARY} cmsOpenProfileFromFile "" HAVE_LCMS )
endif( ) endif( )
if( HAVE_LCMS ) if( NOT HAVE_LCMS )
set( LCMS_LIBRARY lcms )
else( )
tde_message_fatal( "lcms is required, but was not found on your system" ) tde_message_fatal( "lcms is required, but was not found on your system" )
endif( ) endif( )

@ -113,52 +113,56 @@ fi
# Check for lcms # Check for lcms
have_lcms_header='no' have_lcms_header='no'
KDE_CHECK_HEADER(lcms/lcms.h,have_lcms_header='yes',,) KDE_CHECK_HEADER(lcms2.h,have_lcms2_header='yes',,)
if test "$have_lcms_header" = 'yes' if test "$have_lcms2_header" = 'yes'; then
then AC_DEFINE(LCMS_HEADER, <lcms2.h>, [LCMS header])
LCMS_LIBS='-llcms'
AC_DEFINE(LCMS_HEADER, <lcms/lcms.h>, [The correct header])
else else
# Alternative! Debian does it this way...
KDE_CHECK_HEADER(lcms.h,have_lcms_header='yes',,) KDE_CHECK_HEADER(lcms.h,have_lcms_header='yes',,)
if test "$have_lcms_header" = 'yes' if test "$have_lcms_header" = 'yes'; then
then AC_DEFINE(LCMS_HEADER, <lcms.h>, [LCMS header]) else KDE_CHECK_HEADER(lcms/lcms.h,have_lcms_header='yes',,)
LCMS_LIBS='-llcms' if test "$have_lcms_header" = 'yes'; then
AC_DEFINE(LCMS_HEADER, <lcms.h>, [The correct header]) AC_DEFINE(LCMS_HEADER, <lcms/lcms.h>, [LCMS header])
# Try to find the full path of lcms.h
for a in $includedir $prefix/include /usr/include /usr/local/include $kde_extra_includes; do
for b in lcms.h lcms/lcms.h ; do
if test -d "$a" && test -f "$a/$b" ; then
LCMSHDR="$a/$b"
fi fi
done
done
# Check if lcms.h was found. If not then it means that we didn't search
# the right dirs since the kde check already found a usable lcms.h
if test -n "$LCMSHDR" ; then
# Get lcms version
lcms_ver_line=`cat $LCMSHDR | grep '^// Version' `
if test -z "$lcms_ver_line" ; then
# Some versions of lcms have the version in /* */
lcms_ver_line=`cat $LCMSHDR | grep '^/\* Version' `
fi fi
lcms_ver=`echo "$lcms_ver_line" | head -n 1 | cut -d ' ' -f 3 ` fi
# Get major and minor version numbers
lcms_var_maj=`echo $lcms_ver | cut -d . -f 1`
# Some versions have a character attached to the end of minor version
lcms_var_min=`echo $lcms_ver | cut -d . -f 2 | sed 's,[^0-9],,g'`
if test "$lcms_var_maj" -gt 1 || test "$lcms_var_min" -lt 9 ; then LCMS_LIBS=''
LCMS_LIBS='' have_lcms='no'
fi saved_libs=$LIBS
fi saved_cflags="$CFLAGS"
else saved_ldflags="$LDFLAGS"
LCMS_LIBS='' CFLAGS="$CFLAGS $all_includes -I/usr/include/tqt"
LDFLAGS="$LDFLAGS $all_libraries"
if test "$have_lcms2_header" = 'yes'; then
LIBS="$LIBS -llcms2"
AC_TRY_LINK([
#define inline __inline /* gcc is in ansi mode */
#include LCMS_HEADER
#if LCMS_VERSION < 112
choke!
#endif
], [
cmsOpenProfileFromFile("foo", "r");
],
[LCMS_LIBS='-llcms2'; have_lcms='yes'])
else
if test "$have_lcms_header" = 'yes'; then
LIBS="$LIBS -llcms"
AC_TRY_LINK([
#define inline __inline /* gcc is in ansi mode */
#include LCMS_HEADER
#if LCMS_VERSION < 112
choke!
#endif
], [
cmsOpenProfileFromFile("foo", "r");
],
[LCMS_LIBS='-llcms'; have_lcms='yes'])
fi fi
fi fi
LIBS=$saved_libs
CFLAGS=$saved_cflags
LDFLAGS=$saved_ldflags
if test -z "$LCMS_LIBS"; then if test -z "$LCMS_LIBS"; then
DO_NOT_COMPILE="$DO_NOT_COMPILE ksvg" DO_NOT_COMPILE="$DO_NOT_COMPILE ksvg"

@ -205,13 +205,13 @@ bool SVGColorProfileElementImpl::loadColorProfile()
m_hInput = cmsOpenProfileFromFile(open.latin1(), "r"); m_hInput = cmsOpenProfileFromFile(open.latin1(), "r");
m_hOutput = cmsCreate_sRGBProfile(); m_hOutput = cmsCreate_sRGBProfile();
unsigned int dwIn = BYTES_SH(2) | CHANNELS_SH(_cmsChannelsOf(m_inputColorSpace)); unsigned int dwIn = BYTES_SH(2) | CHANNELS_SH(cmsChannelsOf(m_inputColorSpace));
unsigned int dwOut = BYTES_SH(2) | CHANNELS_SH(_cmsChannelsOf(m_outputColorSpace)); unsigned int dwOut = BYTES_SH(2) | CHANNELS_SH(cmsChannelsOf(m_outputColorSpace));
if(m_renderingIntent != RENDERING_INTENT_AUTO) if(m_renderingIntent != RENDERING_INTENT_AUTO)
m_hTrans = cmsCreateTransform(m_hInput, dwIn, m_hOutput, dwOut, m_renderingIntent - 2, cmsFLAGS_NOTPRECALC); m_hTrans = cmsCreateTransform(m_hInput, dwIn, m_hOutput, dwOut, m_renderingIntent - 2, cmsFLAGS_NOOPTIMIZE);
else else
m_hTrans = cmsCreateTransform(m_hInput, dwIn, m_hOutput, dwOut, cmsTakeRenderingIntent(m_hInput), cmsFLAGS_NOTPRECALC); m_hTrans = cmsCreateTransform(m_hInput, dwIn, m_hOutput, dwOut, cmsGetHeaderRenderingIntent(m_hInput), cmsFLAGS_NOOPTIMIZE);
m_inputColorSpace = cmsGetColorSpace(m_hInput); m_inputColorSpace = cmsGetColorSpace(m_hInput);
m_outputColorSpace = cmsGetColorSpace(m_hOutput); m_outputColorSpace = cmsGetColorSpace(m_hOutput);
@ -237,7 +237,7 @@ TQRgb SVGColorProfileElementImpl::correctPixel(float r, float g, float b)
return tqRgb(0, 0, 0); return tqRgb(0, 0, 0);
} }
unsigned short input[MAXCHANNELS], output[MAXCHANNELS]; unsigned short input[cmsMAXCHANNELS], output[cmsMAXCHANNELS];
input[0] = ((unsigned int) r) * 257; input[0] = ((unsigned int) r) * 257;
input[1] = ((unsigned int) g) * 257; input[1] = ((unsigned int) g) * 257;
@ -245,7 +245,7 @@ TQRgb SVGColorProfileElementImpl::correctPixel(float r, float g, float b)
cmsDoTransform(m_hTrans, input, output, 1); cmsDoTransform(m_hTrans, input, output, 1);
if(m_outputColorSpace == icSigRgbData) if(m_outputColorSpace == cmsSigRgbData)
return tqRgb(output[0] / 257, output[1] / 257, output[2] / 257); return tqRgb(output[0] / 257, output[1] / 257, output[2] / 257);
return tqRgb(0, 0, 0); return tqRgb(0, 0, 0);

@ -28,6 +28,15 @@
#undef QT_VERSION // Needed for 1.08 *grml* #undef QT_VERSION // Needed for 1.08 *grml*
#include LCMS_HEADER #include LCMS_HEADER
#if LCMS_VERSION < 2000
#define cmsColorSpaceSignature icColorSpaceSignature
#define cmsChannelsOf _cmsChannelsOf
#define cmsFLAGS_NOOPTIMIZE cmsFLAGS_NOTPRECALC
#define cmsGetHeaderRenderingIntent cmsTakeRenderingIntent
#define cmsMAXCHANNELS MAXCHANNELS
#define cmsSigRgbData icSigRgbData
#endif
#include "SVGElementImpl.h" #include "SVGElementImpl.h"
#include "SVGURIReferenceImpl.h" #include "SVGURIReferenceImpl.h"
@ -74,7 +83,7 @@ private:
cmsHTRANSFORM m_hTrans; cmsHTRANSFORM m_hTrans;
int m_intent; int m_intent;
icColorSpaceSignature m_inputColorSpace, m_outputColorSpace; cmsColorSpaceSignature m_inputColorSpace, m_outputColorSpace;
public: public:
KSVG_GET KSVG_GET

Loading…
Cancel
Save