Example #1
0
static gchar *color_man_get_profile_name(ColorManProfileType type, cmsHPROFILE profile)
{
	switch (type)
		{
		case COLOR_PROFILE_SRGB:
			return g_strdup(_("sRGB"));
		case COLOR_PROFILE_ADOBERGB:
			return g_strdup(_("Adobe RGB compatible"));
			break;
		case COLOR_PROFILE_MEM:
		case COLOR_PROFILE_FILE:
			if (profile)
				{
#ifdef HAVE_LCMS2
				cmsUInt32Number r;
				char buffer[20];
				buffer[0] = '\0';
				r = cmsGetProfileInfoASCII(profile, cmsInfoDescription, "en", "US", buffer, 20);
				buffer[19] = '\0'; /* Just to be sure */
				return g_strdup(buffer);
#else
				return g_strdup(cmsTakeProductName(profile));
#endif
				}
			return g_strdup(_("Custom profile"));
			break;
		case COLOR_PROFILE_NONE:
		default:
			return g_strdup("");
		}
}
Example #2
0
static PyObject*  
cms_profile_getattro(CmsProfileObject* self, PyObject* name)
{
    PyObject* name_bytes;
    char* name_string;

    if (!PyUnicode_Check(name))
        return NULL;
   
    if (!(name_bytes = PyUnicode_AsASCIIString(name)))
        return NULL;

    if (!(name_string = PyBytes_AsString(name_bytes)))
        return NULL;

    if (!strcmp(name_string, "product_name"))
        return PyUnicode_FromFormat("%s", cmsTakeProductName(self->profile));
    if (!strcmp(name_string, "product_desc"))
        return PyUnicode_FromFormat("%s", cmsTakeProductDesc(self->profile));
    if (!strcmp(name_string, "product_info"))
        return PyUnicode_FromFormat("%s", cmsTakeProductInfo(self->profile));
    if (!strcmp(name_string, "rendering_intent"))
        return PyLong_FromLong(cmsTakeRenderingIntent(self->profile));
    if (!strcmp(name_string, "pcs"))
        return PyUnicode_FromFormat("%s", findICmode(cmsGetPCS(self->profile)));
    if (!strcmp(name_string, "color_space"))
        return PyUnicode_FromFormat("%s",
                findICmode(cmsGetColorSpace(self->profile)));
    /* FIXME: add more properties (creation_datetime etc) */

    return PyObject_GenericGetAttr((PyObject*)self, name);
}
Example #3
0
static PyObject*
cms_profile_getattr(CmsProfileObject* self, char* name)
{
#ifdef PY3
    if (!strcmp(name, "product_name"))
        return PyUnicode_DecodeFSDefault(cmsTakeProductName(self->profile));
    if (!strcmp(name, "product_desc"))
        return PyUnicode_DecodeFSDefault(cmsTakeProductDesc(self->profile));
    if (!strcmp(name, "product_info"))
        return PyUnicode_DecodeFSDefault(cmsTakeProductInfo(self->profile));
    if (!strcmp(name, "rendering_intent"))
        return PyLong_FromLong(cmsTakeRenderingIntent(self->profile));
    if (!strcmp(name, "pcs"))
        return PyUnicode_DecodeFSDefault(findICmode(cmsGetPCS(self->profile)));
    if (!strcmp(name, "color_space"))
        return PyUnicode_DecodeFSDefault(findICmode(cmsGetColorSpace(self->profile)));
    /* FIXME: add more properties (creation_datetime etc) */

    return PyObject_GenericGetAttr((PyObject *)self,
                                   PyUnicode_DecodeFSDefault(name));
#else
    if (!strcmp(name, "product_name"))
        return PyString_FromString(cmsTakeProductName(self->profile));
    if (!strcmp(name, "product_desc"))
        return PyString_FromString(cmsTakeProductDesc(self->profile));
    if (!strcmp(name, "product_info"))
        return PyString_FromString(cmsTakeProductInfo(self->profile));
    if (!strcmp(name, "rendering_intent"))
        return PyInt_FromLong(cmsTakeRenderingIntent(self->profile));
    if (!strcmp(name, "pcs"))
        return PyString_FromString(findICmode(cmsGetPCS(self->profile)));
    if (!strcmp(name, "color_space"))
        return PyString_FromString(findICmode(cmsGetColorSpace(self->profile)));
    /* FIXME: add more properties (creation_datetime etc) */

    return Py_FindMethod(cms_profile_methods, (PyObject*) self, name);
#endif
}
Example #4
0
static PyObject *
pycms_GetProfileInfo (PyObject *self, PyObject *args) {

	void *profile;
	cmsHPROFILE hProfile;

	if (!PyArg_ParseTuple(args, "O", &profile)) {
		return NULL;
	}

	cmsErrorAction(LCMS_ERROR_IGNORE);

	hProfile = (cmsHPROFILE) PyCObject_AsVoidPtr(profile);

	return Py_BuildValue("s", cmsTakeProductName(hProfile));
}
Example #5
0
static void
cdisplay_proof_combo_box_set_active (GimpColorProfileComboBox *combo,
                                     const gchar              *filename)
{
  cmsHPROFILE  profile = NULL;
  gchar       *label   = NULL;

  if (filename)
    profile = cmsOpenProfileFromFile (filename, "r");

  if (profile)
    {
      label = gimp_any_to_utf8 (cmsTakeProductDesc (profile), -1, NULL);
      if (! label)
        label = gimp_any_to_utf8 (cmsTakeProductName (profile), -1, NULL);

      cmsCloseProfile (profile);
    }

  gimp_color_profile_combo_box_set_active (combo, filename, label);
  g_free (label);
}
Example #6
0
static PyObject*
cms_profile_getattr_product_name(CmsProfileObject* self, void* closure)
{
    return PyUnicode_DecodeFSDefault(cmsTakeProductName(self->profile));
}
Example #7
0
static
cmsHPROFILE GetTIFFProfile(TIFF* in)
{    
    cmsCIExyYTRIPLE Primaries;
	float* chr;
    cmsCIExyY WhitePoint;
    float* wp;
    int i;       
    LPGAMMATABLE Gamma[3]; 
    LPWORD gmr, gmg, gmb;
    cmsHPROFILE hProfile;
    DWORD EmbedLen;
    LPBYTE EmbedBuffer;
      
              
       if (IgnoreEmbedded) return NULL;

       if (TIFFGetField(in, TIFFTAG_ICCPROFILE, &EmbedLen, &EmbedBuffer)) {

              hProfile = cmsOpenProfileFromMem(EmbedBuffer, EmbedLen);
   
              if (Verbose) {

                  fprintf(stdout, " (Embedded profile found)\n");
                  fprintf(stdout, "Product name: %s\n", cmsTakeProductName(hProfile));
                  fprintf(stdout, "Description : %s\n", cmsTakeProductDesc(hProfile));                          
                  fflush(stdout);
              }

              if (hProfile != NULL && SaveEmbedded != NULL)
                  SaveMemoryBlock(EmbedBuffer, EmbedLen, SaveEmbedded);

              if (hProfile) return hProfile;
       }

        // Try to see if "colorimetric" tiff

       if (TIFFGetField(in, TIFFTAG_PRIMARYCHROMATICITIES, &chr)) {
                      
           Primaries.Red.x   =  chr[0];
           Primaries.Red.y   =  chr[1];
           Primaries.Green.x =  chr[2];
           Primaries.Green.y =  chr[3];
           Primaries.Blue.x  =  chr[4];
           Primaries.Blue.y  =  chr[5];
           
           Primaries.Red.Y = Primaries.Green.Y = Primaries.Blue.Y = 1.0;
                      
           if (TIFFGetField(in, TIFFTAG_WHITEPOINT, &wp)) {
               
               WhitePoint.x = wp[0];
               WhitePoint.y = wp[1];
               WhitePoint.Y = 1.0;
                                             
               // Transferfunction is a bit harder....
               
               for (i=0; i < 3; i++)
                   Gamma[i] = cmsAllocGamma(256);
                                            
               TIFFGetFieldDefaulted(in, TIFFTAG_TRANSFERFUNCTION,
                   &gmr, 
                   &gmg,
                   &gmb);
               
               CopyMemory(Gamma[0]->GammaTable, gmr, 256*sizeof(WORD));
               CopyMemory(Gamma[1]->GammaTable, gmg, 256*sizeof(WORD));
               CopyMemory(Gamma[2]->GammaTable, gmb, 256*sizeof(WORD));
               
               hProfile = cmsCreateRGBProfile(&WhitePoint, &Primaries, Gamma);
               
               for (i=0; i < 3; i++)
                   cmsFreeGamma(Gamma[i]);

                if (Verbose) {
                  fprintf(stdout, " (Colorimetric TIFF)\n");
                }
             
               
               return hProfile;
           }
       }

       return NULL;
}
Example #8
0
static gchar *
lcms_icc_profile_get_name (cmsHPROFILE profile)
{
  return gimp_any_to_utf8 (cmsTakeProductName (profile), -1, NULL);
}
Example #9
0
static
int TransformImage(char *cDefInpProf, char *cOutProf)
{
       cmsHPROFILE hIn, hOut, hProof;
       cmsHTRANSFORM xform;
       DWORD wInput, wOutput;
       int OutputColorSpace;
       DWORD dwFlags = 0; 
       DWORD EmbedLen;
       LPBYTE EmbedBuffer;


       if (BlackPointCompensation) {

            dwFlags |= cmsFLAGS_BLACKPOINTCOMPENSATION;            
       }

       switch (PrecalcMode) {
           
       case 0: dwFlags |= cmsFLAGS_NOTPRECALC; break;
       case 2: dwFlags |= cmsFLAGS_HIGHRESPRECALC; break;
       case 3: dwFlags |= cmsFLAGS_LOWRESPRECALC; break;
       default:;
       }
        

       if (GamutCheck)
            dwFlags |= cmsFLAGS_GAMUTCHECK;
        

        if (lIsDeviceLink) {

            hIn = cmsOpenProfileFromFile(cDefInpProf, "r");
            hOut = NULL;
            hProof = NULL;
       }
        else {

        if (!IgnoreEmbedded && read_icc_profile(&Decompressor, &EmbedBuffer, &EmbedLen))
        {
              hIn = cmsOpenProfileFromMem(EmbedBuffer, EmbedLen);

               if (Verbose) {

                  fprintf(stdout, " (Embedded profile found)\n");
                  fprintf(stdout, "Product name: %s\n", cmsTakeProductName(hIn));
                  fprintf(stdout, "Description : %s\n", cmsTakeProductDesc(hIn));                          
                  fflush(stdout);
              }

               if (hIn != NULL && SaveEmbedded != NULL)
                          SaveMemoryBlock(EmbedBuffer, EmbedLen, SaveEmbedded);

              free(EmbedBuffer);
        }
        else
        {
                hIn = OpenStockProfile(cDefInpProf);
       }

        hOut = OpenStockProfile(cOutProf);


       hProof = NULL;
       if (cProofing != NULL) {

           hProof = OpenStockProfile(cProofing);
       }
        }

       // Take input color space

       wInput = GetInputPixelType();

       // Assure both, input profile and input JPEG are on same colorspace

       
       if (cmsGetColorSpace(hIn) != _cmsICCcolorSpace(T_COLORSPACE(wInput)))
              FatalError("Input profile is not operating in proper color space");
       

       // Output colorspace is given by output profile

        if (lIsDeviceLink) {
            OutputColorSpace = T_COLORSPACE(wInput);
        }
        else {
            OutputColorSpace = GetProfileColorSpace(hOut);
        }

       jpeg_copy_critical_parameters(&Decompressor, &Compressor);
       
       WriteOutputFields(OutputColorSpace);               
       
       wOutput      = ComputeOutputFormatDescriptor(wInput, OutputColorSpace);
       
       xform = cmsCreateProofingTransform(hIn, wInput, 
                                          hOut, wOutput, 
                                          hProof, Intent, 
                                          ProofingIntent, dwFlags);

       // Handle tile by tile or strip by strip strtok

       DoTransform(xform);

       
       jcopy_markers_execute(&Decompressor, &Compressor);
       
       cmsDeleteTransform(xform);
       cmsCloseProfile(hIn);
       cmsCloseProfile(hOut);
       if (hProof) cmsCloseProfile(hProof);
       
       return 1;
}
Example #10
0
static
void OpenTransforms(int argc, char *argv[])
{
    
    DWORD dwIn, dwOut, dwFlags;
    

	if (lMultiProfileChain) {

		int i;
		cmsHTRANSFORM hTmp;

		
		nProfiles = argc - xoptind;
		for (i=0; i < nProfiles; i++) {

			hProfiles[i] = OpenProfile(argv[i+xoptind]);
		}

	
		// Create a temporary devicelink 

		hTmp = cmsCreateMultiprofileTransform(hProfiles, nProfiles, 
							0, 0, Intent, GetFlags());

		hInput = cmsTransform2DeviceLink(hTmp, 0);
		hOutput = NULL;
		cmsDeleteTransform(hTmp);

		InputColorSpace  = cmsGetColorSpace(hInput);
        OutputColorSpace = cmsGetPCS(hInput);        
		lIsDeviceLink = TRUE;

	}
	else
    if (lIsDeviceLink) {
        
        hInput  = cmsOpenProfileFromFile(cInProf, "r");
        hOutput = NULL;
        InputColorSpace  = cmsGetColorSpace(hInput);
        OutputColorSpace = cmsGetPCS(hInput);
        
        
    }
    else {
        
        hInput  = OpenProfile(cInProf);
        hOutput = OpenProfile(cOutProf);    
        
        InputColorSpace   = cmsGetColorSpace(hInput);
        OutputColorSpace  = cmsGetColorSpace(hOutput);
        
        if (cmsGetDeviceClass(hInput) == icSigLinkClass ||
            cmsGetDeviceClass(hOutput) == icSigLinkClass)   
            FatalError("Use %cl flag for devicelink profiles!\n", SW);
    
    }
    
    
    
    if (Verbose) {
        
        mexPrintf("From: %s\n", cmsTakeProductName(hInput));
        if (hOutput) mexPrintf("To  : %s\n\n", cmsTakeProductName(hOutput));
        
    }
    
        
    OutputChannels = _cmsChannelsOf(OutputColorSpace);
	InputChannels  = _cmsChannelsOf(InputColorSpace);
    

    dwIn  = MakeFormatDescriptor(InputColorSpace, nBytesDepth);
    dwOut = MakeFormatDescriptor(OutputColorSpace, nBytesDepth);
    
 
    dwFlags = GetFlags();
    
    if (cProofing != NULL) {

                   hProof = OpenProfile(cProofing);
                   dwFlags |= cmsFLAGS_SOFTPROOFING;
    }

   


     hColorTransform = cmsCreateProofingTransform(hInput, dwIn, 
                                          hOutput, dwOut, 
                                          hProof, Intent, 
                                          ProofingIntent, 
                                          dwFlags);
      
     
    
}
Example #11
0
static
void OpenTransforms(void)
{

    DWORD dwIn, dwOut, dwFlags;

    dwFlags = 0;
    
    
    if (lIsDeviceLink) {

            hInput  = cmsOpenProfileFromFile(cInProf, "r");
            hOutput = NULL;
            InputColorSpace   = cmsGetColorSpace(hInput);
            OutputColorSpace = cmsGetPCS(hInput);
        
            
       }
    else {

            hInput  = OpenStockProfile(cInProf);
            hOutput = OpenStockProfile(cOutProf);    
            hProof  = NULL;

            if (cProofing != NULL) {

                   hProof = OpenStockProfile(cProofing);
                   dwFlags |= cmsFLAGS_SOFTPROOFING;
            }

            InputColorSpace   = cmsGetColorSpace(hInput);
            OutputColorSpace  = cmsGetColorSpace(hOutput);

            if (cmsGetDeviceClass(hInput) == icSigLinkClass ||
                cmsGetDeviceClass(hOutput) == icSigLinkClass)   
                        FatalError("Use %cl flag for devicelink profiles!\n", SW);
    
    }

       hXYZ    = cmsCreateXYZProfile();
       hLab    = cmsCreateLabProfile(NULL);


       if (Verbose) {

            printf("From: %s\n", cmsTakeProductName(hInput));
            printf("Desc: %s\n", cmsTakeProductDesc(hInput));
            if (hOutput) printf("To  : %s\n\n", cmsTakeProductName(hOutput));
       }

      
       dwIn  = BYTES_SH(2) | CHANNELS_SH(_cmsChannelsOf(InputColorSpace));
       dwOut = BYTES_SH(2) | CHANNELS_SH(_cmsChannelsOf(OutputColorSpace));
              
       switch (PrecalcMode) {
           
       case 0: dwFlags |= cmsFLAGS_NOTPRECALC; break;
       case 2: dwFlags |= cmsFLAGS_HIGHRESPRECALC; break;
	   case 3: dwFlags |= cmsFLAGS_LOWRESPRECALC; break;
	   case 1: break;

       default: FatalError("Unknown precalculation mode '%d'", PrecalcMode);
       }
       
       
       if (BlackPointCompensation) 
            dwFlags |= cmsFLAGS_BLACKPOINTCOMPENSATION;

       if (GamutCheck) {

            if (hProof == NULL)
                FatalError("I need proofing profile -p for gamut checking!");

            cmsSetAlarmCodes(0xFF, 0xFF, 0xFF);
            dwFlags |= cmsFLAGS_GAMUTCHECK;            
       }

       if (cmsGetDeviceClass(hInput) == icSigNamedColorClass) {
           dwIn = TYPE_NAMED_COLOR_INDEX;
       }

       hTrans     = cmsCreateProofingTransform(hInput,  dwIn,
                                               hOutput, dwOut,
                                               hProof,
                                               Intent, ProofingIntent, dwFlags);


       
       
       hTransXYZ = NULL; hTransLab = NULL;
       if (hOutput && Verbose) {

            hTransXYZ = cmsCreateTransform(hInput, dwIn,
                                      hXYZ,  TYPE_XYZ_16,
                                      Intent, cmsFLAGS_NOTPRECALC);

            hTransLab = cmsCreateTransform(hInput, dwIn,
                                      hLab,  TYPE_Lab_16,
                                      Intent, cmsFLAGS_NOTPRECALC);    
       }
       
}