Browse Source

- bugfix, identify ICC profileversion correctly

- bugfix, correct ICC profileversion correctly
master
Andreas Romeyke 1 year ago
parent
commit
1b32680ba1
2 changed files with 18 additions and 6 deletions
  1. +5
    -0
      src/check_icc_header.c
  2. +13
    -6
      src/cleanup_icc_header.c

+ 5
- 0
src/check_icc_header.c View File

@ -66,6 +66,11 @@ int parse_icc_header_v240_v430(unsigned long iccsize, char * iccdata, unsigned l
char profileversion[6]=" "; snprintf(profileversion, 6, "%i.%i.%i", (iccdata[8]) & 0x000f, ((iccdata[9] & 0x00f0) >>4), (iccdata[9] & 0x000f));
INFO("ICC: profileversion='%s'\n", profileversion);
// TODO: 2.4.0 or 4.3.0, others not allowed?
if (
(0 != strncmp("2.4.0", profileversion, 5)) &&
(0 != strncmp("4.3.0", profileversion, 5))
) FAIL("profile version ('%s') should be '2.4.0' or 4.3.0", profileversion);
/* -- */
char profileclass[5]=" "; memcpy(profileclass, &iccdata[12],4);
INFO("ICC: profileclass='%s'\n", profileclass);


+ 13
- 6
src/cleanup_icc_header.c View File

@ -14,20 +14,27 @@
/** corrects a ICC profile, fixes CMM type and/or fixes profile version */
char * correct_iccprofile(unsigned long iccsize, char * iccdata) {
int major=iccdata[8];
int minor=(iccdata[9]>>4) & 0x000f;
int bugfix= iccdata[9] & 0x000f;
if (FLAGGED == flag_be_verbose) printf("ICC profile: major=%i minor=%i bugfix=%i (iccdata [8]=%i [9]=%i [10]=%i [11]=%i)\n", major, minor, bugfix, iccdata[8], iccdata[9], iccdata[10], iccdata[11]);
if (/* fixes outdated ICC 2.xx profile versions */
(iccdata[8] == 2) && /* major version */
(iccdata[9] < 4) ) {
(major == 2) && /* major version */
(minor < 4) ) {
/* found 2.1/2.2/2.3 */
iccdata[9] = 4;
iccdata[9] = 4 << 4;
iccdata[10] = 0;
iccdata[11] = 0;
printf("Found outdated 2.xx profile version, try to correct it\n", iccdata[8], iccdata[9], iccdata[10], iccdata[11]);
} else if ( /* fixes outdated ICC 4.xx profile versions */
(iccdata[8] == 4) && /* major version */
(iccdata[9] < 3) ) {
(major == 4) && /* major version */
(minor < 3) ) {
/* found 4.0/4.1/4.2 */
iccdata[9] = 3;
iccdata[9] = 3 << 4;
iccdata[10] = 0;
iccdata[11] = 0;
printf("Found outdated 4.xx profile version, try to correct it\n");
}
/* fixes only wrong 'APPL ' -> 'appl ' in preferredcmmtype */
char preferredcmmtype[5]=" "; memcpy(preferredcmmtype, &iccdata[4],4);


Loading…
Cancel
Save