mscms: Use the bundled lcms2.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2021-10-19 11:25:14 +02:00
parent f550f624b2
commit 5c4c272a26
10 changed files with 103 additions and 354 deletions

111
configure vendored
View File

@ -671,8 +671,6 @@ PULSE_CFLAGS
GETTEXTPO_LIBS
FREETYPE_LIBS
FREETYPE_CFLAGS
LCMS2_LIBS
LCMS2_CFLAGS
RESOLV_LIBS
GPHOTO2_PORT_LIBS
GPHOTO2_PORT_CFLAGS
@ -853,7 +851,6 @@ enable_silent_rules
enable_werror
with_alsa
with_capi
with_cms
with_coreaudio
with_cups
with_dbus
@ -1958,8 +1955,6 @@ GPHOTO2_CFLAGS
GPHOTO2_LIBS
GPHOTO2_PORT_CFLAGS
GPHOTO2_PORT_LIBS
LCMS2_CFLAGS
LCMS2_LIBS
FREETYPE_CFLAGS
FREETYPE_LIBS
PULSE_CFLAGS
@ -2642,7 +2637,6 @@ Optional Packages:
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--without-alsa do not use the Alsa sound support
--without-capi do not use CAPI (ISDN support)
--without-cms do not use CMS (color management support)
--without-coreaudio do not use the CoreAudio sound support
--without-cups do not use CUPS
--without-dbus do not use DBus (dynamic device support)
@ -2763,9 +2757,6 @@ Some influential environment variables:
C compiler flags for libgphoto2_port, overriding pkg-config
GPHOTO2_PORT_LIBS
Linker flags for libgphoto2_port, overriding pkg-config
LCMS2_CFLAGS
C compiler flags for lcms2, overriding pkg-config
LCMS2_LIBS Linker flags for lcms2, overriding pkg-config
FREETYPE_CFLAGS
C compiler flags for freetype2, overriding pkg-config
FREETYPE_LIBS
@ -4009,12 +4000,6 @@ if test "${with_capi+set}" = set; then :
fi
# Check whether --with-cms was given.
if test "${with_cms+set}" = set; then :
withval=$with_cms;
fi
# Check whether --with-coreaudio was given.
if test "${with_coreaudio+set}" = set; then :
withval=$with_coreaudio; if test "x$withval" = "xno"; then ac_cv_header_CoreAudio_CoreAudio_h=no; fi
@ -14225,100 +14210,6 @@ $as_echo "#define HAVE_RES_GETSERVERS 1" >>confdefs.h
fi
fi
if test "x$with_cms" != "xno"
then
if ${LCMS2_CFLAGS:+false} :; then :
if ${PKG_CONFIG+:} false; then :
LCMS2_CFLAGS=`$PKG_CONFIG --cflags lcms2 2>/dev/null`
fi
fi
if ${LCMS2_LIBS:+false} :; then :
if ${PKG_CONFIG+:} false; then :
LCMS2_LIBS=`$PKG_CONFIG --libs lcms2 2>/dev/null`
fi
fi
LCMS2_LIBS=${LCMS2_LIBS:-"-llcms2"}
$as_echo "$as_me:${as_lineno-$LINENO}: lcms2 cflags: $LCMS2_CFLAGS" >&5
$as_echo "$as_me:${as_lineno-$LINENO}: lcms2 libs: $LCMS2_LIBS" >&5
ac_save_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $LCMS2_CFLAGS"
for ac_header in lcms2.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "lcms2.h" "ac_cv_header_lcms2_h" "$ac_includes_default"
if test "x$ac_cv_header_lcms2_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LCMS2_H 1
_ACEOF
fi
done
if test "$ac_cv_header_lcms2_h" = "yes"
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for cmsOpenProfileFromFile in -llcms2" >&5
$as_echo_n "checking for cmsOpenProfileFromFile in -llcms2... " >&6; }
if ${ac_cv_lib_lcms2_cmsOpenProfileFromFile+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-llcms2 $LCMS2_LIBS $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char cmsOpenProfileFromFile ();
int
main ()
{
return cmsOpenProfileFromFile ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_lcms2_cmsOpenProfileFromFile=yes
else
ac_cv_lib_lcms2_cmsOpenProfileFromFile=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lcms2_cmsOpenProfileFromFile" >&5
$as_echo "$ac_cv_lib_lcms2_cmsOpenProfileFromFile" >&6; }
if test "x$ac_cv_lib_lcms2_cmsOpenProfileFromFile" = xyes; then :
$as_echo "#define HAVE_LCMS2 1" >>confdefs.h
else
LCMS2_LIBS=""
fi
else
LCMS2_CFLAGS=""
LCMS2_LIBS=""
fi
CPPFLAGS=$ac_save_CPPFLAGS
fi
if test "$ac_cv_lib_lcms2_cmsOpenProfileFromFile" != "yes"; then :
case "x$with_cms" in
x) as_fn_append wine_notices "|liblcms2 ${notice_platform}development files not found, Color Management won't be supported." ;;
xno) ;;
*) as_fn_error $? "liblcms2 ${notice_platform}development files not found, Color Management won't be supported.
This is an error since --with-cms was requested." "$LINENO" 5 ;;
esac
fi
if test "x$with_freetype" != "xno"
then
if ${FREETYPE_CFLAGS:+false} :; then :
@ -19545,8 +19436,6 @@ GPHOTO2_LIBS = $GPHOTO2_LIBS
GPHOTO2_PORT_CFLAGS = $GPHOTO2_PORT_CFLAGS
GPHOTO2_PORT_LIBS = $GPHOTO2_PORT_LIBS
RESOLV_LIBS = $RESOLV_LIBS
LCMS2_CFLAGS = $LCMS2_CFLAGS
LCMS2_LIBS = $LCMS2_LIBS
FREETYPE_CFLAGS = $FREETYPE_CFLAGS
FREETYPE_LIBS = $FREETYPE_LIBS
GETTEXTPO_LIBS = $GETTEXTPO_LIBS

View File

@ -38,7 +38,6 @@ AC_ARG_ENABLE(werror, AS_HELP_STRING([--enable-werror],[treat compilation warnin
AC_ARG_WITH(alsa, AS_HELP_STRING([--without-alsa],[do not use the Alsa sound support]))
AC_ARG_WITH(capi, AS_HELP_STRING([--without-capi],[do not use CAPI (ISDN support)]))
AC_ARG_WITH(cms, AS_HELP_STRING([--without-cms],[do not use CMS (color management support)]))
AC_ARG_WITH(coreaudio, AS_HELP_STRING([--without-coreaudio],[do not use the CoreAudio sound support]),
[if test "x$withval" = "xno"; then ac_cv_header_CoreAudio_CoreAudio_h=no; fi])
AC_ARG_WITH(cups, AS_HELP_STRING([--without-cups],[do not use CUPS]))
@ -1496,23 +1495,6 @@ then
fi
fi
dnl **** Check for LittleCMS ***
if test "x$with_cms" != "xno"
then
WINE_PACKAGE_FLAGS(LCMS2,[lcms2],[-llcms2],,,
[AC_CHECK_HEADERS([lcms2.h])
if test "$ac_cv_header_lcms2_h" = "yes"
then
AC_CHECK_LIB(lcms2, cmsOpenProfileFromFile,
[AC_DEFINE(HAVE_LCMS2, 1, [Define if you have the LittleCMS development environment])],[LCMS2_LIBS=""],[$LCMS2_LIBS])
else
LCMS2_CFLAGS=""
LCMS2_LIBS=""
fi])
fi
WINE_NOTICE_WITH(cms,[test "$ac_cv_lib_lcms2_cmsOpenProfileFromFile" != "yes"],
[liblcms2 ${notice_platform}development files not found, Color Management won't be supported.])
dnl **** Check for FreeType 2 ****
if test "x$with_freetype" != "xno"
then

View File

@ -1,13 +1,11 @@
MODULE = mscms.dll
IMPORTLIB = mscms
IMPORTS = shlwapi advapi32
EXTRAINCL = $(LCMS2_CFLAGS)
EXTRALIBS = $(LCMS2_LIBS)
IMPORTS = $(LCMS2_PE_LIBS) shlwapi advapi32
EXTRAINCL = $(LCMS2_PE_CFLAGS)
C_SRCS = \
handle.c \
icc.c \
liblcms.c \
mscms_main.c \
profile.c \
stub.c \

View File

@ -40,7 +40,7 @@ static CRITICAL_SECTION_DEBUG mscms_handle_cs_debug =
static CRITICAL_SECTION mscms_handle_cs = { &mscms_handle_cs_debug, -1, 0, 0, 0, 0 };
static struct profile *profiletable;
static struct transform *transformtable;
static cmsHTRANSFORM *transformtable;
static unsigned int num_profile_handles;
static unsigned int num_transform_handles;
@ -80,7 +80,7 @@ void release_profile( struct profile *profile )
LeaveCriticalSection( &mscms_handle_cs );
}
struct transform *grab_transform( HTRANSFORM handle )
cmsHTRANSFORM grab_transform( HTRANSFORM handle )
{
DWORD_PTR index;
@ -92,10 +92,10 @@ struct transform *grab_transform( HTRANSFORM handle )
LeaveCriticalSection( &mscms_handle_cs );
return NULL;
}
return &transformtable[index];
return transformtable[index];
}
void release_transform( struct transform *transform )
void release_transform( cmsHTRANSFORM transform )
{
LeaveCriticalSection( &mscms_handle_cs );
}
@ -172,7 +172,7 @@ BOOL close_profile( HPROFILE handle )
}
CloseHandle( profile->file );
}
if (profile->cmsprofile) lcms_funcs->close_profile( profile->cmsprofile );
if (profile->cmsprofile) cmsCloseProfile( profile->cmsprofile );
HeapFree( GetProcessHeap(), 0, profile->data );
memset( profile, 0, sizeof(struct profile) );
@ -184,21 +184,21 @@ BOOL close_profile( HPROFILE handle )
static HTRANSFORM alloc_transform_handle( void )
{
DWORD_PTR index;
struct transform *p;
cmsHTRANSFORM *p;
unsigned int count = 128;
for (index = 0; index < num_transform_handles; index++)
{
if (!transformtable[index].cmstransform) return (HTRANSFORM)(index + 1);
if (!transformtable[index]) return (HTRANSFORM)(index + 1);
}
if (!transformtable)
{
p = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, count * sizeof(struct transform) );
p = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, count * sizeof(*p) );
}
else
{
count = num_transform_handles * 2;
p = HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, transformtable, count * sizeof(struct transform) );
p = HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, transformtable, count * sizeof(*p) );
}
if (!p) return NULL;
@ -208,7 +208,7 @@ static HTRANSFORM alloc_transform_handle( void )
return (HTRANSFORM)(index + 1);
}
HTRANSFORM create_transform( struct transform *transform )
HTRANSFORM create_transform( cmsHTRANSFORM transform )
{
HTRANSFORM handle;
@ -217,7 +217,7 @@ HTRANSFORM create_transform( struct transform *transform )
if ((handle = alloc_transform_handle()))
{
DWORD_PTR index = (DWORD_PTR)handle - 1;
transformtable[index] = *transform;
transformtable[index] = transform;
}
LeaveCriticalSection( &mscms_handle_cs );
return handle;
@ -226,7 +226,7 @@ HTRANSFORM create_transform( struct transform *transform )
BOOL close_transform( HTRANSFORM handle )
{
DWORD_PTR index;
struct transform *transform;
cmsHTRANSFORM transform;
EnterCriticalSection( &mscms_handle_cs );
@ -236,11 +236,9 @@ BOOL close_transform( HTRANSFORM handle )
LeaveCriticalSection( &mscms_handle_cs );
return FALSE;
}
transform = &transformtable[index];
lcms_funcs->close_transform( transform->cmstransform );
memset( transform, 0, sizeof(struct transform) );
transform = transformtable[index];
transformtable[index] = 0;
cmsDeleteTransform( transform );
LeaveCriticalSection( &mscms_handle_cs );
return TRUE;

View File

@ -1,166 +0,0 @@
/*
* Unix interface for liblcms2
*
* Copyright 2020 Alexandre Julliard
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#if 0
#pragma makedep unix
#endif
#include "config.h"
#ifdef HAVE_LCMS2
#include <stdarg.h>
#include <lcms2.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "windef.h"
#include "winbase.h"
#include "winternl.h"
#include "wingdi.h"
#include "winuser.h"
#include "icm.h"
#include "mscms_priv.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(mscms);
static DWORD from_bmformat( BMFORMAT format )
{
static BOOL quietfixme = FALSE;
DWORD ret;
switch (format)
{
case BM_RGBTRIPLETS: ret = TYPE_RGB_8; break;
case BM_BGRTRIPLETS: ret = TYPE_BGR_8; break;
case BM_GRAY: ret = TYPE_GRAY_8; break;
case BM_xRGBQUADS: ret = TYPE_ARGB_8; break;
case BM_xBGRQUADS: ret = TYPE_ABGR_8; break;
case BM_KYMCQUADS: ret = TYPE_KYMC_8; break;
default:
if (!quietfixme)
{
FIXME( "unhandled bitmap format %08x\n", format );
quietfixme = TRUE;
}
ret = TYPE_RGB_8;
break;
}
TRACE( "color space: %08x -> %08x\n", format, ret );
return ret;
}
static DWORD from_type( COLORTYPE type )
{
DWORD ret;
switch (type)
{
case COLOR_GRAY: ret = TYPE_GRAY_16; break;
case COLOR_RGB: ret = TYPE_RGB_16; break;
case COLOR_XYZ: ret = TYPE_XYZ_16; break;
case COLOR_Yxy: ret = TYPE_Yxy_16; break;
case COLOR_Lab: ret = TYPE_Lab_16; break;
case COLOR_CMYK: ret = TYPE_CMYK_16; break;
default:
FIXME( "unhandled color type %08x\n", type );
ret = TYPE_RGB_16;
break;
}
TRACE( "color type: %08x -> %08x\n", type, ret );
return ret;
}
static void * CDECL lcms_open_profile( void *data, DWORD size )
{
return cmsOpenProfileFromMem( data, size );
}
static void CDECL lcms_close_profile( void *profile )
{
cmsCloseProfile( profile );
}
static void * CDECL lcms_create_transform( void *output, void *target, DWORD intent )
{
DWORD proofing = 0;
cmsHPROFILE input = cmsCreate_sRGBProfile(); /* FIXME: create from supplied color space */
if (target) proofing = cmsFLAGS_SOFTPROOFING;
return cmsCreateProofingTransform( input, 0, output, 0, target,
intent, INTENT_ABSOLUTE_COLORIMETRIC, proofing );
}
static void * CDECL lcms_create_multi_transform( void *profiles, DWORD count, DWORD intent )
{
return cmsCreateMultiprofileTransform( profiles, count, 0, 0, intent, 0 );
}
static BOOL CDECL lcms_translate_bits( void *transform, void *srcbits, BMFORMAT input,
void *dstbits, BMFORMAT output, DWORD size )
{
if (!cmsChangeBuffersFormat( transform, from_bmformat(input), from_bmformat(output) )) return FALSE;
cmsDoTransform( transform, srcbits, dstbits, size );
return TRUE;
}
static BOOL CDECL lcms_translate_colors( void *transform, COLOR *in, DWORD count, COLORTYPE input_type,
COLOR *out, COLORTYPE output_type )
{
unsigned int i;
if (!cmsChangeBuffersFormat( transform, from_type(input_type), from_type(output_type) )) return FALSE;
for (i = 0; i < count; i++) cmsDoTransform( transform, &in[i], &out[i], 1 );
return TRUE;
}
static void CDECL lcms_close_transform( void *transform )
{
cmsDeleteTransform( transform );
}
static const struct lcms_funcs funcs =
{
lcms_open_profile,
lcms_close_profile,
lcms_create_transform,
lcms_create_multi_transform,
lcms_translate_bits,
lcms_translate_colors,
lcms_close_transform
};
static void lcms_error_handler(cmsContext ctx, cmsUInt32Number error, const char *text)
{
TRACE("%u %s\n", error, debugstr_a(text));
}
NTSTATUS CDECL __wine_init_unix_lib( HMODULE module, DWORD reason, const void *ptr_in, void *ptr_out )
{
if (reason != DLL_PROCESS_ATTACH) return STATUS_SUCCESS;
cmsSetLogErrorHandler( lcms_error_handler );
*(const struct lcms_funcs **)ptr_out = &funcs;
return STATUS_SUCCESS;
}
#endif /* HAVE_LCMS2 */

View File

@ -32,7 +32,10 @@
WINE_DEFAULT_DEBUG_CHANNEL(mscms);
const struct lcms_funcs *lcms_funcs = NULL;
static void lcms_error_handler(cmsContext ctx, cmsUInt32Number error, const char *text)
{
TRACE("%u %s\n", error, debugstr_a(text));
}
BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
{
@ -42,8 +45,7 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls( hinst );
if (__wine_init_unix_lib( hinst, reason, NULL, &lcms_funcs ))
ERR( "No liblcms2 support, expect problems\n" );
cmsSetLogErrorHandler( lcms_error_handler );
break;
case DLL_PROCESS_DETACH:
if (reserved) break;

View File

@ -25,31 +25,28 @@
* call, i.e. PROFILE_READ or PROFILE_READWRITE.
*/
#include <lcms2.h>
struct profile
{
HANDLE file;
DWORD access;
char *data;
DWORD size;
void *cmsprofile;
};
struct transform
{
void *cmstransform;
cmsHPROFILE cmsprofile;
};
extern HPROFILE create_profile( struct profile * ) DECLSPEC_HIDDEN;
extern BOOL close_profile( HPROFILE ) DECLSPEC_HIDDEN;
extern HTRANSFORM create_transform( struct transform * ) DECLSPEC_HIDDEN;
extern HTRANSFORM create_transform( cmsHTRANSFORM ) DECLSPEC_HIDDEN;
extern BOOL close_transform( HTRANSFORM ) DECLSPEC_HIDDEN;
struct profile *grab_profile( HPROFILE ) DECLSPEC_HIDDEN;
struct transform *grab_transform( HTRANSFORM ) DECLSPEC_HIDDEN;
cmsHTRANSFORM grab_transform( HTRANSFORM ) DECLSPEC_HIDDEN;
void release_profile( struct profile * ) DECLSPEC_HIDDEN;
void release_transform( struct transform * ) DECLSPEC_HIDDEN;
void release_transform( cmsHTRANSFORM ) DECLSPEC_HIDDEN;
extern void free_handle_tables( void ) DECLSPEC_HIDDEN;

View File

@ -1327,7 +1327,7 @@ HPROFILE WINAPI OpenColorProfileW( PPROFILE profile, DWORD access, DWORD sharing
{
struct profile prof;
HPROFILE hprof;
void *cmsprofile = NULL;
cmsHPROFILE cmsprofile;
char *data = NULL;
HANDLE handle = INVALID_HANDLE_VALUE;
DWORD size;
@ -1343,7 +1343,7 @@ HPROFILE WINAPI OpenColorProfileW( PPROFILE profile, DWORD access, DWORD sharing
if (!(data = HeapAlloc( GetProcessHeap(), 0, profile->cbDataSize ))) return NULL;
memcpy( data, profile->pProfileData, profile->cbDataSize );
if (lcms_funcs && !(cmsprofile = lcms_funcs->open_profile( data, profile->cbDataSize )))
if (!(cmsprofile = cmsOpenProfileFromMem( data, profile->cbDataSize )))
{
HeapFree( GetProcessHeap(), 0, data );
return FALSE;
@ -1405,7 +1405,7 @@ HPROFILE WINAPI OpenColorProfileW( PPROFILE profile, DWORD access, DWORD sharing
HeapFree( GetProcessHeap(), 0, data );
return NULL;
}
if (lcms_funcs && !(cmsprofile = lcms_funcs->open_profile( data, size )))
if (!(cmsprofile = cmsOpenProfileFromMem( data, size )))
{
CloseHandle( handle );
HeapFree( GetProcessHeap(), 0, data );
@ -1426,7 +1426,7 @@ HPROFILE WINAPI OpenColorProfileW( PPROFILE profile, DWORD access, DWORD sharing
if ((hprof = create_profile( &prof ))) return hprof;
if (cmsprofile) lcms_funcs->close_profile( cmsprofile );
cmsCloseProfile( cmsprofile );
HeapFree( GetProcessHeap(), 0, data );
CloseHandle( handle );
return NULL;

View File

@ -32,6 +32,54 @@
WINE_DEFAULT_DEBUG_CHANNEL(mscms);
static DWORD from_bmformat( BMFORMAT format )
{
static BOOL quietfixme = FALSE;
DWORD ret;
switch (format)
{
case BM_RGBTRIPLETS: ret = TYPE_RGB_8; break;
case BM_BGRTRIPLETS: ret = TYPE_BGR_8; break;
case BM_GRAY: ret = TYPE_GRAY_8; break;
case BM_xRGBQUADS: ret = TYPE_ARGB_8; break;
case BM_xBGRQUADS: ret = TYPE_ABGR_8; break;
case BM_KYMCQUADS: ret = TYPE_KYMC_8; break;
default:
if (!quietfixme)
{
FIXME( "unhandled bitmap format %08x\n", format );
quietfixme = TRUE;
}
ret = TYPE_RGB_8;
break;
}
TRACE( "color space: %08x -> %08x\n", format, ret );
return ret;
}
static DWORD from_type( COLORTYPE type )
{
DWORD ret;
switch (type)
{
case COLOR_GRAY: ret = TYPE_GRAY_16; break;
case COLOR_RGB: ret = TYPE_RGB_16; break;
case COLOR_XYZ: ret = TYPE_XYZ_16; break;
case COLOR_Yxy: ret = TYPE_Yxy_16; break;
case COLOR_Lab: ret = TYPE_Lab_16; break;
case COLOR_CMYK: ret = TYPE_CMYK_16; break;
default:
FIXME( "unhandled color type %08x\n", type );
ret = TYPE_RGB_16;
break;
}
TRACE( "color type: %08x -> %08x\n", type, ret );
return ret;
}
/******************************************************************************
* CreateColorTransformA [MSCMS.@]
*
@ -75,13 +123,14 @@ HTRANSFORM WINAPI CreateColorTransformW( LPLOGCOLORSPACEW space, HPROFILE dest,
HPROFILE target, DWORD flags )
{
HTRANSFORM ret = NULL;
struct transform transform;
cmsHTRANSFORM transform;
struct profile *dst, *tgt = NULL;
DWORD proofing = 0;
cmsHPROFILE input;
int intent;
TRACE( "( %p, %p, %p, 0x%08x )\n", space, dest, target, flags );
if (!lcms_funcs) return FALSE;
if (!space || !(dst = grab_profile( dest ))) return FALSE;
if (target && !(tgt = grab_profile( target )))
@ -95,16 +144,18 @@ HTRANSFORM WINAPI CreateColorTransformW( LPLOGCOLORSPACEW space, HPROFILE dest,
TRACE( "lcsCSType: %s\n", dbgstr_tag( space->lcsCSType ) );
TRACE( "lcsFilename: %s\n", debugstr_w( space->lcsFilename ) );
transform.cmstransform = lcms_funcs->create_transform( dst->cmsprofile,
tgt ? tgt->cmsprofile : NULL, intent );
if (!transform.cmstransform)
input = cmsCreate_sRGBProfile(); /* FIXME: create from supplied color space */
if (target) proofing = cmsFLAGS_SOFTPROOFING;
transform = cmsCreateProofingTransform( input, 0, dst->cmsprofile, 0, tgt ? tgt->cmsprofile : NULL,
intent, INTENT_ABSOLUTE_COLORIMETRIC, proofing );
if (!transform)
{
if (tgt) release_profile( tgt );
release_profile( dst );
return FALSE;
}
ret = create_transform( &transform );
ret = create_transform( transform );
if (tgt) release_profile( tgt );
release_profile( dst );
@ -131,14 +182,13 @@ HTRANSFORM WINAPI CreateMultiProfileTransform( PHPROFILE profiles, DWORD nprofil
PDWORD intents, DWORD nintents, DWORD flags, DWORD cmm )
{
HTRANSFORM ret = NULL;
void *cmsprofiles[2];
struct transform transform;
cmsHPROFILE cmsprofiles[2];
cmsHTRANSFORM transform;
struct profile *profile0, *profile1;
TRACE( "( %p, 0x%08x, %p, 0x%08x, 0x%08x, 0x%08x )\n",
profiles, nprofiles, intents, nintents, flags, cmm );
if (!lcms_funcs) return NULL;
if (!profiles || !nprofiles || !intents) return NULL;
if (nprofiles > 2)
@ -159,8 +209,8 @@ HTRANSFORM WINAPI CreateMultiProfileTransform( PHPROFILE profiles, DWORD nprofil
cmsprofiles[0] = profile0->cmsprofile;
cmsprofiles[1] = profile1->cmsprofile;
transform.cmstransform = lcms_funcs->create_multi_transform( cmsprofiles, nprofiles, *intents );
if (transform.cmstransform) ret = create_transform( &transform );
transform = cmsCreateMultiprofileTransform( cmsprofiles, nprofiles, 0, 0, *intents, 0 );
if (transform) ret = create_transform( transform );
release_profile( profile0 );
release_profile( profile1 );
@ -213,15 +263,15 @@ BOOL WINAPI TranslateBitmapBits( HTRANSFORM handle, PVOID srcbits, BMFORMAT inpu
DWORD outputstride, PBMCALLBACKFN callback, ULONG data )
{
BOOL ret;
struct transform *transform = grab_transform( handle );
cmsHTRANSFORM transform = grab_transform( handle );
TRACE( "( %p, %p, 0x%08x, 0x%08x, 0x%08x, 0x%08x, %p, 0x%08x, 0x%08x, %p, 0x%08x )\n",
handle, srcbits, input, width, height, inputstride, destbits, output,
outputstride, callback, data );
if (!transform) return FALSE;
ret = lcms_funcs->translate_bits( transform->cmstransform, srcbits, input,
destbits, output, width * height );
ret = cmsChangeBuffersFormat( transform, from_bmformat(input), from_bmformat(output) );
if (ret) cmsDoTransform( transform, srcbits, destbits, width * height );
release_transform( transform );
return ret;
}
@ -247,12 +297,17 @@ BOOL WINAPI TranslateColors( HTRANSFORM handle, PCOLOR in, DWORD count,
COLORTYPE input_type, PCOLOR out, COLORTYPE output_type )
{
BOOL ret;
struct transform *transform = grab_transform( handle );
unsigned int i;
cmsHTRANSFORM transform = grab_transform( handle );
TRACE( "( %p, %p, %d, %d, %p, %d )\n", handle, in, count, input_type, out, output_type );
if (!transform) return FALSE;
ret = lcms_funcs->translate_colors( transform->cmstransform, in, count, input_type, out, output_type );
ret = cmsChangeBuffersFormat( transform, from_type(input_type), from_type(output_type) );
if (ret)
for (i = 0; i < count; i++) cmsDoTransform( transform, &in[i], &out[i], 1 );
release_transform( transform );
return ret;
}

View File

@ -195,12 +195,6 @@
/* Define to 1 if you have the <lber.h> header file. */
#undef HAVE_LBER_H
/* Define if you have the LittleCMS development environment */
#undef HAVE_LCMS2
/* Define to 1 if you have the <lcms2.h> header file. */
#undef HAVE_LCMS2_H
/* Define if you have the OpenLDAP development environment */
#undef HAVE_LDAP