Fix corrupted description and copyright in ICCProfileCreator (see #4478)

This commit is contained in:
Hombre
2018-07-10 01:36:05 +02:00
parent 7bd0971137
commit a3d6220bd8

View File

@@ -943,15 +943,13 @@ void ICCProfileCreator::savePressed()
if (profileVersion == "v2") { if (profileVersion == "v2") {
//write in tag 'dmdd' values of current gamma and slope to retrieve after in Output profile //write in tag 'dmdd' values of current gamma and slope to retrieve after in Output profile
wchar_t *wParameters = (wchar_t*)g_utf8_to_utf16 (sGammaSlopeParam.c_str(), -1, NULL, NULL, NULL); std::wostringstream wParameters;
if (!wParameters) { wParameters << sGammaSlopeParam;
printf("Error: wParameters / g_utf8_to_utf16 failed!\n");
}
cmsMLU *dmdd = cmsMLUalloc(nullptr, 1); cmsMLU *dmdd = cmsMLUalloc(nullptr, 1);
// Language code (3 letters code) : https://www.iso.org/obp/ui/ // Language code (3 letters code) : https://www.iso.org/obp/ui/
// Country code (3 letters code) : http://www.loc.gov/standards/iso639-2/php/code_list.php // Country code (3 letters code) : http://www.loc.gov/standards/iso639-2/php/code_list.php
if (cmsMLUsetWide(dmdd, "eng", "USA", wParameters)) { if (cmsMLUsetWide(dmdd, "eng", "USA", wParameters.str().c_str())) {
if (!cmsWriteTag(newProfile, cmsSigDeviceModelDescTag, dmdd)) { if (!cmsWriteTag(newProfile, cmsSigDeviceModelDescTag, dmdd)) {
printf("Error: Can't write cmsSigDeviceModelDescTag!\n"); printf("Error: Can't write cmsSigDeviceModelDescTag!\n");
} }
@@ -977,16 +975,15 @@ void ICCProfileCreator::savePressed()
sDescription = profileDesc; sDescription = profileDesc;
} }
} }
//write in tag 'dmdd' values of current gamma and slope to retrieve after in Output profile //write in tag 'dmdd' values of current gamma and slope to retrieve after in Output profile
wchar_t *wDescription = (wchar_t*)g_utf8_to_utf16 (sDescription.c_str(), -1, NULL, NULL, NULL); std::wostringstream wDescription;
if (!wDescription) { wDescription << sDescription;
printf("Error: wDescription / g_utf8_to_utf16 failed!\n");
}
cmsMLU *descMLU = cmsMLUalloc(nullptr, 1); cmsMLU *descMLU = cmsMLUalloc(nullptr, 1);
// Language code (3 letters code) : https://www.iso.org/obp/ui/ // Language code (3 letters code) : https://www.iso.org/obp/ui/
// Country code (3 letters code) : http://www.loc.gov/standards/iso639-2/php/code_list.php // Country code (3 letters code) : http://www.loc.gov/standards/iso639-2/php/code_list.php
if (cmsMLUsetWide(descMLU, "eng", "USA", wDescription)) { if (cmsMLUsetWide(descMLU, "eng", "USA", wDescription.str().c_str())) {
if (!cmsWriteTag(newProfile, cmsSigProfileDescriptionTag, descMLU)) { if (!cmsWriteTag(newProfile, cmsSigProfileDescriptionTag, descMLU)) {
printf("Error: Can't write cmsSigProfileDescriptionTag!\n"); printf("Error: Can't write cmsSigProfileDescriptionTag!\n");
} }
@@ -997,12 +994,11 @@ void ICCProfileCreator::savePressed()
// --------------- set cprt tag ------------------ // --------------- set cprt tag ------------------
std::wostringstream wCopyright;
wCopyright << copyright;
cmsMLU *copyMLU = cmsMLUalloc(nullptr, 1); cmsMLU *copyMLU = cmsMLUalloc(nullptr, 1);
wchar_t *wCopyright = (wchar_t*)g_utf8_to_utf16 (copyright.c_str(), -1, NULL, NULL, NULL); if (cmsMLUsetWide(copyMLU, "eng", "USA", wCopyright.str().c_str())) {
if (!wCopyright) {
printf("Error: wCopyright / g_utf8_to_utf16 failed!\n");
}
if (cmsMLUsetWide(copyMLU, "eng", "USA", wCopyright)) {
if (!cmsWriteTag(newProfile, cmsSigCopyrightTag, copyMLU)) { if (!cmsWriteTag(newProfile, cmsSigCopyrightTag, copyMLU)) {
printf("Error: Can't write cmsSigCopyrightTag!\n"); printf("Error: Can't write cmsSigCopyrightTag!\n");
} }