jdk/src/share/native/sun/java2d/cmm/lcms/cmsio0.c
changeset 2394 404cbe399601
parent 2392 738be5224b3f
child 2395 f5bcb8ee6555
equal deleted inserted replaced
2393:ea28f24e1708 2394:404cbe399601
    27 // However, the following notice accompanied the original version of this
    27 // However, the following notice accompanied the original version of this
    28 // file:
    28 // file:
    29 //
    29 //
    30 //
    30 //
    31 //  Little cms
    31 //  Little cms
    32 //  Copyright (C) 1998-2006 Marti Maria
    32 //  Copyright (C) 1998-2007 Marti Maria
    33 //
    33 //
    34 // Permission is hereby granted, free of charge, to any person obtaining
    34 // Permission is hereby granted, free of charge, to any person obtaining
    35 // a copy of this software and associated documentation files (the "Software"),
    35 // a copy of this software and associated documentation files (the "Software"),
    36 // to deal in the Software without restriction, including without limitation
    36 // to deal in the Software without restriction, including without limitation
    37 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
    37 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
    60 // Memory-based stream ---------------------------------------------------
    60 // Memory-based stream ---------------------------------------------------
    61 
    61 
    62 typedef struct {
    62 typedef struct {
    63                 LPBYTE Block;           // Points to allocated memory
    63                 LPBYTE Block;           // Points to allocated memory
    64                 size_t Size;            // Size of allocated memory
    64                 size_t Size;            // Size of allocated memory
    65                 int Pointer;            // Points to current location
    65                 size_t Pointer;         // Points to current location
    66                 int FreeBlockOnClose;   // As title
    66                 int FreeBlockOnClose;   // As title
    67 
    67 
    68                 } FILEMEM;
    68                 } FILEMEM;
    69 
    69 
    70 static
    70 static
    71 LPVOID MemoryOpen(LPBYTE Block, size_t Size, char Mode)
    71 LPVOID MemoryOpen(LPBYTE Block, size_t Size, char Mode)
    72 {
    72 {
    73     FILEMEM* fm = (FILEMEM*) malloc(sizeof(FILEMEM));
    73     FILEMEM* fm = (FILEMEM*) _cmsMalloc(sizeof(FILEMEM));
       
    74     if (fm == NULL) return NULL;
       
    75 
    74     ZeroMemory(fm, sizeof(FILEMEM));
    76     ZeroMemory(fm, sizeof(FILEMEM));
    75 
    77 
    76     if (Mode == 'r') {
    78     if (Mode == 'r') {
    77 
    79 
    78         fm ->Block   = (LPBYTE) malloc(Size);
    80         fm ->Block   = (LPBYTE) _cmsMalloc(Size);
    79         if (fm ->Block == NULL) {
    81         if (fm ->Block == NULL) {
    80             free(fm);
    82              _cmsFree(fm);
    81             return NULL;
    83             return NULL;
    82         }
    84         }
    83 
       
    84 
    85 
    85         CopyMemory(fm->Block, Block, Size);
    86         CopyMemory(fm->Block, Block, Size);
    86         fm ->FreeBlockOnClose = TRUE;
    87         fm ->FreeBlockOnClose = TRUE;
    87     }
    88     }
    88     else {
    89     else {
   101 size_t MemoryRead(LPVOID buffer, size_t size, size_t count, struct _lcms_iccprofile_struct* Icc)
   102 size_t MemoryRead(LPVOID buffer, size_t size, size_t count, struct _lcms_iccprofile_struct* Icc)
   102 {
   103 {
   103      FILEMEM* ResData = (FILEMEM*) Icc ->stream;
   104      FILEMEM* ResData = (FILEMEM*) Icc ->stream;
   104      LPBYTE Ptr;
   105      LPBYTE Ptr;
   105      size_t len = size * count;
   106      size_t len = size * count;
   106 
   107      size_t extent = ResData -> Pointer + len;
   107 
   108 
   108      if (ResData -> Pointer + len > ResData -> Size){
   109         if (len == 0) {
       
   110                 return 0;
       
   111         }
       
   112 
       
   113         if (len / size != count) {
       
   114           cmsSignalError(LCMS_ERRC_ABORTED, "Read from memory error. Integer overflow with count / size.");
       
   115           return 0;
       
   116       }
       
   117 
       
   118       if (extent < len || extent < ResData -> Pointer) {
       
   119           cmsSignalError(LCMS_ERRC_ABORTED, "Read from memory error. Integer overflow with len.");
       
   120           return 0;
       
   121       }
       
   122 
       
   123       if (ResData -> Pointer + len > ResData -> Size) {
   109 
   124 
   110          len = (ResData -> Size - ResData -> Pointer);
   125          len = (ResData -> Size - ResData -> Pointer);
   111          cmsSignalError(LCMS_ERRC_WARNING, "Read from memory error. Got %d bytes, block should be of %d bytes", len * size, count * size);
   126          cmsSignalError(LCMS_ERRC_ABORTED, "Read from memory error. Got %d bytes, block should be of %d bytes", len * size, count * size);
   112 
   127          return 0;
   113      }
   128      }
   114 
   129 
   115     Ptr  = ResData -> Block;
   130     Ptr  = ResData -> Block;
   116     Ptr += ResData -> Pointer;
   131     Ptr += ResData -> Pointer;
   117     CopyMemory(buffer, Ptr, len);
   132     CopyMemory(buffer, Ptr, len);
   121 }
   136 }
   122 
   137 
   123 // SEEK_CUR is assumed
   138 // SEEK_CUR is assumed
   124 
   139 
   125 static
   140 static
   126 BOOL MemorySeek(struct _lcms_iccprofile_struct* Icc, size_t offset)
   141 LCMSBOOL MemorySeek(struct _lcms_iccprofile_struct* Icc, size_t offset)
   127 {
   142 {
   128     FILEMEM* ResData = (FILEMEM*) Icc ->stream;
   143     FILEMEM* ResData = (FILEMEM*) Icc ->stream;
   129 
   144 
   130     if (offset > ResData ->Size) {
   145     if (offset > ResData ->Size) {
   131          cmsSignalError(LCMS_ERRC_ABORTED,  "Pointer error; probably corrupted file");
   146          cmsSignalError(LCMS_ERRC_ABORTED,  "Pointer error; probably corrupted file");
   145 
   160 
   146     return ResData -> Pointer;
   161     return ResData -> Pointer;
   147 }
   162 }
   148 
   163 
   149 
   164 
   150 // Writes data to memory, also keeps used space for further reference
   165 // Writes data to memory, also keeps used space for further reference. NO CHECK IS PERFORMED
   151 
   166 
   152 static
   167 static
   153 BOOL MemoryWrite(struct _lcms_iccprofile_struct* Icc, size_t size, void *Ptr)
   168 LCMSBOOL MemoryWrite(struct _lcms_iccprofile_struct* Icc, size_t size, void *Ptr)
   154 {
   169 {
   155         FILEMEM* ResData = (FILEMEM*) Icc ->stream;
   170         FILEMEM* ResData = (FILEMEM*) Icc ->stream;
   156 
   171 
   157        if (size == 0) return TRUE;
   172        if (size == 0) return TRUE;
   158 
   173 
   165        return TRUE;
   180        return TRUE;
   166 }
   181 }
   167 
   182 
   168 
   183 
   169 static
   184 static
   170 BOOL MemoryGrow(struct _lcms_iccprofile_struct* Icc, size_t size)
   185 LCMSBOOL MemoryGrow(struct _lcms_iccprofile_struct* Icc, size_t size)
   171 {
   186 {
   172     FILEMEM* ResData = (FILEMEM*) Icc->stream;
   187     FILEMEM* ResData = (FILEMEM*) Icc->stream;
   173 
   188 
   174     void* newBlock = realloc(ResData->Block, ResData->Size + size);
   189     void* newBlock = NULL;
       
   190 
       
   191     /* Follow same policies as functions in lcms.h  */
       
   192     if (ResData->Size + size < 0) return NULL;
       
   193     if (ResData->Size + size > (size_t)1024*1024*500))) return NULL;
       
   194 
       
   195     newBlock = realloc(ResData->Block, ResData->Size + size);
   175 
   196 
   176     if (!newBlock) {
   197     if (!newBlock) {
   177         return FALSE;
   198         return FALSE;
   178     }
   199     }
   179     ResData->Block = newBlock;
   200     ResData->Block = newBlock;
   181     return TRUE;
   202     return TRUE;
   182 }
   203 }
   183 
   204 
   184 
   205 
   185 static
   206 static
   186 BOOL MemoryClose(struct _lcms_iccprofile_struct* Icc)
   207 LCMSBOOL MemoryClose(struct _lcms_iccprofile_struct* Icc)
   187 {
   208 {
   188     FILEMEM* ResData = (FILEMEM*) Icc ->stream;
   209     FILEMEM* ResData = (FILEMEM*) Icc ->stream;
   189 
   210 
   190     if (ResData ->FreeBlockOnClose) {
   211     if (ResData ->FreeBlockOnClose) {
   191 
   212 
   192         if (ResData ->Block) free(ResData ->Block);
   213         if (ResData ->Block)  _cmsFree(ResData ->Block);
   193     }
   214     }
   194     free(ResData);
   215      _cmsFree(ResData);
   195     return 0;
   216     return 0;
   196 }
   217 }
   197 
   218 
   198 
   219 
   199 // File-based stream -------------------------------------------------------
   220 // File-based stream -------------------------------------------------------
   207 static
   228 static
   208 size_t FileRead(void *buffer, size_t size, size_t count, struct _lcms_iccprofile_struct* Icc)
   229 size_t FileRead(void *buffer, size_t size, size_t count, struct _lcms_iccprofile_struct* Icc)
   209 {
   230 {
   210     size_t nReaded = fread(buffer, size, count, (FILE*) Icc->stream);
   231     size_t nReaded = fread(buffer, size, count, (FILE*) Icc->stream);
   211     if (nReaded != count) {
   232     if (nReaded != count) {
   212             cmsSignalError(LCMS_ERRC_WARNING, "Read error. Got %d bytes, block should be of %d bytes", nReaded * size, count * size);
   233             cmsSignalError(LCMS_ERRC_ABORTED, "Read error. Got %d bytes, block should be of %d bytes", nReaded * size, count * size);
   213             return 0;
   234             return 0;
   214     }
   235     }
   215 
   236 
   216     return nReaded;
   237     return nReaded;
   217 }
   238 }
   218 
   239 
   219 
   240 
   220 static
   241 static
   221 BOOL FileSeek(struct _lcms_iccprofile_struct* Icc, size_t offset)
   242 LCMSBOOL FileSeek(struct _lcms_iccprofile_struct* Icc, size_t offset)
   222 {
   243 {
   223     if (fseek((FILE*) Icc ->stream, (long) offset, SEEK_SET) != 0) {
   244     if (fseek((FILE*) Icc ->stream, (long) offset, SEEK_SET) != 0) {
   224 
   245 
   225        cmsSignalError(LCMS_ERRC_ABORTED, "Seek error; probably corrupted file");
   246        cmsSignalError(LCMS_ERRC_ABORTED, "Seek error; probably corrupted file");
   226        return TRUE;
   247        return TRUE;
   238 
   259 
   239 // Writes data to stream, also keeps used space for further reference
   260 // Writes data to stream, also keeps used space for further reference
   240 
   261 
   241 
   262 
   242 static
   263 static
   243 BOOL FileWrite(struct _lcms_iccprofile_struct* Icc, size_t size, LPVOID Ptr)
   264 LCMSBOOL FileWrite(struct _lcms_iccprofile_struct* Icc, size_t size, LPVOID Ptr)
   244 {
   265 {
   245        if (size == 0) return TRUE;
   266        if (size == 0) return TRUE;
   246 
   267 
   247        Icc->UsedSpace += size;
   268        Icc->UsedSpace += size;
   248 
   269 
   254        return (fwrite(Ptr, size, 1, (FILE*) Icc->stream) == 1);
   275        return (fwrite(Ptr, size, 1, (FILE*) Icc->stream) == 1);
   255 }
   276 }
   256 
   277 
   257 
   278 
   258 static
   279 static
   259 BOOL FileGrow(struct _lcms_iccprofile_struct* Icc, size_t size)
   280 LCMSBOOL FileGrow(struct _lcms_iccprofile_struct* Icc, size_t size)
   260 {
   281 {
   261   return TRUE;
   282   return TRUE;
   262 }
   283 }
   263 
   284 
   264 
   285 
   265 static
   286 static
   266 BOOL FileClose(struct _lcms_iccprofile_struct* Icc)
   287 LCMSBOOL FileClose(struct _lcms_iccprofile_struct* Icc)
   267 {
   288 {
   268     return fclose((FILE*) Icc ->stream);
   289     return fclose((FILE*) Icc ->stream);
   269 }
   290 }
   270 
   291 
   271 // ----------------------------------------------------------------------------------------------------
   292 // ----------------------------------------------------------------------------------------------------
   274 // Creates an empty structure holding all required parameters
   295 // Creates an empty structure holding all required parameters
   275 
   296 
   276 cmsHPROFILE _cmsCreateProfilePlaceholder(void)
   297 cmsHPROFILE _cmsCreateProfilePlaceholder(void)
   277 {
   298 {
   278 
   299 
   279     LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) malloc(sizeof(LCMSICCPROFILE));
   300     LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) _cmsMalloc(sizeof(LCMSICCPROFILE));
   280     if (Icc == NULL) return NULL;
   301     if (Icc == NULL) return NULL;
   281 
   302 
   282     // Empty values
   303     // Empty values
   283     ZeroMemory(Icc, sizeof(LCMSICCPROFILE));
   304     ZeroMemory(Icc, sizeof(LCMSICCPROFILE));
   284 
   305 
   312 
   333 
   313 
   334 
   314 // Search for a specific tag in tag dictionary
   335 // Search for a specific tag in tag dictionary
   315 // Returns position or -1 if tag not found
   336 // Returns position or -1 if tag not found
   316 
   337 
   317 icInt32Number _cmsSearchTag(LPLCMSICCPROFILE Profile, icTagSignature sig, BOOL lSignalError)
   338 icInt32Number _cmsSearchTag(LPLCMSICCPROFILE Profile, icTagSignature sig, LCMSBOOL lSignalError)
   318 {
   339 {
   319        icInt32Number i;
   340        icInt32Number i;
   320 
   341 
   321        if (sig == 0) return -1;     // 0 identifies a special tag holding raw memory.
   342        if (sig == 0) return -1;     // 0 identifies a special tag holding raw memory.
   322 
   343 
   333 }
   354 }
   334 
   355 
   335 
   356 
   336 // Check existance
   357 // Check existance
   337 
   358 
   338 BOOL LCMSEXPORT cmsIsTag(cmsHPROFILE hProfile, icTagSignature sig)
   359 LCMSBOOL LCMSEXPORT cmsIsTag(cmsHPROFILE hProfile, icTagSignature sig)
   339 {
   360 {
   340        LPLCMSICCPROFILE  Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile;
   361        LPLCMSICCPROFILE  Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile;
   341        return _cmsSearchTag(Icc, sig, FALSE) >= 0;
   362        return _cmsSearchTag(Icc, sig, FALSE) >= 0;
   342 }
   363 }
   343 
   364 
   352 
   373 
   353     i = _cmsSearchTag(Icc, sig, FALSE);
   374     i = _cmsSearchTag(Icc, sig, FALSE);
   354 
   375 
   355     if (i >=0) {
   376     if (i >=0) {
   356 
   377 
   357         if (Icc -> TagPtrs[i]) free(Icc -> TagPtrs[i]);
   378         if (Icc -> TagPtrs[i]) _cmsFree(Icc -> TagPtrs[i]);
   358     }
   379     }
   359     else  {
   380     else  {
   360 
   381 
   361         i = Icc -> TagCount;
   382         i = Icc -> TagCount;
   362         Icc -> TagCount++;
   383         Icc -> TagCount++;
   363 
   384 
   364         if (Icc ->TagCount >= MAX_TABLE_TAG) {
   385         if (Icc ->TagCount >= MAX_TABLE_TAG) {
   365 
   386 
   366             cmsSignalError(LCMS_ERRC_ABORTED, "Too many tags (%d)", MAX_TABLE_TAG);
   387             cmsSignalError(LCMS_ERRC_ABORTED, "Too many tags (%d)", MAX_TABLE_TAG);
   367             Icc ->TagCount = MAX_TABLE_TAG-1;
   388             Icc ->TagCount = MAX_TABLE_TAG-1;
       
   389             return NULL;
   368         }
   390         }
   369     }
   391     }
   370 
   392 
   371 
   393 
   372     Ptr = malloc(size);
   394     Ptr = _cmsMalloc(size);
       
   395     if (Ptr == NULL) return NULL;
       
   396 
   373     CopyMemory(Ptr, Init, size);
   397     CopyMemory(Ptr, Init, size);
   374 
   398 
   375     Icc ->TagNames[i] = sig;
   399     Icc ->TagNames[i] = sig;
   376     Icc ->TagSizes[i] = size;
   400     Icc ->TagSizes[i] = size;
   377     Icc ->TagPtrs[i]  = Ptr;
   401     Icc ->TagPtrs[i]  = Ptr;
   398 
   422 
   399     NewIcc = (LPLCMSICCPROFILE) _cmsCreateProfilePlaceholder();
   423     NewIcc = (LPLCMSICCPROFILE) _cmsCreateProfilePlaceholder();
   400     if (NewIcc == NULL) return NULL;
   424     if (NewIcc == NULL) return NULL;
   401 
   425 
   402     strncpy(NewIcc -> PhysicalFile, FileName, MAX_PATH-1);
   426     strncpy(NewIcc -> PhysicalFile, FileName, MAX_PATH-1);
       
   427     NewIcc -> PhysicalFile[MAX_PATH-1] = 0;
       
   428 
   403     NewIcc ->stream = ICCfile;
   429     NewIcc ->stream = ICCfile;
   404 
   430 
   405     NewIcc ->Read  = FileRead;
   431     NewIcc ->Read  = FileRead;
   406     NewIcc ->Seek  = FileSeek;
   432     NewIcc ->Seek  = FileSeek;
   407     NewIcc ->Tell  = FileTell;
   433     NewIcc ->Tell  = FileTell;
   500 // ----------------------------------------------------------------------- Set/Get several struct members
   526 // ----------------------------------------------------------------------- Set/Get several struct members
   501 
   527 
   502 
   528 
   503 
   529 
   504 
   530 
   505 BOOL LCMSEXPORT cmsTakeMediaWhitePoint(LPcmsCIEXYZ Dest, cmsHPROFILE hProfile)
   531 LCMSBOOL LCMSEXPORT cmsTakeMediaWhitePoint(LPcmsCIEXYZ Dest, cmsHPROFILE hProfile)
   506 {
   532 {
   507      LPLCMSICCPROFILE    Icc = (LPLCMSICCPROFILE) hProfile;
   533      LPLCMSICCPROFILE    Icc = (LPLCMSICCPROFILE) hProfile;
   508      *Dest = Icc -> MediaWhitePoint;
   534      *Dest = Icc -> MediaWhitePoint;
   509      return TRUE;
   535      return TRUE;
   510 }
   536 }
   511 
   537 
   512 
   538 
   513 BOOL LCMSEXPORT cmsTakeMediaBlackPoint(LPcmsCIEXYZ Dest, cmsHPROFILE hProfile)
   539 LCMSBOOL LCMSEXPORT cmsTakeMediaBlackPoint(LPcmsCIEXYZ Dest, cmsHPROFILE hProfile)
   514 {
   540 {
   515       LPLCMSICCPROFILE    Icc = (LPLCMSICCPROFILE) hProfile;
   541       LPLCMSICCPROFILE    Icc = (LPLCMSICCPROFILE) hProfile;
   516       *Dest = Icc -> MediaBlackPoint;
   542       *Dest = Icc -> MediaBlackPoint;
   517       return TRUE;
   543       return TRUE;
   518 }
   544 }
   519 
   545 
   520 BOOL  LCMSEXPORT cmsTakeIluminant(LPcmsCIEXYZ Dest, cmsHPROFILE hProfile)
   546 LCMSBOOL  LCMSEXPORT cmsTakeIluminant(LPcmsCIEXYZ Dest, cmsHPROFILE hProfile)
   521 {
   547 {
   522        LPLCMSICCPROFILE  Icc = (LPLCMSICCPROFILE) hProfile;
   548        LPLCMSICCPROFILE  Icc = (LPLCMSICCPROFILE) hProfile;
   523        *Dest = Icc -> Illuminant;
   549        *Dest = Icc -> Illuminant;
   524        return TRUE;
   550        return TRUE;
   525 }
   551 }
   573     LPLCMSICCPROFILE  Icc = (LPLCMSICCPROFILE) hProfile;
   599     LPLCMSICCPROFILE  Icc = (LPLCMSICCPROFILE) hProfile;
   574     CopyMemory(Icc -> ProfileID, ProfileID, 16);
   600     CopyMemory(Icc -> ProfileID, ProfileID, 16);
   575 }
   601 }
   576 
   602 
   577 
   603 
   578 BOOL LCMSEXPORT cmsTakeCreationDateTime(struct tm *Dest, cmsHPROFILE hProfile)
   604 LCMSBOOL LCMSEXPORT cmsTakeCreationDateTime(struct tm *Dest, cmsHPROFILE hProfile)
   579 {
   605 {
   580     LPLCMSICCPROFILE  Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile;
   606     LPLCMSICCPROFILE  Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile;
   581     CopyMemory(Dest, &Icc ->Created, sizeof(struct tm));
   607     CopyMemory(Dest, &Icc ->Created, sizeof(struct tm));
   582     return TRUE;
   608     return TRUE;
   583 }
   609 }
   594 {
   620 {
   595        LPLCMSICCPROFILE  Icc = (LPLCMSICCPROFILE) hProfile;
   621        LPLCMSICCPROFILE  Icc = (LPLCMSICCPROFILE) hProfile;
   596        Icc -> PCS = pcs;
   622        Icc -> PCS = pcs;
   597 }
   623 }
   598 
   624 
   599 
       
   600 
       
   601 icColorSpaceSignature LCMSEXPORT cmsGetColorSpace(cmsHPROFILE hProfile)
   625 icColorSpaceSignature LCMSEXPORT cmsGetColorSpace(cmsHPROFILE hProfile)
   602 {
   626 {
   603        LPLCMSICCPROFILE  Icc = (LPLCMSICCPROFILE) hProfile;
   627        LPLCMSICCPROFILE  Icc = (LPLCMSICCPROFILE) hProfile;
   604        return Icc -> ColorSpace;
   628        return Icc -> ColorSpace;
   605 }
   629 }
   606 
   630 
   607 
       
   608 
       
   609 void LCMSEXPORT cmsSetColorSpace(cmsHPROFILE hProfile, icColorSpaceSignature sig)
   631 void LCMSEXPORT cmsSetColorSpace(cmsHPROFILE hProfile, icColorSpaceSignature sig)
   610 {
   632 {
   611        LPLCMSICCPROFILE  Icc = (LPLCMSICCPROFILE) hProfile;
   633        LPLCMSICCPROFILE  Icc = (LPLCMSICCPROFILE) hProfile;
   612        Icc -> ColorSpace = sig;
   634        Icc -> ColorSpace = sig;
   613 }
   635 }
   614 
   636 
   615 
       
   616 icProfileClassSignature LCMSEXPORT cmsGetDeviceClass(cmsHPROFILE hProfile)
   637 icProfileClassSignature LCMSEXPORT cmsGetDeviceClass(cmsHPROFILE hProfile)
   617 {
   638 {
   618        LPLCMSICCPROFILE  Icc = (LPLCMSICCPROFILE) hProfile;
   639        LPLCMSICCPROFILE  Icc = (LPLCMSICCPROFILE) hProfile;
   619        return Icc -> DeviceClass;
   640        return Icc -> DeviceClass;
   620 }
   641 }
   622 DWORD LCMSEXPORT cmsGetProfileICCversion(cmsHPROFILE hProfile)
   643 DWORD LCMSEXPORT cmsGetProfileICCversion(cmsHPROFILE hProfile)
   623 {
   644 {
   624        LPLCMSICCPROFILE  Icc = (LPLCMSICCPROFILE) hProfile;
   645        LPLCMSICCPROFILE  Icc = (LPLCMSICCPROFILE) hProfile;
   625        return (DWORD) Icc -> Version;
   646        return (DWORD) Icc -> Version;
   626 }
   647 }
   627 
       
   628 
   648 
   629 void LCMSEXPORT cmsSetProfileICCversion(cmsHPROFILE hProfile, DWORD Version)
   649 void LCMSEXPORT cmsSetProfileICCversion(cmsHPROFILE hProfile, DWORD Version)
   630 {
   650 {
   631    LPLCMSICCPROFILE  Icc = (LPLCMSICCPROFILE) hProfile;
   651    LPLCMSICCPROFILE  Icc = (LPLCMSICCPROFILE) hProfile;
   632    Icc -> Version = Version;
   652    Icc -> Version = Version;
   662 
   682 
   663 }
   683 }
   664 
   684 
   665 // This is tricky, since LUT structs does have pointers
   685 // This is tricky, since LUT structs does have pointers
   666 
   686 
   667 BOOL LCMSEXPORT _cmsAddLUTTag(cmsHPROFILE hProfile, icTagSignature sig, const void* lut)
   687 LCMSBOOL LCMSEXPORT _cmsAddLUTTag(cmsHPROFILE hProfile, icTagSignature sig, const void* lut)
   668 {
   688 {
   669        LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile;
   689        LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile;
   670        LPLUT Orig, Stored;
   690        LPLUT Orig, Stored;
   671        unsigned int i;
   691        unsigned int i;
   672 
   692 
   690        Stored ->CLut16params.p8 = NULL;
   710        Stored ->CLut16params.p8 = NULL;
   691        return TRUE;
   711        return TRUE;
   692 }
   712 }
   693 
   713 
   694 
   714 
   695 BOOL LCMSEXPORT _cmsAddXYZTag(cmsHPROFILE hProfile, icTagSignature sig, const cmsCIEXYZ* XYZ)
   715 LCMSBOOL LCMSEXPORT _cmsAddXYZTag(cmsHPROFILE hProfile, icTagSignature sig, const cmsCIEXYZ* XYZ)
   696 {
   716 {
   697        LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile;
   717        LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile;
   698 
   718 
   699        _cmsInitTag(Icc, sig, sizeof(cmsCIEXYZ), XYZ);
   719        _cmsInitTag(Icc, sig, sizeof(cmsCIEXYZ), XYZ);
   700        return TRUE;
   720        return TRUE;
   701 }
   721 }
   702 
   722 
   703 
   723 
   704 BOOL LCMSEXPORT _cmsAddTextTag(cmsHPROFILE hProfile, icTagSignature sig, const char* Text)
   724 LCMSBOOL LCMSEXPORT _cmsAddTextTag(cmsHPROFILE hProfile, icTagSignature sig, const char* Text)
   705 {
   725 {
   706        LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile;
   726        LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile;
   707 
   727 
   708        _cmsInitTag(Icc, sig, strlen(Text)+1, (LPVOID) Text);
   728        _cmsInitTag(Icc, sig, strlen(Text)+1, (LPVOID) Text);
   709        return TRUE;
   729        return TRUE;
   710 }
   730 }
   711 
   731 
   712 BOOL LCMSEXPORT _cmsAddGammaTag(cmsHPROFILE hProfile, icTagSignature sig, LPGAMMATABLE TransferFunction)
   732 LCMSBOOL LCMSEXPORT _cmsAddGammaTag(cmsHPROFILE hProfile, icTagSignature sig, LPGAMMATABLE TransferFunction)
   713 {
   733 {
   714     LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile;
   734     LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile;
   715 
   735 
   716     _cmsInitTag(Icc, sig, SizeOfGammaTab(TransferFunction), TransferFunction);
   736     _cmsInitTag(Icc, sig, SizeOfGammaTab(TransferFunction), TransferFunction);
   717     return TRUE;
   737     return TRUE;
   718 }
   738 }
   719 
   739 
   720 
   740 
   721 BOOL LCMSEXPORT _cmsAddChromaticityTag(cmsHPROFILE hProfile, icTagSignature sig, LPcmsCIExyYTRIPLE Chrm)
   741 LCMSBOOL LCMSEXPORT _cmsAddChromaticityTag(cmsHPROFILE hProfile, icTagSignature sig, LPcmsCIExyYTRIPLE Chrm)
   722 {
   742 {
   723     LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile;
   743     LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile;
   724 
   744 
   725     _cmsInitTag(Icc, sig, sizeof(cmsCIExyYTRIPLE), Chrm);
   745     _cmsInitTag(Icc, sig, sizeof(cmsCIExyYTRIPLE), Chrm);
   726     return TRUE;
   746     return TRUE;
   727 }
   747 }
   728 
   748 
   729 
   749 
   730 BOOL LCMSEXPORT _cmsAddSequenceDescriptionTag(cmsHPROFILE hProfile, icTagSignature sig, LPcmsSEQ pseq)
   750 LCMSBOOL LCMSEXPORT _cmsAddSequenceDescriptionTag(cmsHPROFILE hProfile, icTagSignature sig, LPcmsSEQ pseq)
   731 {
   751 {
   732     LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile;
   752     LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile;
   733 
   753 
   734     _cmsInitTag(Icc, sig, sizeof(int) + pseq -> n * sizeof(cmsPSEQDESC), pseq);
   754     _cmsInitTag(Icc, sig, sizeof(int) + pseq -> n * sizeof(cmsPSEQDESC), pseq);
   735     return TRUE;
   755     return TRUE;
   736 
   756 
   737 }
   757 }
   738 
   758 
   739 
   759 
   740 BOOL LCMSEXPORT _cmsAddNamedColorTag(cmsHPROFILE hProfile, icTagSignature sig, LPcmsNAMEDCOLORLIST nc)
   760 LCMSBOOL LCMSEXPORT _cmsAddNamedColorTag(cmsHPROFILE hProfile, icTagSignature sig, LPcmsNAMEDCOLORLIST nc)
   741 {
   761 {
   742     LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile;
   762     LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile;
   743 
   763 
   744     _cmsInitTag(Icc, sig, sizeof(cmsNAMEDCOLORLIST) + (nc ->nColors - 1) * sizeof(cmsNAMEDCOLOR), nc);
   764     _cmsInitTag(Icc, sig, sizeof(cmsNAMEDCOLORLIST) + (nc ->nColors - 1) * sizeof(cmsNAMEDCOLOR), nc);
   745     return FALSE;
   765     return TRUE;
   746 }
   766 }
   747 
   767 
   748 
   768 
   749 BOOL LCMSEXPORT _cmsAddDateTimeTag(cmsHPROFILE hProfile, icTagSignature sig, struct tm *DateTime)
   769 LCMSBOOL LCMSEXPORT _cmsAddDateTimeTag(cmsHPROFILE hProfile, icTagSignature sig, struct tm *DateTime)
   750 {
   770 {
   751     LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile;
   771     LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile;
   752 
   772 
   753     _cmsInitTag(Icc, sig, sizeof(struct tm), DateTime);
   773     _cmsInitTag(Icc, sig, sizeof(struct tm), DateTime);
   754     return FALSE;
   774     return TRUE;
   755 }
   775 }
   756 
   776 
   757 
   777 
   758 BOOL LCMSEXPORT _cmsAddColorantTableTag(cmsHPROFILE hProfile, icTagSignature sig, LPcmsNAMEDCOLORLIST nc)
   778 LCMSBOOL LCMSEXPORT _cmsAddColorantTableTag(cmsHPROFILE hProfile, icTagSignature sig, LPcmsNAMEDCOLORLIST nc)
   759 {
   779 {
   760     LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile;
   780     LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile;
   761 
   781 
   762     _cmsInitTag(Icc, sig, sizeof(cmsNAMEDCOLORLIST) + (nc ->nColors - 1) * sizeof(cmsNAMEDCOLOR), nc);
   782     _cmsInitTag(Icc, sig, sizeof(cmsNAMEDCOLORLIST) + (nc ->nColors - 1) * sizeof(cmsNAMEDCOLOR), nc);
   763     return FALSE;
   783     return TRUE;
   764 }
   784 }
       
   785 
       
   786 
       
   787 LCMSBOOL LCMSEXPORT _cmsAddChromaticAdaptationTag(cmsHPROFILE hProfile, icTagSignature sig, const cmsCIEXYZ* mat)
       
   788 {
       
   789     LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile;
       
   790 
       
   791     _cmsInitTag(Icc, sig, 3*sizeof(cmsCIEXYZ), mat);
       
   792     return TRUE;
       
   793 
       
   794 }
       
   795 
       
   796