static PyObject * createProfile(PyObject *self, PyObject *args) { char *sColorSpace; cmsHPROFILE hProfile; cmsFloat64Number dColorTemp = 0.0; cmsCIExyY whitePoint; cmsBool result; if (!PyArg_ParseTuple(args, "s|d:createProfile", &sColorSpace, &dColorTemp)) return NULL; if (strcmp(sColorSpace, "LAB") == 0) { if (dColorTemp > 0.0) { result = cmsWhitePointFromTemp(&whitePoint, dColorTemp); if (!result) { PyErr_SetString(PyExc_ValueError, "ERROR: Could not calculate white point from color temperature provided, must be float in degrees Kelvin"); return NULL; } hProfile = cmsCreateLab2Profile(&whitePoint); } else { hProfile = cmsCreateLab2Profile(NULL); } } else if (strcmp(sColorSpace, "XYZ") == 0) { hProfile = cmsCreateXYZProfile(); } else if (strcmp(sColorSpace, "sRGB") == 0) { hProfile = cmsCreate_sRGBProfile(); } else { hProfile = NULL; } if (!hProfile) { PyErr_SetString(PyExc_ValueError, "failed to create requested color space"); return NULL; } return cms_profile_new(hProfile); }
static void gcm_cell_renderer_set_color (GcmCellRendererColor *renderer) { CdColorRGB8 rgb; GdkPixbuf *pixbuf = NULL; gint height = 26; /* TODO: needs to be a property */ gint width = 400; /* TODO: needs to be a property */ gint x, y; guchar *pixels; guint pos; cmsHPROFILE profile_srgb = NULL; cmsHPROFILE profile_lab = NULL; cmsHTRANSFORM xform = NULL; /* nothing set yet */ if (renderer->color == NULL) goto out; /* convert the color to sRGB */ profile_lab = cmsCreateLab2Profile (NULL); profile_srgb = cmsCreate_sRGBProfile (); xform = cmsCreateTransform (profile_lab, TYPE_Lab_DBL, profile_srgb, TYPE_RGB_8, INTENT_ABSOLUTE_COLORIMETRIC, 0); cmsDoTransform (xform, renderer->color, &rgb, 1); /* create a pixbuf of the right size */ pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, width, height); width = gdk_pixbuf_get_width (pixbuf); height = gdk_pixbuf_get_height (pixbuf); pixels = gdk_pixbuf_get_pixels (pixbuf); for (y=0; y<height; y++) { for (x=0; x<width; x++) { pos = (y*width+x) * 3; pixels[pos+0] = rgb.R; pixels[pos+1] = rgb.G; pixels[pos+2] = rgb.B; } } out: g_object_set (renderer, "pixbuf", pixbuf, NULL); if (profile_srgb != NULL) cmsCloseProfile (profile_srgb); if (profile_lab != NULL) cmsCloseProfile (profile_lab); if (xform != NULL) cmsDeleteTransform (xform); if (pixbuf != NULL) g_object_unref (pixbuf); }
ScColorProfile ScLcms2ColorMgmtEngineImpl::createProfile_Lab(ScColorMgmtEngine& engine) { QString internalProfilePath("memprofile://Internal Lab profile"); ScColorProfile profile = m_profileCache->profile(internalProfilePath); if (!profile.isNull()) return profile; cmsHPROFILE lcmsProf = cmsCreateLab2Profile(NULL); if (lcmsProf) { ScLcms2ColorProfileImpl* profData = new ScLcms2ColorProfileImpl(engine, lcmsProf); profData->m_profilePath = internalProfilePath; profile = ScColorProfile(dynamic_cast<ScColorProfileData*>(profData)); m_profileCache->addProfile(profile); } if (profile.isNull() && lcmsProf) { cmsCloseProfile(lcmsProf); lcmsProf = NULL; } return profile; }
JNIEXPORT jlong JNICALL Java_com_lightcrafts_utils_LCMS_cmsCreateLab2Profile (JNIEnv *env, jclass clazz) { return (jlong)(intptr_t) cmsCreateLab2Profile(NULL); }