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); }
QString IccProfile::description() { if (!d) { return QString(); } if (!d->description.isNull()) { return d->description; } if (!open()) { return QString(); } LcmsLock lock; const char* desc = cmsTakeProductDesc(d->handle); if (desc && desc[0] != '\0') { d->description = QString::fromLatin1(desc); } return d->description; }
QString ScLcmsColorProfileImpl::productDescription() const { if (m_productDescription.isEmpty()) { if (m_profileHandle) { const char* desc = cmsTakeProductDesc(m_profileHandle); m_productDescription = QString(desc); return m_productDescription; } } return m_productDescription; }
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 }
static PyObject * pycms_GetProfileName (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", cmsTakeProductDesc(hProfile)); }
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); }
void TestKoLcmsColorProfile::testProfileCreationFromChromaticities() { #if 0 KoLcmsRGBColorProfile::Chromaticities chromaticities; chromaticities.primaries.Red.x = 0.7347f; chromaticities.primaries.Red.y = 0.2653f; chromaticities.primaries.Red.Y = 1.0f; chromaticities.primaries.Green.x = 0.1596f; chromaticities.primaries.Green.y = 0.8404f; chromaticities.primaries.Green.Y = 1.0f; chromaticities.primaries.Blue.x = 0.0366f; chromaticities.primaries.Blue.y = 0.0001f; chromaticities.primaries.Blue.Y = 1.0f; chromaticities.whitePoint.x = 0.34567f; chromaticities.whitePoint.y = 0.35850f; chromaticities.whitePoint.Y = 1.0f; qreal gamma = 1.75f; KoLcmsRGBColorProfile *profile = new KoLcmsRGBColorProfile(chromaticities, gamma); QVERIFY(profile != 0); QCOMPARE(profile->colorSpaceSignature(), icSigRgbData); cmsHPROFILE lcmsProfile = profile->lcmsProfile(); KoLcmsRGBColorProfile::Chromaticities profileChromaticities = KoLcmsRGBColorProfile::chromaticitiesFromProfile(lcmsProfile); QCOMPARE(testRounding(profileChromaticities.primaries.Red.x), testRounding(chromaticities.primaries.Red.x)); QCOMPARE(testRounding(profileChromaticities.primaries.Red.y), testRounding(chromaticities.primaries.Red.y)); QCOMPARE(testRounding(profileChromaticities.primaries.Green.x), testRounding(chromaticities.primaries.Green.x)); QCOMPARE(testRounding(profileChromaticities.primaries.Green.y), testRounding(chromaticities.primaries.Green.y)); QCOMPARE(testRounding(profileChromaticities.primaries.Blue.x), testRounding(chromaticities.primaries.Blue.x)); QCOMPARE(testRounding(profileChromaticities.primaries.Blue.y), testRounding(chromaticities.primaries.Blue.y)); QCOMPARE(testRounding(profileChromaticities.whitePoint.x), testRounding(chromaticities.whitePoint.x)); QCOMPARE(testRounding(profileChromaticities.whitePoint.y), testRounding(chromaticities.whitePoint.y)); LPGAMMATABLE redGamma = cmsReadICCGamma(lcmsProfile, icSigRedTRCTag); LPGAMMATABLE greenGamma = cmsReadICCGamma(lcmsProfile, icSigGreenTRCTag); LPGAMMATABLE blueGamma = cmsReadICCGamma(lcmsProfile, icSigBlueTRCTag); QCOMPARE(testRounding(cmsEstimateGamma(redGamma)), gamma); QCOMPARE(testRounding(cmsEstimateGamma(greenGamma)), gamma); QCOMPARE(testRounding(cmsEstimateGamma(blueGamma)), gamma); QString expectedProfileName = QString("lcms virtual RGB profile - R(%1, %2) G(%3, %4) B(%5, %6) W(%7, %8) gamma %9") .arg(chromaticities.primaries.Red.x) .arg(chromaticities.primaries.Red.y) .arg(chromaticities.primaries.Green.x) .arg(chromaticities.primaries.Green.y) .arg(chromaticities.primaries.Blue.x) .arg(chromaticities.primaries.Blue.y) .arg(chromaticities.whitePoint.x) .arg(chromaticities.whitePoint.y) .arg(gamma); QCOMPARE(profile->name(), expectedProfileName); QCOMPARE(QString(cmsTakeProductDesc(lcmsProfile)), expectedProfileName); profileChromaticities = profile->chromaticities(); QCOMPARE(profileChromaticities.primaries.Red.x, chromaticities.primaries.Red.x); QCOMPARE(profileChromaticities.primaries.Red.y, chromaticities.primaries.Red.y); QCOMPARE(profileChromaticities.primaries.Green.x, chromaticities.primaries.Green.x); QCOMPARE(profileChromaticities.primaries.Green.y, chromaticities.primaries.Green.y); QCOMPARE(profileChromaticities.primaries.Blue.x, chromaticities.primaries.Blue.x); QCOMPARE(profileChromaticities.primaries.Blue.y, chromaticities.primaries.Blue.y); QCOMPARE(profileChromaticities.whitePoint.x, chromaticities.whitePoint.x); QCOMPARE(profileChromaticities.whitePoint.y, chromaticities.whitePoint.y); const QString testProfileName = "Test Profile Name"; profile = new KoLcmsRGBColorProfile(chromaticities, gamma, testProfileName); lcmsProfile = profile->lcmsProfile(); QCOMPARE(profile->name(), testProfileName); QCOMPARE(QString(cmsTakeProductDesc(lcmsProfile)), testProfileName); #endif }
static PyObject* cms_profile_getattr_product_desc(CmsProfileObject* self, void* closure) { return PyUnicode_DecodeFSDefault(cmsTakeProductDesc(self->profile)); }
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; }
static gchar * lcms_icc_profile_get_desc (cmsHPROFILE profile) { return gimp_any_to_utf8 (cmsTakeProductDesc (profile), -1, NULL); }
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; }
void PDFExportDialog::updateDocOptions() { Opts.fileName = QDir::fromNativeSeparators(fileNameLineEdit->text()); Opts.doMultiFile = multiFile->isChecked(); Opts.Thumbnails = Options->CheckBox1->isChecked(); Opts.Compress = Options->Compression->isChecked(); Opts.CompressMethod = (PDFOptions::PDFCompression) Options->CMethod->currentIndex(); Opts.Quality = Options->CQuality->currentIndex(); Opts.Resolution = Options->Resolution->value(); Opts.EmbedList = Options->FontsToEmbed; Opts.SubsetList = Options->FontsToOutline; Opts.RecalcPic = Options->DSColor->isChecked(); Opts.PicRes = Options->ValC->value(); Opts.embedPDF = Options->EmbedPDF->isChecked(); Opts.Bookmarks = Options->CheckBM->isChecked(); Opts.Binding = Options->ComboBind->currentIndex(); Opts.MirrorH = Options->MirrorH->isChecked(); Opts.MirrorV = Options->MirrorV->isChecked(); Opts.doClip = Options->ClipMarg->isChecked(); Opts.RotateDeg = Options->RotateDeg->currentIndex() * 90; Opts.PresentMode = Options->CheckBox10->isChecked(); Opts.PresentVals = EffVal; Opts.Articles = Options->Article->isChecked(); Opts.Encrypt = Options->Encry->isChecked(); Opts.UseLPI = Options->UseLPI->isChecked(); Opts.useLayers = Options->useLayers->isChecked(); Opts.UseSpotColors = !Options->useSpot->isChecked(); Opts.displayBookmarks = Options->useBookmarks->isChecked(); Opts.displayFullscreen = Options->useFullScreen->isChecked(); Opts.displayLayers = Options->useLayers2->isChecked(); Opts.displayThumbs = Options->useThumbnails->isChecked(); Opts.hideMenuBar = Options->hideMenuBar->isChecked(); Opts.hideToolBar = Options->hideToolBar->isChecked(); Opts.fitWindow = Options->fitWindow->isChecked(); Opts.useDocBleeds = Options->docBleeds->isChecked(); if (!Options->docBleeds->isChecked()) { Opts.bleeds.Top = Options->BleedTop->value()/docUnitRatio; Opts.bleeds.Left = Options->BleedLeft->value()/docUnitRatio; Opts.bleeds.Right = Options->BleedRight->value()/docUnitRatio; Opts.bleeds.Bottom = Options->BleedBottom->value()/docUnitRatio; } Opts.markOffset = Options->markOffset->value()/docUnitRatio; Opts.cropMarks = Options->cropMarks->isChecked(); Opts.bleedMarks = Options->bleedMarks->isChecked(); Opts.registrationMarks = Options->registrationMarks->isChecked(); Opts.colorMarks = Options->colorMarks->isChecked(); Opts.docInfoMarks = Options->docInfoMarks->isChecked(); int pgl = PDFOptions::SinglePage; if (Options->singlePage->isChecked()) pgl = PDFOptions::SinglePage; else if (Options->continuousPages->isChecked()) pgl = PDFOptions::OneColumn; else if (Options->doublePageLeft->isChecked()) pgl = PDFOptions::TwoColumnLeft; else if (Options->doublePageRight->isChecked()) pgl = PDFOptions::TwoColumnRight; Opts.PageLayout = pgl; if (Options->actionCombo->currentIndex() != 0) Opts.openAction = Options->actionCombo->currentText(); else Opts.openAction = ""; if (Options->Encry->isChecked()) { int Perm = -64; if (Options->PDFVersionCombo->currentIndex() == 1) Perm &= ~0x00240000; if (Options->PrintSec->isChecked()) Perm += 4; if (Options->ModifySec->isChecked()) Perm += 8; if (Options->CopySec->isChecked()) Perm += 16; if (Options->AddSec->isChecked()) Perm += 32; Opts.Permissions = Perm; Opts.PassOwner = Options->PassOwner->text(); Opts.PassUser = Options->PassUser->text(); } if (Options->PDFVersionCombo->currentIndex() == 0) Opts.Version = PDFOptions::PDFVersion_13; if (Options->PDFVersionCombo->currentIndex() == 1) Opts.Version = PDFOptions::PDFVersion_14; if (Options->PDFVersionCombo->currentIndex() == 2) Opts.Version = PDFOptions::PDFVersion_15; if (Options->PDFVersionCombo->currentIndex() == 3) Opts.Version = PDFOptions::PDFVersion_X3; if (Options->OutCombo->currentIndex() == 0) { Opts.UseRGB = true; Opts.isGrayscale = false; Opts.UseProfiles = false; Opts.UseProfiles2 = false; } else { if (Options->OutCombo->currentIndex() == 2) { Opts.isGrayscale = true; Opts.UseRGB = false; Opts.UseProfiles = false; Opts.UseProfiles2 = false; } else { Opts.isGrayscale = false; Opts.UseRGB = false; if (doc->HasCMS) { Opts.UseProfiles = Options->EmbedProfs->isChecked(); Opts.UseProfiles2 = Options->EmbedProfs2->isChecked(); Opts.Intent = Options->IntendS->currentIndex(); Opts.Intent2 = Options->IntendI->currentIndex(); Opts.EmbeddedI = Options->NoEmbedded->isChecked(); Opts.SolidProf = Options->SolidPr->currentText(); Opts.ImageProf = Options->ImageP->currentText(); Opts.PrintProf = Options->PrintProfC->currentText(); if (Opts.Version == PDFOptions::PDFVersion_X3) { cmsHPROFILE hIn; QByteArray profilePath( appPrinterProfiles[Opts.PrintProf].toLocal8Bit() ); hIn = cmsOpenProfileFromFile(profilePath.data(), "r"); const char *Descriptor = cmsTakeProductDesc(hIn); cmsDescriptorName = QString(Descriptor); if (static_cast<int>(cmsGetColorSpace(hIn)) == icSigRgbData) components = 3; if (static_cast<int>(cmsGetColorSpace(hIn)) == icSigCmykData) components = 4; if (static_cast<int>(cmsGetColorSpace(hIn)) == icSigCmyData) components = 3; cmsCloseProfile(hIn); Opts.Info = Options->InfoString->text(); Opts.Encrypt = false; Opts.MirrorH = false; Opts.MirrorV = false; Opts.RotateDeg = 0; Opts.PresentMode = false; Opts.Encrypt = false; } } else { Opts.UseProfiles = false; Opts.UseProfiles2 = false; } } } }
QList<ScColorProfileInfo> ScLcmsColorMgmtEngineImpl::getAvailableProfileInfo(const QString& directory, bool recursive) { QList<ScColorProfileInfo> profileInfos; QDir d(directory, "*", QDir::Name, QDir::Files | QDir::Readable | QDir::Dirs | QDir::NoSymLinks); if ((!d.exists()) || (d.count() == 0)) return profileInfos; QString nam = ""; cmsHPROFILE hIn = NULL; for (uint dc = 0; dc < d.count(); ++dc) { QString file = d[dc]; if (file == "." || file == "..") continue; QFileInfo fi(directory + "/" + file); if (fi.isDir() && !recursive) continue; else if (fi.isDir() && !file.startsWith('.')) { QList<ScColorProfileInfo> profileInfos2 = getAvailableProfileInfo(fi.filePath()+"/", true); profileInfos.append(profileInfos2); continue; } ScColorProfileInfo profileInfo; profileInfo.file = fi.filePath(); QFile f(fi.filePath()); QByteArray bb(40, ' '); if (!f.open(QIODevice::ReadOnly)) { profileInfo.debug = QString("couldn't open %1 as color profile").arg(fi.filePath()); profileInfos.append(profileInfo); continue; } int len = f.read(bb.data(), 40); f.close(); if (len == 40 && bb[36] == 'a' && bb[37] == 'c' && bb[38] == 's' && bb[39] == 'p') { const QByteArray profilePath( QString(directory + "/" + file).toLocal8Bit() ); cmsSetErrorHandler(&cmsErrorHandler); try { hIn = cmsOpenProfileFromFile(profilePath.data(), "r"); if (hIn == NULL) continue; const char* profileDescriptor = cmsTakeProductDesc(hIn); profileInfo.description = QString(profileDescriptor); if (profileInfo.description.isEmpty()) { cmsCloseProfile(hIn); profileInfo.debug = QString("Color profile %1 is broken : no valid description").arg(fi.filePath()); profileInfos.append(profileInfo); continue; } profileInfo.colorSpace = translateLcmsColorSpaceType( cmsGetColorSpace(hIn) ); profileInfo.deviceClass = translateLcmsProfileClass( cmsGetDeviceClass(hIn) ); profileInfos.append(profileInfo); cmsCloseProfile(hIn); hIn = NULL; } catch (lcmsException&) { // Profile is broken if (hIn) { cmsCloseProfile(hIn); hIn = NULL; } profileInfo.debug = QString("Color profile %1 is broken").arg(fi.filePath()); profileInfos.append(profileInfo); } cmsSetErrorHandler(NULL); } } cmsSetErrorHandler(NULL); return profileInfos; }
bool ScImgDataLoader_JPEG::loadPicture(const QString& fn, int /*page*/, int res, bool thumbnail) { bool isCMYK = false; bool fromPS = false; float xres = 72.0, yres = 72.0; if (!QFile::exists(fn)) return false; ExifData ExifInf; struct jpeg_decompress_struct cinfo; struct my_error_mgr jerr; FILE *infile; cinfo.err = jpeg_std_error (&jerr.pub); jerr.pub.error_exit = my_error_exit; infile = NULL; initialize(); m_imageInfoRecord.type = ImageTypeJPG; m_imageInfoRecord.exifInfo.thumbnail = QImage(); if (setjmp (jerr.setjmp_buffer)) { jpeg_destroy_decompress (&cinfo); if (infile) fclose (infile); return false; } jpeg_create_decompress (&cinfo); if ((infile = fopen (fn.toLocal8Bit(), "rb")) == NULL) return false; jpeg_stdio_src(&cinfo, infile); jpeg_save_markers(&cinfo, ICC_MARKER, 0xFFFF); jpeg_save_markers(&cinfo, PHOTOSHOP_MARKER, 0xFFFF); jpeg_read_header(&cinfo, true); jpeg_start_decompress(&cinfo); bool exi = ExifInf.scan(fn); if ((exi) && (ExifInf.exifDataValid)) { if (cinfo.output_components == 4) m_imageInfoRecord.colorspace = ColorSpaceCMYK; else if (cinfo.output_components == 3) m_imageInfoRecord.colorspace = ColorSpaceRGB; else if (cinfo.output_components == 1) m_imageInfoRecord.colorspace = ColorSpaceGray; if ((!ExifInf.Thumbnail.isNull()) && thumbnail) { m_image = ExifInf.getThumbnail(); m_imageInfoRecord.exifInfo.thumbnail = ExifInf.getThumbnail(); if (cinfo.output_components == 4) { QRgb *s; unsigned char cc, cm, cy, ck; for( int yit=0; yit < m_image.height(); ++yit ) { s = (QRgb*)(m_image.scanLine( yit )); for(int xit=0; xit < m_image.width(); ++xit ) { cc = 255 - qRed(*s); cm = 255 - qGreen(*s); cy = 255 - qBlue(*s); ck = qMin(qMin(cc, cm), cy); *s = qRgba(cc-ck,cm-ck,cy-ck,ck); s++; } } } } else m_imageInfoRecord.exifInfo.thumbnail = QImage(); m_imageInfoRecord.exifInfo.cameraName = ExifInf.getCameraModel(); m_imageInfoRecord.exifInfo.cameraVendor = ExifInf.getCameraMake(); m_imageInfoRecord.exifInfo.comment = ExifInf.getComment(); m_imageInfoRecord.exifInfo.width = ExifInf.getWidth(); m_imageInfoRecord.exifInfo.height = ExifInf.getHeight(); m_imageInfoRecord.exifInfo.userComment = ExifInf.getUserComment(); m_imageInfoRecord.exifInfo.dateTime = ExifInf.getDateTime(); m_imageInfoRecord.exifInfo.ApertureFNumber = ExifInf.getApertureFNumber(); m_imageInfoRecord.exifInfo.ExposureTime = ExifInf.getExposureTime(); m_imageInfoRecord.exifInfo.ISOequivalent = ExifInf.getISOequivalent(); m_imageInfoRecord.exifDataValid = true; if (cinfo.density_unit == 0) { xres = 72; yres = 72; } else if ( cinfo.density_unit == 1 ) { xres = cinfo.X_density; yres = cinfo.Y_density; } else if ( cinfo.density_unit == 2 ) { xres = cinfo.X_density * 2.54; yres = cinfo.Y_density * 2.54; } if( xres <= 1.0 || yres <= 1.0 || xres > 3000.0 || yres > 3000.0 ) { xres = yres = 72.0; QFileInfo qfi(fn); m_message = QObject::tr("%1 may be corrupted : missing or wrong resolution tags").arg(qfi.fileName()); m_msgType = warningMsg; } m_imageInfoRecord.xres = qRound(xres); m_imageInfoRecord.yres = qRound(yres); m_imageInfoRecord.progressive = jpeg_has_multiple_scans(&cinfo); if ((!ExifInf.Thumbnail.isNull()) && thumbnail) { jpeg_destroy_decompress(&cinfo); fclose(infile); return true; } } else m_imageInfoRecord.exifDataValid = false; m_imageInfoRecord.exifInfo.thumbnail = QImage(); unsigned int EmbedLen = 0; unsigned char* EmbedBuffer; if (read_jpeg_marker(ICC_MARKER,&cinfo, &EmbedBuffer, &EmbedLen)) { const char *Descriptor; cmsHPROFILE prof = cmsOpenProfileFromMem(EmbedBuffer, EmbedLen); Descriptor = cmsTakeProductDesc(prof); m_embeddedProfile = QByteArray((const char*) EmbedBuffer, EmbedLen); m_imageInfoRecord.profileName = QString(Descriptor); m_imageInfoRecord.isEmbedded = true; free(EmbedBuffer); } else { m_imageInfoRecord.isEmbedded = false; m_imageInfoRecord.profileName = ""; } unsigned int PhotoshopLen = 0; unsigned char * PhotoshopBuffer; if (cinfo.density_unit == 0) { xres = 72; yres = 72; m_image.setDotsPerMeterX(2834); m_image.setDotsPerMeterY(2834); } else if ( cinfo.density_unit == 1 ) { xres = cinfo.X_density; yres = cinfo.Y_density; m_image.setDotsPerMeterX( int(100. * cinfo.X_density / 2.54) ); m_image.setDotsPerMeterY( int(100. * cinfo.Y_density / 2.54) ); } else if ( cinfo.density_unit == 2 ) { xres = cinfo.X_density * 2.54; yres = cinfo.Y_density * 2.54; m_image.setDotsPerMeterX( int(100. * cinfo.X_density) ); m_image.setDotsPerMeterY( int(100. * cinfo.Y_density) ); } if( xres <= 1.0 || yres <= 1.0 || xres > 3000.0 || yres > 3000.0 ) { xres = yres = 72.0; m_image.setDotsPerMeterX(2834); m_image.setDotsPerMeterY(2834); QFileInfo qfi(fn); m_message = QObject::tr("%1 may be corrupted : missing or wrong resolution tags").arg(qfi.fileName()); m_msgType = warningMsg; } m_imageInfoRecord.xres = qRound(xres); m_imageInfoRecord.yres = qRound(yres); if (cinfo.output_components == 4) { isCMYK = true; m_imageInfoRecord.colorspace = ColorSpaceCMYK; } else if (cinfo.output_components == 3) m_imageInfoRecord.colorspace = ColorSpaceRGB; else if (cinfo.output_components == 1) m_imageInfoRecord.colorspace = ColorSpaceGray; m_imageInfoRecord.progressive = jpeg_has_multiple_scans(&cinfo); if (read_jpeg_marker(PHOTOSHOP_MARKER,&cinfo, &PhotoshopBuffer, &PhotoshopLen) ) { if (PhotoshopLen != 0) { bool savEx = m_imageInfoRecord.exifDataValid; QByteArray arrayPhot(PhotoshopLen, ' '); arrayPhot = QByteArray::fromRawData((const char*)PhotoshopBuffer,PhotoshopLen); QDataStream strPhot(&arrayPhot,QIODevice::ReadOnly); strPhot.setByteOrder( QDataStream::BigEndian ); PSDHeader fakeHeader; fakeHeader.width = cinfo.output_width; fakeHeader.height = cinfo.output_height; if (cinfo.output_components == 4) m_imageInfoRecord.colorspace = ColorSpaceCMYK; else if (cinfo.output_components == 3) m_imageInfoRecord.colorspace = ColorSpaceRGB; else if (cinfo.output_components == 1) m_imageInfoRecord.colorspace = ColorSpaceGray; m_imageInfoRecord.progressive = jpeg_has_multiple_scans(&cinfo); parseRessourceData(strPhot, fakeHeader, PhotoshopLen); // Photoshop resolution is more accurate than jpeg header resolution xres = m_imageInfoRecord.xres; yres = m_imageInfoRecord.yres; m_image.setDotsPerMeterX( int(100. * m_imageInfoRecord.xres / 2.54) ); m_image.setDotsPerMeterY( int(100. * m_imageInfoRecord.yres / 2.54) ); if( xres <= 1.0 || yres <= 1.0 || xres > 3000.0 || yres > 3000.0 ) { xres = yres = 72.0; m_imageInfoRecord.xres = qRound(xres); m_imageInfoRecord.yres = qRound(yres); m_image.setDotsPerMeterX(2834); m_image.setDotsPerMeterY(2834); QFileInfo qfi(fn); m_message = QObject::tr("%1 may be corrupted : missing or wrong resolution tags").arg(qfi.fileName()); m_msgType = warningMsg; } if (m_imageInfoRecord.exifDataValid && thumbnail) { m_image = QImage(m_imageInfoRecord.exifInfo.width, m_imageInfoRecord.exifInfo.height, QImage::Format_ARGB32 ); m_imageInfoRecord.exifInfo.width = cinfo.output_width; m_imageInfoRecord.exifInfo.height = cinfo.output_height; if (cinfo.output_components == 4) { QRgb *d; QRgb *s; unsigned char cc, cm, cy, ck; for( int yit=0; yit < m_image.height(); ++yit ) { d = (QRgb*)(m_image.scanLine( yit )); s = (QRgb*)(m_imageInfoRecord.exifInfo.thumbnail.scanLine( yit )); for(int xit=0; xit < m_image.width(); ++xit ) { cc = 255 - qRed(*s); cm = 255 - qGreen(*s); cy = 255 - qBlue(*s); ck = qMin(qMin(cc, cm), cy); *d = qRgba(cc-ck,cm-ck,cy-ck,ck); s++; d++; } } } else m_image = m_imageInfoRecord.exifInfo.thumbnail.copy(); } m_imageInfoRecord.valid = (m_imageInfoRecord.PDSpathData.size())>0?true:false; // The only interest is vectormask arrayPhot.clear(); free( PhotoshopBuffer ); if (m_imageInfoRecord.exifDataValid && thumbnail) { jpeg_destroy_decompress(&cinfo); fclose(infile); return true; } m_imageInfoRecord.exifInfo.thumbnail = QImage(); m_imageInfoRecord.exifDataValid = savEx; fromPS = true; } } if ( cinfo.output_components == 3 || cinfo.output_components == 4) m_image = QImage( cinfo.output_width, cinfo.output_height, QImage::Format_ARGB32 ); else if ( cinfo.output_components == 1 ) { m_image = QImage( cinfo.output_width, cinfo.output_height, QImage::Format_Indexed8 ); m_image.setNumColors(256); for (int i=0; i<256; i++) m_image.setColor(i, qRgb(i,i,i)); } if (!m_image.isNull()) { uchar* data = m_image.bits(); int bpl = m_image.bytesPerLine(); while (cinfo.output_scanline < cinfo.output_height) { uchar *d = data + cinfo.output_scanline * bpl; (void) jpeg_read_scanlines(&cinfo, &d, 1); } if ( cinfo.output_components == 3 ) { uchar *in; QRgb *out; for (uint j=0; j<cinfo.output_height; j++) { in = m_image.scanLine(j) + cinfo.output_width * 3; out = (QRgb*) m_image.scanLine(j); for (uint i=cinfo.output_width; i--; ) { in -= 3; out[i] = qRgb(in[0], in[1], in[2]); } } } if ( cinfo.output_components == 4 ) { int method = 0; if (cinfo.jpeg_color_space == JCS_YCCK) method = 1; else if (fromPS) { if ((cinfo.jpeg_color_space == JCS_CMYK) && (cinfo.saw_Adobe_marker) && (cinfo.Adobe_transform == 0)) method = 2; } else if ((cinfo.jpeg_color_space == JCS_CMYK) && (cinfo.saw_Adobe_marker)) method = 1; QRgb *ptr; unsigned char c, m, y ,k; unsigned char *p; for (int i = 0; i < m_image.height(); i++) { ptr = (QRgb*) m_image.scanLine(i); if (method == 1) { for (int j = 0; j < m_image.width(); j++) { p = (unsigned char *) ptr; c = p[0]; m = p[1]; y = p[2]; k = p[3]; *ptr = qRgba(255 - c, 255 - m, 255 - y, 255 - k); ptr++; } } else if (method == 2) { for (int j = 0; j < m_image.width(); j++) { p = (unsigned char *) ptr; c = p[0]; m = p[1]; y = p[2]; k = p[3]; *ptr = qRgba(255 - c, 255 - m, 255 - y, k); ptr++; } } else { for (int j = 0; j < m_image.width(); j++) { p = (unsigned char *) ptr; c = p[0]; m = p[1]; y = p[2]; k = p[3]; *ptr = qRgba(y, m, c, k); ptr++; } } } isCMYK = true; } else isCMYK = false; if ( cinfo.output_components == 1 ) { QImage tmpImg = m_image.convertToFormat(QImage::Format_ARGB32); m_image = QImage( cinfo.output_width, cinfo.output_height, QImage::Format_ARGB32 ); QRgb *s; QRgb *d; for( int yi=0; yi < tmpImg.height(); ++yi ) { s = (QRgb*)(tmpImg.scanLine( yi )); d = (QRgb*)(m_image.scanLine( yi )); for(int xi=0; xi < tmpImg.width(); ++xi ) { (*d) = (*s); s++; d++; } } } } (void) jpeg_finish_decompress(&cinfo); fclose (infile); jpeg_destroy_decompress (&cinfo); m_imageInfoRecord.layerInfo.clear(); m_imageInfoRecord.BBoxX = 0; m_imageInfoRecord.BBoxH = m_image.height(); return (!m_image.isNull()); }
static PyObject *PDFfile_save(PDFfile *self) { if (!ScCore->primaryMainWindow()->HaveDoc) { PyErr_SetString(PyExc_SystemError, "Need to open document first"); return NULL; }; // copied from file scribus.cpp //void ScribusMainWindow::SaveAsPDF() int Components = 3; QString nam = ""; if (ScCore->primaryMainWindow()->bookmarkPalette->BView->topLevelItemCount() == 0) ScCore->primaryMainWindow()->doc->PDF_Options.Bookmarks = false; // apply fonts attribute ScCore->primaryMainWindow()->doc->PDF_Options.EmbedList.clear(); int n = PyList_Size(self->fonts); for ( int i=0; i<n; ++i){ QString tmpFon; tmpFon = QString(PyString_AsString(PyList_GetItem(self->fonts, i))); ScCore->primaryMainWindow()->doc->PDF_Options.EmbedList.append(tmpFon); } // apply file attribute QString fn; fn = QString(PyString_AsString(self->file)); ScCore->primaryMainWindow()->doc->PDF_Options.fileName = fn; // apply pages attribute std::vector<int> pageNs; int nn=PyList_Size(self->pages); for (int i = 0; i < nn; ++i) { pageNs.push_back((int)PyInt_AsLong(PyList_GetItem(self->pages, i))); } // apply thumbnails attribute ScCore->primaryMainWindow()->doc->PDF_Options.Thumbnails = self->thumbnails; // apply compress attribute self->compressmtd = minmaxi(self->compressmtd, 0, 3); ScCore->primaryMainWindow()->doc->PDF_Options.Compress = self->compress; ScCore->primaryMainWindow()->doc->PDF_Options.CompressMethod = (PDFOptions::PDFCompression) self->compressmtd; // apply quality attribute self->quality = minmaxi(self->quality, 0, 4); ScCore->primaryMainWindow()->doc->PDF_Options.Quality = self->quality; // apply resolusion attribute ScCore->primaryMainWindow()->doc->PDF_Options.Resolution = PyInt_AsLong(self->resolution); // apply downsample attribute ScCore->primaryMainWindow()->doc->PDF_Options.RecalcPic = PyInt_AsLong(self->downsample); if (ScCore->primaryMainWindow()->doc->PDF_Options.RecalcPic) ScCore->primaryMainWindow()->doc->PDF_Options.PicRes = PyInt_AsLong(self->downsample); else ScCore->primaryMainWindow()->doc->PDF_Options.PicRes = ScCore->primaryMainWindow()->doc->PDF_Options.Resolution; // apply bookmarks attribute ScCore->primaryMainWindow()->doc->PDF_Options.Bookmarks = self->bookmarks; // apply binding attribute ScCore->primaryMainWindow()->doc->PDF_Options.Binding = self->binding; // apply presentation attribute ScCore->primaryMainWindow()->doc->PDF_Options.PresentMode = self->presentation; QList<PDFPresentationData> PresentVals; PresentVals.clear(); int tmpnum; tmpnum=PyList_Size(self->effval); for (int i=0; i<tmpnum; ++i) { PDFPresentationData t; // How do I make this commented piece of code to work? // I always get an error here PyObject *ti = PyList_GetItem(self->effval, i); // if (!PyArg_ParseTuple(ti , "[iiiiii]", // &t.pageEffectDuration, &t.pageViewDuration, &t.effectType, &t.Dm, // &t.M, &t.Di)) { // PyErr_SetString(PyExc_SystemError, "while parsing 'effval'. WHY THIS HAPPENED????"); // return NULL; // } // PresentVals.append(t); // pv 10/03/2004 crashed when pt is null if (ti) { // Do I Need to check if every PyInt_AsLong and PyList_GetItem funtion succeed??? t.pageEffectDuration = PyInt_AsLong(PyList_GetItem(ti, 0)); t.pageViewDuration = PyInt_AsLong(PyList_GetItem(ti, 1)); t.effectType = PyInt_AsLong(PyList_GetItem(ti, 2)); t.Dm = PyInt_AsLong(PyList_GetItem(ti, 3)); t.M = PyInt_AsLong(PyList_GetItem(ti, 4)); t.Di = PyInt_AsLong(PyList_GetItem(ti, 5)); PresentVals.append(t); } // if ti=NULL } ScCore->primaryMainWindow()->doc->PDF_Options.PresentVals = PresentVals; // apply lpival int n2 = PyList_Size(self->lpival); for (int i=0; i<n2; ++i){ LPIData lpi; PyObject *t = PyList_GetItem(self->lpival, i); // This code always raise exception - WHY??? // char *s; // if (!PyArg_ParseTuple(t, "[siii]", &s, &lpi.Frequency, // &lpi.Angle, &lpi.SpotFunc)) { // PyErr_SetString(PyExc_SystemError, "while parsing 'lpival'. WHY THIS HAPPENED????"); // return NULL; // } // ScCore->primaryMainWindow()->doc->PDF_Options.LPISettings[QString(s)]=lpi; QString st; st = QString(PyString_AsString(PyList_GetItem(t,0))); lpi.Frequency = PyInt_AsLong(PyList_GetItem(t, 1)); lpi.Angle = PyInt_AsLong(PyList_GetItem(t, 2)); lpi.SpotFunc = PyInt_AsLong(PyList_GetItem(t, 3)); ScCore->primaryMainWindow()->doc->PDF_Options.LPISettings[st]=lpi; } ScCore->primaryMainWindow()->doc->PDF_Options.Articles = self->article; ScCore->primaryMainWindow()->doc->PDF_Options.Encrypt = self->encrypt; ScCore->primaryMainWindow()->doc->PDF_Options.UseLPI = self->uselpi; ScCore->primaryMainWindow()->doc->PDF_Options.UseSpotColors = self->usespot; ScCore->primaryMainWindow()->doc->PDF_Options.doMultiFile = self->domulti; self->version = minmaxi(self->version, 12, 14); // FIXME: Sanity check version ScCore->primaryMainWindow()->doc->PDF_Options.Version = (PDFOptions::PDFVersion)self->version; if (self->encrypt) { int Perm = -64; if (ScCore->primaryMainWindow()->doc->PDF_Options.Version == PDFOptions::PDFVersion_14) Perm &= ~0x00240000; if (self->aprint) Perm += 4; if (self->achange) Perm += 8; if (self->acopy) Perm += 16; if (self->aanot) Perm += 32; ScCore->primaryMainWindow()->doc->PDF_Options.Permissions = Perm; ScCore->primaryMainWindow()->doc->PDF_Options.PassOwner = QString(PyString_AsString(self->owner)); ScCore->primaryMainWindow()->doc->PDF_Options.PassUser = QString(PyString_AsString(self->user)); } if (self->outdst == 0) { ScCore->primaryMainWindow()->doc->PDF_Options.UseRGB = true; ScCore->primaryMainWindow()->doc->PDF_Options.UseProfiles = false; ScCore->primaryMainWindow()->doc->PDF_Options.UseProfiles2 = false; } else { ScCore->primaryMainWindow()->doc->PDF_Options.UseRGB = false; if (ScCore->primaryMainWindow()->doc->HasCMS) { ScCore->primaryMainWindow()->doc->PDF_Options.UseProfiles = self->profiles; ScCore->primaryMainWindow()->doc->PDF_Options.UseProfiles2 = self->profilei; self->intents = minmaxi(self->intents, 0, 3); ScCore->primaryMainWindow()->doc->PDF_Options.Intent = self->intents; self->intenti = minmaxi(self->intenti, 0, 3); ScCore->primaryMainWindow()->doc->PDF_Options.Intent2 = self->intenti; ScCore->primaryMainWindow()->doc->PDF_Options.EmbeddedI = self->noembicc; ScCore->primaryMainWindow()->doc->PDF_Options.SolidProf = PyString_AsString(self->solidpr); ScCore->primaryMainWindow()->doc->PDF_Options.ImageProf = PyString_AsString(self->imagepr); ScCore->primaryMainWindow()->doc->PDF_Options.PrintProf = PyString_AsString(self->printprofc); if (ScCore->primaryMainWindow()->doc->PDF_Options.Version == PDFOptions::PDFVersion_X3) { // Where does compiler find cms function when I have not included header for it const char *Descriptor; cmsHPROFILE hIn; hIn = cmsOpenProfileFromFile(ScCore->PrinterProfiles[ScCore->primaryMainWindow()->doc->PDF_Options.PrintProf].toLocal8Bit().constData(), "r"); Descriptor = cmsTakeProductDesc(hIn); nam = QString(Descriptor); if (static_cast<int>(cmsGetColorSpace(hIn)) == icSigRgbData) Components = 3; if (static_cast<int>(cmsGetColorSpace(hIn)) == icSigCmykData) Components = 4; if (static_cast<int>(cmsGetColorSpace(hIn)) == icSigCmyData) Components = 3; cmsCloseProfile(hIn); ScCore->primaryMainWindow()->doc->PDF_Options.Info = PyString_AsString(self->info); self->bleedt = minmaxd(self->bleedt, 0, ScCore->primaryMainWindow()->view->Doc->pageHeight*ScCore->primaryMainWindow()->view->Doc->unitRatio()); ScCore->primaryMainWindow()->doc->PDF_Options.bleeds.Top = self->bleedt/ScCore->primaryMainWindow()->view->Doc->unitRatio(); self->bleedl = minmaxd(self->bleedl, 0, ScCore->primaryMainWindow()->view->Doc->pageWidth*ScCore->primaryMainWindow()->view->Doc->unitRatio()); ScCore->primaryMainWindow()->doc->PDF_Options.bleeds.Left = self->bleedl/ScCore->primaryMainWindow()->view->Doc->unitRatio(); self->bleedr = minmaxd(self->bleedr, 0, ScCore->primaryMainWindow()->view->Doc->pageWidth*ScCore->primaryMainWindow()->view->Doc->unitRatio()); ScCore->primaryMainWindow()->doc->PDF_Options.bleeds.Right = self->bleedr/ScCore->primaryMainWindow()->view->Doc->unitRatio(); self->bleedb = minmaxd(self->bleedb, 0, ScCore->primaryMainWindow()->view->Doc->pageHeight*ScCore->primaryMainWindow()->view->Doc->unitRatio()); ScCore->primaryMainWindow()->doc->PDF_Options.bleeds.Bottom = self->bleedb/ScCore->primaryMainWindow()->view->Doc->unitRatio(); ScCore->primaryMainWindow()->doc->PDF_Options.Encrypt = false; ScCore->primaryMainWindow()->doc->PDF_Options.PresentMode = false; } } else { ScCore->primaryMainWindow()->doc->PDF_Options.UseProfiles = false; ScCore->primaryMainWindow()->doc->PDF_Options.UseProfiles2 = false; } } QMap<int,QPixmap> thumbs; for (uint ap = 0; ap < pageNs.size(); ++ap) { QPixmap pm(10,10); if (ScCore->primaryMainWindow()->doc->PDF_Options.Thumbnails) pm = QPixmap::fromImage(ScCore->primaryMainWindow()->view->PageToPixmap(pageNs[ap]-1, 100)); thumbs.insert(pageNs[ap], pm); } ReOrderText(ScCore->primaryMainWindow()->doc, ScCore->primaryMainWindow()->view); QString errorMessage; if (!ScCore->primaryMainWindow()->getPDFDriver(fn, nam, Components, pageNs, thumbs, errorMessage)) { fn = "Cannot write the File: " + fn; if (!errorMessage.isEmpty()) fn += QString("\n%1").arg(errorMessage); PyErr_SetString(PyExc_SystemError, fn.toAscii()); return NULL; } // Py_INCREF(Py_None); // return Py_None; Py_RETURN_NONE; }
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); } }