Avoid using CMFlattenProfile

This symbol is not available to 64-bit applications.  So put another
approach in place.

I can confirm that the code does not crash, but I do not know if it
works properly.  Mitch forced me to push anyway.
This commit is contained in:
Kristian Rietveld 2012-06-09 22:32:02 +02:00
parent c7ff5e7ae4
commit 9514cf4871
1 changed files with 16 additions and 55 deletions

View File

@ -470,53 +470,6 @@ cdisplay_lcms_get_screen (CdisplayLcms *lcms,
} }
#ifdef GDK_WINDOWING_QUARTZ
typedef struct
{
guchar *data;
gsize len;
} ProfileTransfer;
enum
{
openReadSpool = 1, /* start read data process */
openWriteSpool = 2, /* start write data process */
readSpool = 3, /* read specified number of bytes */
writeSpool = 4, /* write specified number of bytes */
closeSpool = 5 /* complete data transfer process */
};
static OSErr
lcms_cdisplay_lcms_flatten_profile (SInt32 command,
SInt32 *size,
void *data,
void *refCon)
{
ProfileTransfer *transfer = refCon;
switch (command)
{
case openWriteSpool:
g_return_val_if_fail (transfer->data == NULL && transfer->len == 0, -1);
break;
case writeSpool:
transfer->data = g_realloc (transfer->data, transfer->len + *size);
memcpy (transfer->data + transfer->len, data, *size);
transfer->len += *size;
break;
default:
break;
}
return 0;
}
#endif /* GDK_WINDOWING_QUARTZ */
static cmsHPROFILE static cmsHPROFILE
cdisplay_lcms_get_display_profile (CdisplayLcms *lcms) cdisplay_lcms_get_display_profile (CdisplayLcms *lcms)
{ {
@ -568,18 +521,26 @@ cdisplay_lcms_get_display_profile (CdisplayLcms *lcms)
if (prof) if (prof)
{ {
ProfileTransfer transfer = { NULL, 0 }; CFDataRef data;
Boolean foo;
CMFlattenProfile (prof, 0, data = CMProfileCopyICCData (NULL, prof);
lcms_cdisplay_lcms_flatten_profile, &transfer,
&foo);
CMCloseProfile (prof); CMCloseProfile (prof);
if (transfer.data) if (data)
{ {
profile = cmsOpenProfileFromMem (transfer.data, transfer.len); UInt8 *buffer = g_malloc (CFDataGetLength (data));
g_free (transfer.data);
/* We cannot use CFDataGetBytesPtr(), because that returns
* a const pointer where cmsOpenProfileFromMem wants a
* non-const pointer.
*/
CFDataGetBytes (data, CFRangeMake (0, CFDataGetLength (data)),
buffer);
profile = cmsOpenProfileFromMem (buffer, CFDataGetLength (data));
g_free (buffer);
CFRelease (data);
} }
} }
} }