Fredrik Lundh avatar Fredrik Lundh committed 847409d

More CMS cleanup.

Comments (0)

Files changed (1)

  * Copyright (C) 2002-2003 Kevin Cazabon
+ * Adapted/reworked for PIL by Fredrik Lundh
+ * Copyright (c) 2009 Fredrik Lundh
  * pyCMS home page:
  * littleCMS home page:
 /* version history */
-0.1.0 pil integration
+0.1.0 pil integration & refactoring
 0.0.2 alpha:  Minor updates, added interfaces to littleCMS features, Jan 6, 2003
     - fixed some memory holes in how transforms/profiles were created and passed back to Python
        due to improper destructor setup for PyCObjects
-/* known to-do list with current version */
+/* known to-do list with current version:
-Add comments to code to make it clearer for others to read/understand!!!
 Verify that PILmode->littleCMStype conversion in findLCMStype is correct for all PIL modes (it probably isn't for the more obscure ones)
-Add support for reading and writing embedded profiles in JPEG and TIFF files
 Add support for creating custom RGB profiles on the fly
 Add support for checking presence of a specific tag in a profile
 Add support for other littleCMS features as required
-/* reference */
 INTENT_PERCEPTUAL                 0
 /* -------------------------------------------------------------------- */
 /* wrapper classes */
+/* a profile represents the ICC characteristics for a specific device */
 typedef struct {
     cmsHPROFILE profile;
     cmsHPROFILE hProfile;
     char* sProfile;
-    if (!PyArg_ParseTuple(args, "s:OpenProfile", &sProfile))
+    if (!PyArg_ParseTuple(args, "s:profile_open", &sProfile))
       return NULL;
 static PyObject*
-cms_profile_open_memory(PyObject* self, PyObject* args)
+cms_profile_fromstring(PyObject* self, PyObject* args)
     cmsHPROFILE hProfile;
     char* pProfile;
     int nProfile;
-    if (!PyArg_ParseTuple(args, "s#:OpenMemoryProfile", &pProfile, &nProfile))
+    if (!PyArg_ParseTuple(args, "s#:profile_fromstring", &pProfile, &nProfile))
       return NULL;
     hProfile = cmsOpenProfileFromMem(pProfile, nProfile);
     if (!hProfile)
-      PyErr_SetString(PyExc_IOError, "cannot open memory profile");
+      PyErr_SetString(PyExc_IOError, "cannot open profile from string");
     return cms_profile_new(hProfile);
+/* a transform represents the mapping between two profiles */
 typedef struct {
     char mode_in[8];
   return Py_BuildValue("si", PYCMSVERSION, LCMS_VERSION);
-static cmsHPROFILE
-open_profile(const char* sProfile)
-  cmsHPROFILE hProfile;
-  hProfile = cmsOpenProfileFromFile(sProfile, "r");
-  if (!hProfile)
-    PyErr_SetString(PyExc_IOError, "cannot open profile file");
-  return hProfile;
 static PyObject *
 buildTransform(PyObject *self, PyObject *args) {
   CmsProfileObject *pInputProfile;
 static PyMethodDef pyCMSdll_methods[] = {
   {"profile_open", cms_profile_open, 1},
-  {"profile_fromstring", cms_profile_open_memory, 1},
+  {"profile_fromstring", cms_profile_fromstring, 1},
   /* pyCMS info */
   {"versions", versions, 1},
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.