diff options
author | Philipp Lohmann <pl@openoffice.org> | 2008-01-10 14:39:13 +0000 |
---|---|---|
committer | Philipp Lohmann <pl@openoffice.org> | 2008-01-10 14:39:13 +0000 |
commit | 23d4ebbdcb5a0952132040bbd8f928083789210a (patch) | |
tree | e5cf2a1bc78fc4a0b3c0cd828359c7e71798ed98 /icc/source | |
parent | 9c4f6472dd4b1642ff3ce20ec1ae0430f850c660 (diff) |
#i81093# sRGB profile
Diffstat (limited to 'icc/source')
-rw-r--r-- | icc/source/create_sRGB_profile/create_sRGB_profile.cpp | 237 |
1 files changed, 124 insertions, 113 deletions
diff --git a/icc/source/create_sRGB_profile/create_sRGB_profile.cpp b/icc/source/create_sRGB_profile/create_sRGB_profile.cpp index eef7a8c9b96d..deece8cdede6 100644 --- a/icc/source/create_sRGB_profile/create_sRGB_profile.cpp +++ b/icc/source/create_sRGB_profile/create_sRGB_profile.cpp @@ -4,9 +4,9 @@ * * $RCSfile: create_sRGB_profile.cpp,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: beppec56 $ $Date: 2007-12-09 10:19:51 $ + * last change: $Author: pl $ $Date: 2008-01-10 15:39:13 $ Derived by beppec56@openoffice.org from various examples in SampleICC library, the original copyright retained. @@ -89,7 +89,7 @@ using namespace std; const char * const icc_file_name = "sRGB-IEC61966-2.1.icc"; const char * const hxx_file_name = "sRGB-IEC61966-2.1.hxx"; -const char * const this_file_name_and_location =" * external/icc/source/create_sRGB_profile/create_sRGB_profile.cpp"; +const char * const this_file_name_and_location =" * icc/source/create_sRGB_profile/create_sRGB_profile.cpp"; const char* const description = "sRGB IEC61966-2.1"; //const char* const devicemanufact = "IEC http://www.iec.ch"; not used, device manufactured by OOo seems funny... @@ -99,10 +99,10 @@ const char* const copyright = "The Contents of this file are made available subj // the creation date is fixed, corresponds to the last time this file has been changed // NOTE: change this date values whenever the data inside the profile are changed. const int data_last_changed_year = 2007; -const int data_last_changed_month = 8; -const int data_last_day = 31; -const int data_last_changed_hour = 14; -const int data_last_changed_minute = 9; +const int data_last_changed_month = 12; +const int data_last_day = 12; +const int data_last_changed_hour = 18; +const int data_last_changed_minute = 32; // the following string array it's the standard OOo header format const char * const TheHeader1[] = @@ -149,9 +149,12 @@ const char * const TheHeader2[] = "#define INCLUDED_ICC_SRGB_IEC61966_2_1_H", "", "/***********************************************************************", - " * this file is automatically generated by file", + " * NOTE:", + " * this file is automatically generated by running the program", + " * obtained building:", this_file_name_and_location, - " * modify that file if you need to change something", + " * contained in module icc", + " * modify that program if you need to change something.", " ***********************************************************************/", NULL // last string, a null }; @@ -162,7 +165,7 @@ const char * const TheTail[] = NULL }; -icFloatNumber computeIECRGBtoXYZ( icFloatNumber indata ) +icFloatNumber computeIEC_RGBtoXYZ( icFloatNumber indata ) { double retval = 0.0; if(indata < 0.04045) @@ -196,7 +199,7 @@ void dumpTag(FILE *outfile, CIccProfile *pIcc, icTagSignature sig) if (pTag) { fprintf(outfile, "\nContents of %s tag (%s)\n", Fmt.GetTagSigName(sig), icGetSig(buf, sig)); - fprintf(outfile,"outfile, Type: "); + fprintf(outfile,"Type: "); if (pTag->IsArrayType()) fprintf(outfile, "Array of "); @@ -279,34 +282,8 @@ int main(int argc, char* argv[]) try { - int N = 1024; // number of points in LUTs - const char* const out_file_pathname = icc_file_name; - icFloatNumber measuredBlack[3]; - icFloatNumber measuredWhite[3]; - - measuredBlack[0] = 0.0; - measuredBlack[1] = 0.0; - measuredBlack[2] = 0.0; - - measuredWhite[0] = 0.3127; - measuredWhite[1] = 0.3290; - measuredWhite[2] = 0.3583; - - icFloatNumber* redTRC = new icFloatNumber[N]; - icFloatNumber* greenTRC = new icFloatNumber[N]; - icFloatNumber* blueTRC = new icFloatNumber[N]; - int i; - for (i = 0; i < N; ++i) - { - // apply conversion from RGB to XYZ, moving the RGB value linearly from 0 to 100% - // 1024 steps are computed - redTRC[i] = computeIECRGBtoXYZ( (icFloatNumber)i/(N-1)); - greenTRC[i] = redTRC[i]; - blueTRC[i] = redTRC[i]; - } - CIccProfile profile; profile.InitHeader(); @@ -329,82 +306,57 @@ int main(int argc, char* argv[]) profile.m_Header.version=icVersionNumberV2_1; - // Required tags for a three-component matrix-based display profile, as layed - // out in the ICC spec [sections 8.2 and 8.4.3] are: - // profileDescriptionTag + // Required tags for a three-component matrix-based display profile, as laid + // out by specification ICC.1:1998-09 (clause 6.3) are: + // // copyrightTag - // mediaWhitePointTag - // chromaticAdaptationTag + // profileDescriptionTag // redMatrixColumnTag // greenMatrixColumnTag // blueMatrixColumnTag // redTRCTag // greenTRCTag // blueTRCTag + // mediaWhitePointTag - // profileDescriptionTag - CIccTagTextDescription* descriptionTag = new CIccTagTextDescription; - descriptionTag->SetText(description); - profile.AttachTag(icSigProfileDescriptionTag, descriptionTag); + // the other tags: + // + // technologyTag + // deviceModelTag + // deviceMfgDescTag + // mediaBlackPointTag + // viewingCondDescTag + // viewingConditionsTag + // luminanceTag + // measurementTag + // + // are optionals, added for completeness - //device model tag - CIccTagTextDescription* deviceModelTag = new CIccTagTextDescription; - deviceModelTag->SetText("IEC 61966-2.1 Default RGB colour space - sRGB "); - profile.AttachTag( icSigDeviceModelDescTag, deviceModelTag); + // the element below are sorted in the same order as + // the list above, but the LUT table, + // embedded at the end of the profile // copyrightTag CIccTagText* copyrightTag = new CIccTagText; copyrightTag->SetText(copyright); profile.AttachTag(icSigCopyrightTag, copyrightTag); - //device signature - CIccTagSignature* deviceSign = new CIccTagSignature; - deviceSign->SetValue( icSigCRTDisplay ); - profile.AttachTag( icSigTechnologyTag, deviceSign ); - - // For displays, and for projected imagery in cinema, we assume complete - // adaptation on the part of the viewer, and we treat the medium white - // as the illuminant. - icFloatNumber illuminantY = measuredWhite[1]; - icFloatNumber normalizedIlluminant[3]; - for (i = 0; i < 3; ++i) - normalizedIlluminant[i] = measuredWhite[i] / illuminantY; - CAT* CATToD50 = new CAT(icD50XYZ, normalizedIlluminant); - - icFloatNumber flare[3] = { 0, 0, 0 }; // perhaps oversimplified but... - - // mediaWhitePointTag - CIccTagXYZ* whitePointTag = new CIccTagXYZ; - icFloatNumber adaptedMediaWhite[3]; - CLUT::measuredXYZToAdaptedXYZ(adaptedMediaWhite, measuredWhite, - flare, illuminantY, CATToD50); - (*whitePointTag)[0].X = icDtoF(adaptedMediaWhite[0]); - (*whitePointTag)[0].Y = icDtoF(adaptedMediaWhite[1]); - (*whitePointTag)[0].Z = icDtoF(adaptedMediaWhite[2]); - profile.AttachTag(icSigMediaWhitePointTag, whitePointTag); - - // mediaBlackPointTag - CIccTagXYZ* blackPointTag = new CIccTagXYZ; - icFloatNumber adaptedMediaBlack[3]; - CLUT::measuredXYZToAdaptedXYZ(adaptedMediaBlack, measuredBlack, - flare, illuminantY, CATToD50); - (*blackPointTag)[0].X = icDtoF(adaptedMediaBlack[0]); - (*blackPointTag)[0].Y = icDtoF(adaptedMediaBlack[1]); - (*blackPointTag)[0].Z = icDtoF(adaptedMediaBlack[2]); - profile.AttachTag(icSigMediaBlackPointTag, blackPointTag); - // chromaticAdaptationTag - CIccTagS15Fixed16* chromaticAdaptationTag = CATToD50->makeChromaticAdaptationTag(); - profile.AttachTag(icSigChromaticAdaptationTag, chromaticAdaptationTag); + // profileDescriptionTag + CIccTagTextDescription* descriptionTag = new CIccTagTextDescription; + descriptionTag->SetText(description); + profile.AttachTag(icSigProfileDescriptionTag, descriptionTag); CIccTagXYZ* redMatrixColumnTag = new CIccTagXYZ; //values from raccomandation of ICC for sRGB, D50 referenced characterisation data - (*redMatrixColumnTag)[0].X = icDtoF(0.4360); + //should be: 0.4361, 0.2225, 0.0139 according to application notes, + // the 'X' value below is the one commonly in use on a very + // diffused sRGB profile + (*redMatrixColumnTag)[0].X = icDtoF(0.4361); (*redMatrixColumnTag)[0].Y = icDtoF(0.2225); (*redMatrixColumnTag)[0].Z = icDtoF(0.0139); profile.AttachTag(icSigRedMatrixColumnTag, redMatrixColumnTag); CIccTagXYZ* greenMatrixColumnTag = new CIccTagXYZ; - //values from raccomandation of ICC for sRGB, D50 referenced characterisation data (*greenMatrixColumnTag)[0].X = icDtoF(0.3851); (*greenMatrixColumnTag)[0].Y = icDtoF(0.7169); @@ -412,36 +364,95 @@ int main(int argc, char* argv[]) profile.AttachTag(icSigGreenMatrixColumnTag, greenMatrixColumnTag); CIccTagXYZ* blueMatrixColumnTag = new CIccTagXYZ; - //values from raccomandation of ICC for sRGB, D50 referenced characterisation data + //should be: 0.1431, 0.0606, 0.7139 according to application notes, + // the 'Z' value below is the one commonly in use on a very + // diffused sRGB profile (*blueMatrixColumnTag)[0].X = icDtoF(0.1431); (*blueMatrixColumnTag)[0].Y = icDtoF(0.0606); - (*blueMatrixColumnTag)[0].Z = icDtoF(0.7139); + (*blueMatrixColumnTag)[0].Z = icDtoF(0.7141); profile.AttachTag(icSigBlueMatrixColumnTag, blueMatrixColumnTag); - CIccTagCurve* redTRCTag = new CIccTagCurve(N); - if (N == 1) - redTRCTag->SetGamma(redTRC[0]); - else - for (i = 0; i < N; ++i) - (*redTRCTag)[i] = redTRC[i]; - profile.AttachTag(icSigRedTRCTag, redTRCTag); + // mediaWhitePointTag + CIccTagXYZ* whitePointTag = new CIccTagXYZ; + (*whitePointTag)[0].X = icDtoF(0.9505); + (*whitePointTag)[0].Y = icDtoF(1.0); + (*whitePointTag)[0].Z = icDtoF(1.0891); + profile.AttachTag(icSigMediaWhitePointTag, whitePointTag); - CIccTagCurve* greenTRCTag = new CIccTagCurve(N); - if (N == 1) - greenTRCTag->SetGamma(greenTRC[0]); - else - for (i = 0; i < N; ++i) - (*greenTRCTag)[i] = greenTRC[i]; - profile.AttachTag(icSigGreenTRCTag, greenTRCTag); + //device signature (technologytag) + CIccTagSignature* deviceSign = new CIccTagSignature; + deviceSign->SetValue( icSigCRTDisplay ); + profile.AttachTag( icSigTechnologyTag, deviceSign ); - CIccTagCurve* blueTRCTag = new CIccTagCurve(N); - if (N == 1) - blueTRCTag->SetGamma(blueTRC[0]); - else - for (i = 0; i < N; ++i) - (*blueTRCTag)[i] = blueTRC[i]; - profile.AttachTag(icSigBlueTRCTag, blueTRCTag); + //device model tag + CIccTagTextDescription* deviceModelTag = new CIccTagTextDescription; + deviceModelTag->SetText("IEC 61966-2.1 Default RGB colour space - sRGB"); + profile.AttachTag( icSigDeviceModelDescTag, deviceModelTag); + + // deviceMfgDescTag + CIccTagTextDescription* deviceMfgTag = new CIccTagTextDescription; + deviceMfgTag->SetText("IEC http://www.iec.ch"); + profile.AttachTag( icSigDeviceMfgDescTag, deviceMfgTag); + + // mediaBlackPointTag + CIccTagXYZ* blackPointTag = new CIccTagXYZ; + (*blackPointTag)[0].X = + (*blackPointTag)[0].Y = + (*blackPointTag)[0].Z = icDtoF(0.0); + profile.AttachTag(icSigMediaBlackPointTag, blackPointTag); + + // viewingCondDescTag + CIccTagTextDescription* viewingCondDescTag = new CIccTagTextDescription; + viewingCondDescTag->SetText("Reference viewing condition according to IEC 61966-2.1"); + profile.AttachTag( icSigViewingCondDescTag, viewingCondDescTag ); + + // viewingConditionsTag + CIccTagViewingConditions* viewingConditionsTag = new CIccTagViewingConditions; + // Illuminant tristimulus value + (*viewingConditionsTag).m_XYZIllum.X = icDtoF(19.6445); + (*viewingConditionsTag).m_XYZIllum.Y = icDtoF(20.3718); + (*viewingConditionsTag).m_XYZIllum.Z = icDtoF(16.8089); + // surround tristimulus value + (*viewingConditionsTag).m_XYZSurround.X = icDtoF(3.9289); + (*viewingConditionsTag).m_XYZSurround.Y = icDtoF(4.0744); + (*viewingConditionsTag).m_XYZSurround.Z = icDtoF(3.3618); + (*viewingConditionsTag).m_illumType = icIlluminantD50; + profile.AttachTag( icSigViewingConditionsType, viewingConditionsTag ); + + // luminanceTag + CIccTagXYZ* luminanceTag = new CIccTagXYZ; + (*luminanceTag)[0].X = icDtoF(76.0365); + (*luminanceTag)[0].Y = icDtoF(80.0); + (*luminanceTag)[0].Z = icDtoF(87.1246); + profile.AttachTag(icSigLuminanceTag, luminanceTag); + + // measurementTag + CIccTagMeasurement* measurementTag = new CIccTagMeasurement; + (*measurementTag).m_Data.stdObserver = icStdObs1931TwoDegrees; + (*measurementTag).m_Data.backing.X = + (*measurementTag).m_Data.backing.Y = + (*measurementTag).m_Data.backing.Z = icDtoF(0.0); + (*measurementTag).m_Data.geometry = icGeometryUnknown; + // the flare is 1%, but the library doesn't seem all right with this + // see specification ICC.1:1998-09, clause 6.5.8, table 55 fot the right + // format of the data value + (*measurementTag).m_Data.flare = static_cast< icMeasurementFlare > ( icDtoUF( 0.01 ) );//means 1% + (*measurementTag).m_Data.illuminant = icIlluminantD65; + profile.AttachTag(icSigMeasurementTag, measurementTag ); + + // compute the LUT curves, they are equal for all three colors + // so only one LUT is computed and stored + int N = 1024; // number of points in LUTs + CIccTagCurve* colorTRCTag = new CIccTagCurve(N); + // apply conversion from RGB to XYZ, stepping the RGB value linearly from 0 to 100% + // 1024 steps are computed + for (int i = 0; i < N; ++i) + (*colorTRCTag)[i] = computeIEC_RGBtoXYZ( (icFloatNumber)i/(N-1)); + + profile.AttachTag(icSigRedTRCTag, colorTRCTag); + profile.AttachTag(icSigGreenTRCTag, colorTRCTag); + profile.AttachTag(icSigBlueTRCTag, colorTRCTag); //Verify things string validationReport; |