[gimp/gimp-2-8] Avoid using CMFlattenProfile
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-8] Avoid using CMFlattenProfile
- Date: Sat, 9 Jun 2012 20:59:00 +0000 (UTC)
commit 7212f9973dbf88f627469d7e5ecf5d14e4b7a9fe
Author: Kristian Rietveld <kris loopnest org>
Date: Sat Jun 9 22:32:02 2012 +0200
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.
(cherry picked from commit 9514cf4871efbb0b13fc808c1277dbc467e43cac)
modules/display-filter-lcms.c | 71 +++++++++-------------------------------
1 files changed, 16 insertions(+), 55 deletions(-)
---
diff --git a/modules/display-filter-lcms.c b/modules/display-filter-lcms.c
index c99b0f8..30c5857 100644
--- a/modules/display-filter-lcms.c
+++ b/modules/display-filter-lcms.c
@@ -469,53 +469,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
cdisplay_lcms_get_display_profile (CdisplayLcms *lcms)
{
@@ -567,18 +520,26 @@ cdisplay_lcms_get_display_profile (CdisplayLcms *lcms)
if (prof)
{
- ProfileTransfer transfer = { NULL, 0 };
- Boolean foo;
+ CFDataRef data;
- CMFlattenProfile (prof, 0,
- lcms_cdisplay_lcms_flatten_profile, &transfer,
- &foo);
+ data = CMProfileCopyICCData (NULL, prof);
CMCloseProfile (prof);
- if (transfer.data)
+ if (data)
{
- profile = cmsOpenProfileFromMem (transfer.data, transfer.len);
- g_free (transfer.data);
+ UInt8 *buffer = g_malloc (CFDataGetLength (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);
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]