src/java.desktop/share/native/liblcms/cmstypes.c
author rpatil
Mon, 14 Aug 2017 15:32:25 +0530
changeset 47424 3a00eb4636e3
parent 47419 c08d54553a36
child 49775 8fa5bb0cb937
permissions -rw-r--r--
8184937: LCMS error 13: Couldn't link the profiles Reviewed-by: prr Contributed-by: sreeprakash.s@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
     1
/*
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
     2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
     3
 *
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
     4
 * This code is free software; you can redistribute it and/or modify it
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
     5
 * under the terms of the GNU General Public License version 2 only, as
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
     6
 * published by the Free Software Foundation.  Oracle designates this
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
     7
 * particular file as subject to the "Classpath" exception as provided
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
     8
 * by Oracle in the LICENSE file that accompanied this code.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
     9
 *
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    14
 * accompanied this code).
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    15
 *
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    19
 *
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    22
 * questions.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    23
 */
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    24
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    25
// This file is available under and governed by the GNU General Public
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    26
// License version 2 only, as published by the Free Software Foundation.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    27
// However, the following notice accompanied the original version of this
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    28
// file:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    29
//
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    30
//---------------------------------------------------------------------------------
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    31
//
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    32
//  Little Color Management System
40152
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
    33
//  Copyright (c) 1998-2016 Marti Maria Saguer
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    34
//
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    35
// Permission is hereby granted, free of charge, to any person obtaining
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    36
// a copy of this software and associated documentation files (the "Software"),
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    37
// to deal in the Software without restriction, including without limitation
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    38
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    39
// and/or sell copies of the Software, and to permit persons to whom the Software
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    40
// is furnished to do so, subject to the following conditions:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    41
//
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    42
// The above copyright notice and this permission notice shall be included in
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    43
// all copies or substantial portions of the Software.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    44
//
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    45
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    46
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    47
// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    48
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    49
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    50
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    51
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    52
//
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    53
//---------------------------------------------------------------------------------
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    54
//
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    55
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    56
#include "lcms2_internal.h"
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    57
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    58
// Tag Serialization  -----------------------------------------------------------------------------
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    59
// This file implements every single tag and tag type as described in the ICC spec. Some types
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    60
// have been deprecated, like ncl and Data. There is no implementation for those types as there
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    61
// are no profiles holding them. The programmer can also extend this list by defining his own types
40152
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
    62
// by using the appropriate plug-in. There are three types of plug ins regarding that. First type
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    63
// allows to define new tags using any existing type. Next plug-in type allows to define new types
26609
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
    64
// and the third one is very specific: allows to extend the number of elements in the multiprocessing
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    65
// elements special type.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    66
//--------------------------------------------------------------------------------------------------
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    67
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    68
// Some broken types
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    69
#define cmsCorbisBrokenXYZtype    ((cmsTagTypeSignature) 0x17A505B8)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    70
#define cmsMonacoBrokenCurveType  ((cmsTagTypeSignature) 0x9478ee00)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    71
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    72
// This is the linked list that keeps track of the defined types
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    73
typedef struct _cmsTagTypeLinkedList_st {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    74
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    75
    cmsTagTypeHandler Handler;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    76
    struct _cmsTagTypeLinkedList_st* Next;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    77
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    78
} _cmsTagTypeLinkedList;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    79
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    80
// Some macros to define callbacks.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    81
#define READ_FN(x)  Type_##x##_Read
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    82
#define WRITE_FN(x) Type_##x##_Write
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    83
#define FREE_FN(x)  Type_##x##_Free
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    84
#define DUP_FN(x)   Type_##x##_Dup
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    85
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    86
// Helper macro to define a handler. Callbacks do have a fixed naming convention.
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
    87
#define TYPE_HANDLER(t, x)  { (t), READ_FN(x), WRITE_FN(x), DUP_FN(x), FREE_FN(x), NULL, 0 }
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    88
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    89
// Helper macro to define a MPE handler. Callbacks do have a fixed naming convention
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
    90
#define TYPE_MPE_HANDLER(t, x)  { (t), READ_FN(x), WRITE_FN(x), GenericMPEdup, GenericMPEfree, NULL, 0 }
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    91
26609
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
    92
// Register a new type handler. This routine is shared between normal types and MPE. LinkedList points to the optional list head
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    93
static
26609
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
    94
cmsBool RegisterTypesPlugin(cmsContext id, cmsPluginBase* Data, _cmsMemoryClient pos)
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    95
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    96
    cmsPluginTagType* Plugin = (cmsPluginTagType*) Data;
26609
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
    97
    _cmsTagTypePluginChunkType* ctx = ( _cmsTagTypePluginChunkType*) _cmsContextGetClientChunk(id, pos);
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
    98
    _cmsTagTypeLinkedList *pt;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
    99
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   100
    // Calling the function with NULL as plug-in would unregister the plug in.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   101
    if (Data == NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   102
26609
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
   103
        // There is no need to set free the memory, as pool is destroyed as a whole.
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
   104
        ctx ->TagTypes = NULL;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   105
        return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   106
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   107
26609
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
   108
    // Registering happens in plug-in memory pool.
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
   109
    pt = (_cmsTagTypeLinkedList*) _cmsPluginMalloc(id, sizeof(_cmsTagTypeLinkedList));
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   110
    if (pt == NULL) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   111
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   112
    pt ->Handler   = Plugin ->Handler;
26609
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
   113
    pt ->Next      = ctx ->TagTypes;
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
   114
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
   115
    ctx ->TagTypes = pt;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   116
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   117
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   118
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   119
26609
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
   120
// Return handler for a given type or NULL if not found. Shared between normal types and MPE. It first tries the additons
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
   121
// made by plug-ins and then the built-in defaults.
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   122
static
26609
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
   123
cmsTagTypeHandler* GetHandler(cmsTagTypeSignature sig, _cmsTagTypeLinkedList* PluginLinkedList, _cmsTagTypeLinkedList* DefaultLinkedList)
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   124
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   125
    _cmsTagTypeLinkedList* pt;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   126
26609
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
   127
    for (pt = PluginLinkedList;
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
   128
         pt != NULL;
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
   129
         pt = pt ->Next) {
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
   130
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
   131
            if (sig == pt -> Handler.Signature) return &pt ->Handler;
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
   132
    }
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
   133
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
   134
    for (pt = DefaultLinkedList;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   135
         pt != NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   136
         pt = pt ->Next) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   137
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   138
            if (sig == pt -> Handler.Signature) return &pt ->Handler;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   139
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   140
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   141
    return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   142
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   143
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   144
40152
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
   145
// Auxiliary to convert UTF-32 to UTF-16 in some cases
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   146
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   147
cmsBool _cmsWriteWCharArray(cmsIOHANDLER* io, cmsUInt32Number n, const wchar_t* Array)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   148
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   149
    cmsUInt32Number i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   150
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   151
    _cmsAssert(io != NULL);
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   152
    _cmsAssert(!(Array == NULL && n > 0));
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   153
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   154
    for (i=0; i < n; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   155
        if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) Array[i])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   156
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   157
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   158
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   159
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   160
40152
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
   161
// Auxiliary to read an array of wchar_t
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   162
static
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   163
cmsBool _cmsReadWCharArray(cmsIOHANDLER* io, cmsUInt32Number n, wchar_t* Array)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   164
{
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   165
    cmsUInt32Number i;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   166
    cmsUInt16Number tmp;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   167
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   168
    _cmsAssert(io != NULL);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   169
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   170
    for (i=0; i < n; i++) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   171
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   172
        if (Array != NULL) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   173
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   174
            if (!_cmsReadUInt16Number(io, &tmp)) return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   175
            Array[i] = (wchar_t) tmp;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   176
        }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   177
        else {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   178
            if (!_cmsReadUInt16Number(io, NULL)) return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   179
        }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   180
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   181
    }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   182
    return TRUE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   183
}
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   184
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   185
// To deal with position tables
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   186
typedef cmsBool (* PositionTableEntryFn)(struct _cms_typehandler_struct* self,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   187
                                             cmsIOHANDLER* io,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   188
                                             void* Cargo,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   189
                                             cmsUInt32Number n,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   190
                                             cmsUInt32Number SizeOfTag);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   191
40152
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
   192
// Helper function to deal with position tables as described in ICC spec 4.3
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   193
// A table of n elements is readed, where first comes n records containing offsets and sizes and
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   194
// then a block containing the data itself. This allows to reuse same data in more than one entry
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   195
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   196
cmsBool ReadPositionTable(struct _cms_typehandler_struct* self,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   197
                              cmsIOHANDLER* io,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   198
                              cmsUInt32Number Count,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   199
                              cmsUInt32Number BaseOffset,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   200
                              void *Cargo,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   201
                              PositionTableEntryFn ElementFn)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   202
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   203
    cmsUInt32Number i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   204
    cmsUInt32Number *ElementOffsets = NULL, *ElementSizes = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   205
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   206
    // Let's take the offsets to each element
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
   207
    ElementOffsets = (cmsUInt32Number *) _cmsCalloc(io ->ContextID, Count, sizeof(cmsUInt32Number));
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   208
    if (ElementOffsets == NULL) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   209
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
   210
    ElementSizes = (cmsUInt32Number *) _cmsCalloc(io ->ContextID, Count, sizeof(cmsUInt32Number));
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   211
    if (ElementSizes == NULL) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   212
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   213
    for (i=0; i < Count; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   214
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   215
        if (!_cmsReadUInt32Number(io, &ElementOffsets[i])) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   216
        if (!_cmsReadUInt32Number(io, &ElementSizes[i])) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   217
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   218
        ElementOffsets[i] += BaseOffset;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   219
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   220
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   221
    // Seek to each element and read it
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   222
    for (i=0; i < Count; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   223
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   224
        if (!io -> Seek(io, ElementOffsets[i])) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   225
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   226
        // This is the reader callback
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   227
        if (!ElementFn(self, io, Cargo, i, ElementSizes[i])) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   228
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   229
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   230
    // Success
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   231
    if (ElementOffsets != NULL) _cmsFree(io ->ContextID, ElementOffsets);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   232
    if (ElementSizes != NULL) _cmsFree(io ->ContextID, ElementSizes);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   233
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   234
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   235
Error:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   236
    if (ElementOffsets != NULL) _cmsFree(io ->ContextID, ElementOffsets);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   237
    if (ElementSizes != NULL) _cmsFree(io ->ContextID, ElementSizes);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   238
    return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   239
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   240
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   241
// Same as anterior, but for write position tables
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   242
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   243
cmsBool WritePositionTable(struct _cms_typehandler_struct* self,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   244
                               cmsIOHANDLER* io,
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   245
                               cmsUInt32Number SizeOfTag,
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   246
                               cmsUInt32Number Count,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   247
                               cmsUInt32Number BaseOffset,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   248
                               void *Cargo,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   249
                               PositionTableEntryFn ElementFn)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   250
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   251
    cmsUInt32Number i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   252
    cmsUInt32Number DirectoryPos, CurrentPos, Before;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   253
    cmsUInt32Number *ElementOffsets = NULL, *ElementSizes = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   254
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   255
     // Create table
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
   256
    ElementOffsets = (cmsUInt32Number *) _cmsCalloc(io ->ContextID, Count, sizeof(cmsUInt32Number));
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   257
    if (ElementOffsets == NULL) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   258
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
   259
    ElementSizes = (cmsUInt32Number *) _cmsCalloc(io ->ContextID, Count, sizeof(cmsUInt32Number));
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   260
    if (ElementSizes == NULL) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   261
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   262
    // Keep starting position of curve offsets
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   263
    DirectoryPos = io ->Tell(io);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   264
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   265
    // Write a fake directory to be filled latter on
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   266
    for (i=0; i < Count; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   267
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   268
        if (!_cmsWriteUInt32Number(io, 0)) goto Error;  // Offset
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   269
        if (!_cmsWriteUInt32Number(io, 0)) goto Error;  // size
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   270
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   271
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   272
    // Write each element. Keep track of the size as well.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   273
    for (i=0; i < Count; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   274
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   275
        Before = io ->Tell(io);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   276
        ElementOffsets[i] = Before - BaseOffset;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   277
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   278
        // Callback to write...
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   279
        if (!ElementFn(self, io, Cargo, i, SizeOfTag)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   280
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   281
        // Now the size
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   282
        ElementSizes[i] = io ->Tell(io) - Before;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   283
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   284
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   285
    // Write the directory
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   286
    CurrentPos = io ->Tell(io);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   287
    if (!io ->Seek(io, DirectoryPos)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   288
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   289
    for (i=0; i <  Count; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   290
        if (!_cmsWriteUInt32Number(io, ElementOffsets[i])) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   291
        if (!_cmsWriteUInt32Number(io, ElementSizes[i])) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   292
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   293
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   294
    if (!io ->Seek(io, CurrentPos)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   295
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   296
    if (ElementOffsets != NULL) _cmsFree(io ->ContextID, ElementOffsets);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   297
    if (ElementSizes != NULL) _cmsFree(io ->ContextID, ElementSizes);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   298
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   299
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   300
Error:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   301
    if (ElementOffsets != NULL) _cmsFree(io ->ContextID, ElementOffsets);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   302
    if (ElementSizes != NULL) _cmsFree(io ->ContextID, ElementSizes);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   303
    return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   304
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   305
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   306
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   307
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   308
// Type XYZ. Only one value is allowed
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   309
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   310
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   311
//The XYZType contains an array of three encoded values for the XYZ tristimulus
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   312
//values. Tristimulus values must be non-negative. The signed encoding allows for
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   313
//implementation optimizations by minimizing the number of fixed formats.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   314
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   315
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   316
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   317
void *Type_XYZ_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   318
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   319
    cmsCIEXYZ* xyz;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   320
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   321
    *nItems = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   322
    xyz = (cmsCIEXYZ*) _cmsMallocZero(self ->ContextID, sizeof(cmsCIEXYZ));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   323
    if (xyz == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   324
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   325
    if (!_cmsReadXYZNumber(io, xyz)) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   326
        _cmsFree(self ->ContextID, xyz);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   327
        return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   328
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   329
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   330
    *nItems = 1;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   331
    return (void*) xyz;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   332
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   333
    cmsUNUSED_PARAMETER(SizeOfTag);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   334
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   335
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   336
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   337
cmsBool  Type_XYZ_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   338
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   339
    return _cmsWriteXYZNumber(io, (cmsCIEXYZ*) Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   340
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   341
    cmsUNUSED_PARAMETER(nItems);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   342
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   343
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   344
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   345
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   346
void* Type_XYZ_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   347
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   348
    return _cmsDupMem(self ->ContextID, Ptr, sizeof(cmsCIEXYZ));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   349
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   350
    cmsUNUSED_PARAMETER(n);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   351
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   352
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   353
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   354
void Type_XYZ_Free(struct _cms_typehandler_struct* self, void *Ptr)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   355
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   356
    _cmsFree(self ->ContextID, Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   357
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   358
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   359
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   360
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   361
cmsTagTypeSignature DecideXYZtype(cmsFloat64Number ICCVersion, const void *Data)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   362
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   363
    return cmsSigXYZType;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   364
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   365
    cmsUNUSED_PARAMETER(ICCVersion);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   366
    cmsUNUSED_PARAMETER(Data);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   367
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   368
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   369
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   370
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   371
// Type chromaticity. Only one value is allowed
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   372
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   373
// The chromaticity tag type provides basic chromaticity data and type of
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   374
// phosphors or colorants of a monitor to applications and utilities.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   375
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   376
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   377
void *Type_Chromaticity_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   378
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   379
    cmsCIExyYTRIPLE* chrm;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   380
    cmsUInt16Number nChans, Table;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   381
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   382
    *nItems = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   383
    chrm =  (cmsCIExyYTRIPLE*) _cmsMallocZero(self ->ContextID, sizeof(cmsCIExyYTRIPLE));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   384
    if (chrm == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   385
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   386
    if (!_cmsReadUInt16Number(io, &nChans)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   387
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   388
    // Let's recover from a bug introduced in early versions of lcms1
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   389
    if (nChans == 0 && SizeOfTag == 32) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   390
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   391
        if (!_cmsReadUInt16Number(io, NULL)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   392
        if (!_cmsReadUInt16Number(io, &nChans)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   393
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   394
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   395
    if (nChans != 3) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   396
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   397
    if (!_cmsReadUInt16Number(io, &Table)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   398
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   399
    if (!_cmsRead15Fixed16Number(io, &chrm ->Red.x)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   400
    if (!_cmsRead15Fixed16Number(io, &chrm ->Red.y)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   401
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   402
    chrm ->Red.Y = 1.0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   403
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   404
    if (!_cmsRead15Fixed16Number(io, &chrm ->Green.x)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   405
    if (!_cmsRead15Fixed16Number(io, &chrm ->Green.y)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   406
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   407
    chrm ->Green.Y = 1.0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   408
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   409
    if (!_cmsRead15Fixed16Number(io, &chrm ->Blue.x)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   410
    if (!_cmsRead15Fixed16Number(io, &chrm ->Blue.y)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   411
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   412
    chrm ->Blue.Y = 1.0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   413
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   414
    *nItems = 1;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   415
    return (void*) chrm;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   416
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   417
Error:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   418
    _cmsFree(self ->ContextID, (void*) chrm);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   419
    return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   420
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   421
    cmsUNUSED_PARAMETER(SizeOfTag);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   422
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   423
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   424
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   425
cmsBool  SaveOneChromaticity(cmsFloat64Number x, cmsFloat64Number y, cmsIOHANDLER* io)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   426
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   427
    if (!_cmsWriteUInt32Number(io, _cmsDoubleTo15Fixed16(x))) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   428
    if (!_cmsWriteUInt32Number(io, _cmsDoubleTo15Fixed16(y))) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   429
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   430
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   431
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   432
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   433
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   434
cmsBool  Type_Chromaticity_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   435
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   436
    cmsCIExyYTRIPLE* chrm = (cmsCIExyYTRIPLE*) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   437
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   438
    if (!_cmsWriteUInt16Number(io, 3)) return FALSE;        // nChannels
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   439
    if (!_cmsWriteUInt16Number(io, 0)) return FALSE;        // Table
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   440
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   441
    if (!SaveOneChromaticity(chrm -> Red.x,   chrm -> Red.y, io)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   442
    if (!SaveOneChromaticity(chrm -> Green.x, chrm -> Green.y, io)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   443
    if (!SaveOneChromaticity(chrm -> Blue.x,  chrm -> Blue.y, io)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   444
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   445
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   446
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   447
    cmsUNUSED_PARAMETER(nItems);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   448
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   449
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   450
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   451
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   452
void* Type_Chromaticity_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   453
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   454
    return _cmsDupMem(self ->ContextID, Ptr, sizeof(cmsCIExyYTRIPLE));
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
   455
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   456
    cmsUNUSED_PARAMETER(n);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   457
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   458
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   459
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   460
void Type_Chromaticity_Free(struct _cms_typehandler_struct* self, void* Ptr)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   461
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   462
    _cmsFree(self ->ContextID, Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   463
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   464
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   465
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   466
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   467
// Type cmsSigColorantOrderType
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   468
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   469
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   470
// This is an optional tag which specifies the laydown order in which colorants will
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   471
// be printed on an n-colorant device. The laydown order may be the same as the
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   472
// channel generation order listed in the colorantTableTag or the channel order of a
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   473
// colour space such as CMYK, in which case this tag is not needed. When this is not
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   474
// the case (for example, ink-towers sometimes use the order KCMY), this tag may be
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   475
// used to specify the laydown order of the colorants.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   476
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   477
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   478
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   479
void *Type_ColorantOrderType_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   480
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   481
    cmsUInt8Number* ColorantOrder;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   482
    cmsUInt32Number Count;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   483
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   484
    *nItems = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   485
    if (!_cmsReadUInt32Number(io, &Count)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   486
    if (Count > cmsMAXCHANNELS) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   487
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   488
    ColorantOrder = (cmsUInt8Number*) _cmsCalloc(self ->ContextID, cmsMAXCHANNELS, sizeof(cmsUInt8Number));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   489
    if (ColorantOrder == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   490
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   491
    // We use FF as end marker
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   492
    memset(ColorantOrder, 0xFF, cmsMAXCHANNELS * sizeof(cmsUInt8Number));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   493
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   494
    if (io ->Read(io, ColorantOrder, sizeof(cmsUInt8Number), Count) != Count) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   495
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   496
        _cmsFree(self ->ContextID, (void*) ColorantOrder);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   497
        return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   498
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   499
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   500
    *nItems = 1;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   501
    return (void*) ColorantOrder;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   502
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   503
    cmsUNUSED_PARAMETER(SizeOfTag);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   504
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   505
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   506
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   507
cmsBool Type_ColorantOrderType_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   508
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   509
    cmsUInt8Number*  ColorantOrder = (cmsUInt8Number*) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   510
    cmsUInt32Number i, sz, Count;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   511
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   512
    // Get the length
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   513
    for (Count=i=0; i < cmsMAXCHANNELS; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   514
        if (ColorantOrder[i] != 0xFF) Count++;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   515
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   516
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   517
    if (!_cmsWriteUInt32Number(io, Count)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   518
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   519
    sz = Count * sizeof(cmsUInt8Number);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   520
    if (!io -> Write(io, sz, ColorantOrder)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   521
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   522
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   523
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   524
    cmsUNUSED_PARAMETER(nItems);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   525
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   526
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   527
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   528
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   529
void* Type_ColorantOrderType_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   530
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   531
    return _cmsDupMem(self ->ContextID, Ptr, cmsMAXCHANNELS * sizeof(cmsUInt8Number));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   532
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   533
    cmsUNUSED_PARAMETER(n);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   534
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   535
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   536
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   537
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   538
void Type_ColorantOrderType_Free(struct _cms_typehandler_struct* self, void* Ptr)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   539
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   540
    _cmsFree(self ->ContextID, Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   541
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   542
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   543
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   544
// Type cmsSigS15Fixed16ArrayType
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   545
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   546
// This type represents an array of generic 4-byte/32-bit fixed point quantity.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   547
// The number of values is determined from the size of the tag.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   548
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   549
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   550
void *Type_S15Fixed16_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   551
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   552
    cmsFloat64Number*  array_double;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   553
    cmsUInt32Number i, n;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   554
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   555
    *nItems = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   556
    n = SizeOfTag / sizeof(cmsUInt32Number);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   557
    array_double = (cmsFloat64Number*) _cmsCalloc(self ->ContextID, n, sizeof(cmsFloat64Number));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   558
    if (array_double == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   559
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   560
    for (i=0; i < n; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   561
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   562
        if (!_cmsRead15Fixed16Number(io, &array_double[i])) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   563
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   564
            _cmsFree(self ->ContextID, array_double);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   565
            return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   566
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   567
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   568
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   569
    *nItems = n;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   570
    return (void*) array_double;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   571
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   572
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   573
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   574
cmsBool Type_S15Fixed16_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   575
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   576
    cmsFloat64Number* Value = (cmsFloat64Number*) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   577
    cmsUInt32Number i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   578
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   579
    for (i=0; i < nItems; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   580
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   581
        if (!_cmsWrite15Fixed16Number(io, Value[i])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   582
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   583
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   584
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   585
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   586
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   587
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   588
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   589
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   590
void* Type_S15Fixed16_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   591
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   592
    return _cmsDupMem(self ->ContextID, Ptr, n * sizeof(cmsFloat64Number));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   593
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   594
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   595
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   596
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   597
void Type_S15Fixed16_Free(struct _cms_typehandler_struct* self, void* Ptr)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   598
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   599
    _cmsFree(self ->ContextID, Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   600
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   601
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   602
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   603
// Type cmsSigU16Fixed16ArrayType
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   604
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   605
// This type represents an array of generic 4-byte/32-bit quantity.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   606
// The number of values is determined from the size of the tag.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   607
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   608
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   609
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   610
void *Type_U16Fixed16_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   611
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   612
    cmsFloat64Number*  array_double;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   613
    cmsUInt32Number v;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   614
    cmsUInt32Number i, n;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   615
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   616
    *nItems = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   617
    n = SizeOfTag / sizeof(cmsUInt32Number);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   618
    array_double = (cmsFloat64Number*) _cmsCalloc(self ->ContextID, n, sizeof(cmsFloat64Number));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   619
    if (array_double == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   620
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   621
    for (i=0; i < n; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   622
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   623
        if (!_cmsReadUInt32Number(io, &v)) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   624
            _cmsFree(self ->ContextID, (void*) array_double);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   625
            return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   626
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   627
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   628
        // Convert to cmsFloat64Number
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   629
        array_double[i] =  (cmsFloat64Number) (v / 65536.0);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   630
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   631
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   632
    *nItems = n;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   633
    return (void*) array_double;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   634
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   635
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   636
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   637
cmsBool Type_U16Fixed16_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   638
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   639
    cmsFloat64Number* Value = (cmsFloat64Number*) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   640
    cmsUInt32Number i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   641
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   642
    for (i=0; i < nItems; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   643
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   644
        cmsUInt32Number v = (cmsUInt32Number) floor(Value[i]*65536.0 + 0.5);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   645
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   646
        if (!_cmsWriteUInt32Number(io, v)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   647
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   648
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   649
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   650
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   651
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   652
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   653
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   654
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   655
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   656
void* Type_U16Fixed16_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   657
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   658
    return _cmsDupMem(self ->ContextID, Ptr, n * sizeof(cmsFloat64Number));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   659
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   660
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   661
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   662
void Type_U16Fixed16_Free(struct _cms_typehandler_struct* self, void* Ptr)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   663
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   664
    _cmsFree(self ->ContextID, Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   665
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   666
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   667
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   668
// Type cmsSigSignatureType
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   669
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   670
//
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   671
// The signatureType contains a four-byte sequence, Sequences of less than four
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   672
// characters are padded at the end with spaces, 20h.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   673
// Typically this type is used for registered tags that can be displayed on many
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   674
// development systems as a sequence of four characters.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   675
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   676
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   677
void *Type_Signature_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   678
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   679
    cmsSignature* SigPtr = (cmsSignature*) _cmsMalloc(self ->ContextID, sizeof(cmsSignature));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   680
    if (SigPtr == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   681
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   682
     if (!_cmsReadUInt32Number(io, SigPtr)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   683
     *nItems = 1;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   684
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   685
     return SigPtr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   686
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   687
     cmsUNUSED_PARAMETER(SizeOfTag);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   688
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   689
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   690
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   691
cmsBool  Type_Signature_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   692
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   693
    cmsSignature* SigPtr = (cmsSignature*) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   694
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   695
    return _cmsWriteUInt32Number(io, *SigPtr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   696
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   697
    cmsUNUSED_PARAMETER(nItems);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   698
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   699
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   700
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   701
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   702
void* Type_Signature_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   703
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   704
    return _cmsDupMem(self ->ContextID, Ptr, n * sizeof(cmsSignature));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   705
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   706
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   707
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   708
void Type_Signature_Free(struct _cms_typehandler_struct* self, void* Ptr)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   709
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   710
    _cmsFree(self ->ContextID, Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   711
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   712
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   713
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   714
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   715
// Type cmsSigTextType
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   716
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   717
//
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   718
// The textType is a simple text structure that contains a 7-bit ASCII text string.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   719
// The length of the string is obtained by subtracting 8 from the element size portion
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   720
// of the tag itself. This string must be terminated with a 00h byte.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   721
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   722
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   723
void *Type_Text_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   724
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   725
    char* Text = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   726
    cmsMLU* mlu = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   727
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   728
    // Create a container
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   729
    mlu = cmsMLUalloc(self ->ContextID, 1);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   730
    if (mlu == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   731
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   732
    *nItems = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   733
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   734
    // We need to store the "\0" at the end, so +1
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   735
    if (SizeOfTag == UINT_MAX) goto Error;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   736
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   737
    Text = (char*) _cmsMalloc(self ->ContextID, SizeOfTag + 1);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   738
    if (Text == NULL) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   739
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   740
    if (io -> Read(io, Text, sizeof(char), SizeOfTag) != SizeOfTag) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   741
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   742
    // Make sure text is properly ended
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   743
    Text[SizeOfTag] = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   744
    *nItems = 1;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   745
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   746
    // Keep the result
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   747
    if (!cmsMLUsetASCII(mlu, cmsNoLanguage, cmsNoCountry, Text)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   748
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   749
    _cmsFree(self ->ContextID, Text);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   750
    return (void*) mlu;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   751
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   752
Error:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   753
    if (mlu != NULL)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   754
        cmsMLUfree(mlu);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   755
    if (Text != NULL)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   756
        _cmsFree(self ->ContextID, Text);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   757
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   758
    return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   759
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   760
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   761
// The conversion implies to choose a language. So, we choose the actual language.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   762
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   763
cmsBool Type_Text_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   764
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   765
    cmsMLU* mlu = (cmsMLU*) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   766
    cmsUInt32Number size;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   767
    cmsBool  rc;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   768
    char* Text;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   769
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   770
    // Get the size of the string. Note there is an extra "\0" at the end
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   771
    size = cmsMLUgetASCII(mlu, cmsNoLanguage, cmsNoCountry, NULL, 0);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   772
    if (size == 0) return FALSE;       // Cannot be zero!
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   773
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   774
    // Create memory
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   775
    Text = (char*) _cmsMalloc(self ->ContextID, size);
26609
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
   776
    if (Text == NULL) return FALSE;
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
   777
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   778
    cmsMLUgetASCII(mlu, cmsNoLanguage, cmsNoCountry, Text, size);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   779
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   780
    // Write it, including separator
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   781
    rc = io ->Write(io, size, Text);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   782
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   783
    _cmsFree(self ->ContextID, Text);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   784
    return rc;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   785
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   786
    cmsUNUSED_PARAMETER(nItems);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   787
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   788
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   789
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   790
void* Type_Text_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   791
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   792
    return (void*) cmsMLUdup((cmsMLU*) Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   793
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   794
    cmsUNUSED_PARAMETER(n);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   795
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   796
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   797
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   798
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   799
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   800
void Type_Text_Free(struct _cms_typehandler_struct* self, void* Ptr)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   801
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   802
    cmsMLU* mlu = (cmsMLU*) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   803
    cmsMLUfree(mlu);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   804
    return;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   805
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   806
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   807
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   808
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   809
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   810
cmsTagTypeSignature DecideTextType(cmsFloat64Number ICCVersion, const void *Data)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   811
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   812
    if (ICCVersion >= 4.0)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   813
        return cmsSigMultiLocalizedUnicodeType;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   814
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   815
    return cmsSigTextType;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   816
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   817
    cmsUNUSED_PARAMETER(Data);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   818
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   819
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   820
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   821
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   822
// Type cmsSigDataType
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   823
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   824
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   825
// General purpose data type
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   826
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   827
void *Type_Data_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   828
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   829
    cmsICCData* BinData;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   830
    cmsUInt32Number LenOfData;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   831
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   832
    *nItems = 0;
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   833
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   834
    if (SizeOfTag < sizeof(cmsUInt32Number)) return NULL;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   835
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   836
    LenOfData = SizeOfTag - sizeof(cmsUInt32Number);
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   837
    if (LenOfData > INT_MAX) return NULL;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   838
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   839
    BinData = (cmsICCData*) _cmsMalloc(self ->ContextID, sizeof(cmsICCData) + LenOfData - 1);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   840
    if (BinData == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   841
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   842
    BinData ->len = LenOfData;
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   843
    if (!_cmsReadUInt32Number(io, &BinData->flag)) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   844
        _cmsFree(self ->ContextID, BinData);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   845
        return NULL;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   846
    }
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   847
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   848
    if (io -> Read(io, BinData ->data, sizeof(cmsUInt8Number), LenOfData) != LenOfData) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   849
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   850
        _cmsFree(self ->ContextID, BinData);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   851
        return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   852
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   853
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   854
    *nItems = 1;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   855
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   856
    return (void*) BinData;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   857
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   858
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   859
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   860
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   861
cmsBool Type_Data_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   862
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   863
   cmsICCData* BinData = (cmsICCData*) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   864
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   865
   if (!_cmsWriteUInt32Number(io, BinData ->flag)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   866
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   867
   return io ->Write(io, BinData ->len, BinData ->data);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   868
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   869
   cmsUNUSED_PARAMETER(nItems);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   870
   cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   871
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   872
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   873
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   874
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   875
void* Type_Data_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   876
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   877
    cmsICCData* BinData = (cmsICCData*) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   878
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   879
    return _cmsDupMem(self ->ContextID, Ptr, sizeof(cmsICCData) + BinData ->len - 1);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   880
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   881
    cmsUNUSED_PARAMETER(n);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   882
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   883
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   884
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   885
void Type_Data_Free(struct _cms_typehandler_struct* self, void* Ptr)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   886
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   887
    _cmsFree(self ->ContextID, Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   888
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   889
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   890
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   891
// Type cmsSigTextDescriptionType
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   892
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   893
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   894
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   895
void *Type_Text_Description_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   896
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   897
    char* Text = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   898
    cmsMLU* mlu = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   899
    cmsUInt32Number  AsciiCount;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   900
    cmsUInt32Number  i, UnicodeCode, UnicodeCount;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   901
    cmsUInt16Number  ScriptCodeCode, Dummy;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   902
    cmsUInt8Number   ScriptCodeCount;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   903
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   904
    *nItems = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   905
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   906
    //  One dword should be there
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   907
    if (SizeOfTag < sizeof(cmsUInt32Number)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   908
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   909
    // Read len of ASCII
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   910
    if (!_cmsReadUInt32Number(io, &AsciiCount)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   911
    SizeOfTag -= sizeof(cmsUInt32Number);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   912
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   913
    // Check for size
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   914
    if (SizeOfTag < AsciiCount) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   915
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   916
    // All seems Ok, allocate the container
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   917
    mlu = cmsMLUalloc(self ->ContextID, 1);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   918
    if (mlu == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   919
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   920
    // As many memory as size of tag
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   921
    Text = (char*) _cmsMalloc(self ->ContextID, AsciiCount + 1);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   922
    if (Text == NULL) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   923
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   924
    // Read it
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   925
    if (io ->Read(io, Text, sizeof(char), AsciiCount) != AsciiCount) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   926
    SizeOfTag -= AsciiCount;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   927
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   928
    // Make sure there is a terminator
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   929
    Text[AsciiCount] = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   930
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   931
    // Set the MLU entry. From here we can be tolerant to wrong types
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   932
    if (!cmsMLUsetASCII(mlu, cmsNoLanguage, cmsNoCountry, Text)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   933
    _cmsFree(self ->ContextID, (void*) Text);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   934
    Text = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   935
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   936
    // Skip Unicode code
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   937
    if (SizeOfTag < 2* sizeof(cmsUInt32Number)) goto Done;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   938
    if (!_cmsReadUInt32Number(io, &UnicodeCode)) goto Done;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   939
    if (!_cmsReadUInt32Number(io, &UnicodeCount)) goto Done;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   940
    SizeOfTag -= 2* sizeof(cmsUInt32Number);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   941
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   942
    if (SizeOfTag < UnicodeCount*sizeof(cmsUInt16Number)) goto Done;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   943
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   944
    for (i=0; i < UnicodeCount; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   945
        if (!io ->Read(io, &Dummy, sizeof(cmsUInt16Number), 1)) goto Done;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   946
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   947
    SizeOfTag -= UnicodeCount*sizeof(cmsUInt16Number);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   948
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   949
    // Skip ScriptCode code if present. Some buggy profiles does have less
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   950
    // data that stricttly required. We need to skip it as this type may come
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   951
    // embedded in other types.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   952
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   953
    if (SizeOfTag >= sizeof(cmsUInt16Number) + sizeof(cmsUInt8Number) + 67) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   954
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   955
        if (!_cmsReadUInt16Number(io, &ScriptCodeCode)) goto Done;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   956
        if (!_cmsReadUInt8Number(io,  &ScriptCodeCount)) goto Done;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   957
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   958
        // Skip rest of tag
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   959
        for (i=0; i < 67; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   960
            if (!io ->Read(io, &Dummy, sizeof(cmsUInt8Number), 1)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   961
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   962
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   963
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   964
Done:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   965
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   966
    *nItems = 1;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   967
    return mlu;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   968
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   969
Error:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   970
    if (Text) _cmsFree(self ->ContextID, (void*) Text);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   971
    if (mlu) cmsMLUfree(mlu);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   972
    return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   973
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   974
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   975
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   976
// This tag can come IN UNALIGNED SIZE. In order to prevent issues, we force zeros on description to align it
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   977
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   978
cmsBool  Type_Text_Description_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   979
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   980
    cmsMLU* mlu = (cmsMLU*) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   981
    char *Text = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   982
    wchar_t *Wide = NULL;
40152
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
   983
    cmsUInt32Number len, len_text, len_tag_requirement, len_aligned;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   984
    cmsBool  rc = FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   985
    char Filler[68];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   986
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   987
    // Used below for writting zeroes
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   988
    memset(Filler, 0, sizeof(Filler));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   989
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   990
    // Get the len of string
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   991
    len = cmsMLUgetASCII(mlu, cmsNoLanguage, cmsNoCountry, NULL, 0);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   992
40152
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
   993
    // Specification ICC.1:2001-04 (v2.4.0): It has been found that textDescriptionType can contain misaligned data
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   994
    //(see clause 4.1 for the definition of “aligned”). Because the Unicode language
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   995
    // code and Unicode count immediately follow the ASCII description, their
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   996
    // alignment is not correct if the ASCII count is not a multiple of four. The
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   997
    // ScriptCode code is misaligned when the ASCII count is odd. Profile reading and
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   998
    // writing software must be written carefully in order to handle these alignment
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
   999
    // problems.
40152
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  1000
    //
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  1001
    // The above last sentence suggest to handle alignment issues in the
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  1002
    // parser. The provided example (Table 69 on Page 60) makes this clear.
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  1003
    // The padding only in the ASCII count is not sufficient for a aligned tag
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  1004
    // size, with the same text size in ASCII and Unicode.
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1005
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1006
    // Null strings
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1007
    if (len <= 0) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1008
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1009
        Text = (char*)    _cmsDupMem(self ->ContextID, "", sizeof(char));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1010
        Wide = (wchar_t*) _cmsDupMem(self ->ContextID, L"", sizeof(wchar_t));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1011
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1012
    else {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1013
        // Create independent buffers
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1014
        Text = (char*) _cmsCalloc(self ->ContextID, len, sizeof(char));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1015
        if (Text == NULL) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1016
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1017
        Wide = (wchar_t*) _cmsCalloc(self ->ContextID, len, sizeof(wchar_t));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1018
        if (Wide == NULL) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1019
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1020
        // Get both representations.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1021
        cmsMLUgetASCII(mlu, cmsNoLanguage, cmsNoCountry,  Text, len * sizeof(char));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1022
        cmsMLUgetWide(mlu,  cmsNoLanguage, cmsNoCountry,  Wide, len * sizeof(wchar_t));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1023
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1024
40152
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  1025
    // Tell the real text len including the null terminator and padding
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  1026
    len_text = (cmsUInt32Number) strlen(Text) + 1;
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  1027
    // Compute an total tag size requirement
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  1028
    len_tag_requirement = (8+4+len_text+4+4+2*len_text+2+1+67);
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  1029
    len_aligned = _cmsALIGNLONG(len_tag_requirement);
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  1030
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1031
  // * cmsUInt32Number       count;          * Description length
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1032
  // * cmsInt8Number         desc[count]     * NULL terminated ascii string
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1033
  // * cmsUInt32Number       ucLangCode;     * UniCode language code
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1034
  // * cmsUInt32Number       ucCount;        * UniCode description length
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1035
  // * cmsInt16Number        ucDesc[ucCount];* The UniCode description
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1036
  // * cmsUInt16Number       scCode;         * ScriptCode code
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1037
  // * cmsUInt8Number        scCount;        * ScriptCode count
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1038
  // * cmsInt8Number         scDesc[67];     * ScriptCode Description
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1039
40152
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  1040
    if (!_cmsWriteUInt32Number(io, len_text)) goto Error;
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  1041
    if (!io ->Write(io, len_text, Text)) goto Error;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1042
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1043
    if (!_cmsWriteUInt32Number(io, 0)) goto Error;  // ucLanguageCode
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1044
40152
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  1045
    if (!_cmsWriteUInt32Number(io, len_text)) goto Error;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1046
    // Note that in some compilers sizeof(cmsUInt16Number) != sizeof(wchar_t)
40152
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  1047
    if (!_cmsWriteWCharArray(io, len_text, Wide)) goto Error;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1048
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1049
    // ScriptCode Code & count (unused)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1050
    if (!_cmsWriteUInt16Number(io, 0)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1051
    if (!_cmsWriteUInt8Number(io, 0)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1052
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1053
    if (!io ->Write(io, 67, Filler)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1054
40152
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  1055
    // possibly add pad at the end of tag
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  1056
    if(len_aligned - len_tag_requirement > 0)
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  1057
      if (!io ->Write(io, len_aligned - len_tag_requirement, Filler)) goto Error;
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  1058
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1059
    rc = TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1060
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1061
Error:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1062
    if (Text) _cmsFree(self ->ContextID, Text);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1063
    if (Wide) _cmsFree(self ->ContextID, Wide);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1064
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1065
    return rc;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1066
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1067
    cmsUNUSED_PARAMETER(nItems);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1068
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1069
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1070
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1071
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1072
void* Type_Text_Description_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1073
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1074
    return (void*) cmsMLUdup((cmsMLU*) Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1075
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1076
    cmsUNUSED_PARAMETER(n);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1077
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1078
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1079
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1080
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1081
void Type_Text_Description_Free(struct _cms_typehandler_struct* self, void* Ptr)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1082
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1083
    cmsMLU* mlu = (cmsMLU*) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1084
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1085
    cmsMLUfree(mlu);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1086
    return;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1087
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1088
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1089
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1090
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1091
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1092
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1093
cmsTagTypeSignature DecideTextDescType(cmsFloat64Number ICCVersion, const void *Data)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1094
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1095
    if (ICCVersion >= 4.0)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1096
        return cmsSigMultiLocalizedUnicodeType;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1097
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1098
    return cmsSigTextDescriptionType;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1099
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1100
    cmsUNUSED_PARAMETER(Data);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1101
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1102
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1103
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1104
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1105
// Type cmsSigCurveType
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1106
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1107
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1108
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1109
void *Type_Curve_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1110
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1111
    cmsUInt32Number Count;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1112
    cmsToneCurve* NewGamma;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1113
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1114
    *nItems = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1115
    if (!_cmsReadUInt32Number(io, &Count)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1116
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1117
    switch (Count) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1118
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1119
           case 0:   // Linear.
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1120
               {
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1121
                   cmsFloat64Number SingleGamma = 1.0;
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1122
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1123
                   NewGamma = cmsBuildParametricToneCurve(self ->ContextID, 1, &SingleGamma);
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1124
                   if (!NewGamma) return NULL;
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1125
                   *nItems = 1;
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1126
                   return NewGamma;
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1127
               }
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1128
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1129
           case 1:  // Specified as the exponent of gamma function
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1130
               {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1131
                   cmsUInt16Number SingleGammaFixed;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1132
                   cmsFloat64Number SingleGamma;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1133
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1134
                   if (!_cmsReadUInt16Number(io, &SingleGammaFixed)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1135
                   SingleGamma = _cms8Fixed8toDouble(SingleGammaFixed);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1136
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1137
                   *nItems = 1;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1138
                   return cmsBuildParametricToneCurve(self ->ContextID, 1, &SingleGamma);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1139
               }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1140
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1141
           default:  // Curve
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1142
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1143
               if (Count > 0x7FFF)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1144
                   return NULL; // This is to prevent bad guys for doing bad things
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1145
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1146
               NewGamma = cmsBuildTabulatedToneCurve16(self ->ContextID, Count, NULL);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1147
               if (!NewGamma) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1148
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1149
               if (!_cmsReadUInt16Array(io, Count, NewGamma -> Table16)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1150
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1151
               *nItems = 1;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1152
               return NewGamma;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1153
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1154
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1155
    cmsUNUSED_PARAMETER(SizeOfTag);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1156
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1157
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1158
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1159
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1160
cmsBool  Type_Curve_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1161
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1162
    cmsToneCurve* Curve = (cmsToneCurve*) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1163
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1164
    if (Curve ->nSegments == 1 && Curve ->Segments[0].Type == 1) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1165
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1166
            // Single gamma, preserve number
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1167
            cmsUInt16Number SingleGammaFixed = _cmsDoubleTo8Fixed8(Curve ->Segments[0].Params[0]);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1168
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1169
            if (!_cmsWriteUInt32Number(io, 1)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1170
            if (!_cmsWriteUInt16Number(io, SingleGammaFixed)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1171
            return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1172
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1173
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1174
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1175
    if (!_cmsWriteUInt32Number(io, Curve ->nEntries)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1176
    return _cmsWriteUInt16Array(io, Curve ->nEntries, Curve ->Table16);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1177
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1178
    cmsUNUSED_PARAMETER(nItems);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1179
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1180
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1181
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1182
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1183
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1184
void* Type_Curve_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1185
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1186
    return (void*) cmsDupToneCurve((cmsToneCurve*) Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1187
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1188
    cmsUNUSED_PARAMETER(n);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1189
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1190
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1191
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1192
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1193
void Type_Curve_Free(struct _cms_typehandler_struct* self, void* Ptr)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1194
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1195
    cmsToneCurve* gamma = (cmsToneCurve*) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1196
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1197
    cmsFreeToneCurve(gamma);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1198
    return;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1199
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1200
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1201
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1202
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1203
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1204
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1205
// Type cmsSigParametricCurveType
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1206
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1207
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1208
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1209
// Decide which curve type to use on writting
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1210
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1211
cmsTagTypeSignature DecideCurveType(cmsFloat64Number ICCVersion, const void *Data)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1212
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1213
    cmsToneCurve* Curve = (cmsToneCurve*) Data;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1214
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1215
    if (ICCVersion < 4.0) return cmsSigCurveType;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1216
    if (Curve ->nSegments != 1) return cmsSigCurveType;          // Only 1-segment curves can be saved as parametric
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1217
    if (Curve ->Segments[0].Type < 0) return cmsSigCurveType;    // Only non-inverted curves
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1218
    if (Curve ->Segments[0].Type > 5) return cmsSigCurveType;    // Only ICC parametric curves
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1219
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1220
    return cmsSigParametricCurveType;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1221
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1222
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1223
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1224
void *Type_ParametricCurve_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1225
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1226
    static const int ParamsByType[] = { 1, 3, 4, 5, 7 };
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1227
    cmsFloat64Number Params[10];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1228
    cmsUInt16Number Type;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1229
    int i, n;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1230
    cmsToneCurve* NewGamma;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1231
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1232
    if (!_cmsReadUInt16Number(io, &Type)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1233
    if (!_cmsReadUInt16Number(io, NULL)) return NULL;   // Reserved
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1234
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1235
    if (Type > 4) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1236
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1237
        cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unknown parametric curve type '%d'", Type);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1238
        return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1239
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1240
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1241
    memset(Params, 0, sizeof(Params));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1242
    n = ParamsByType[Type];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1243
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1244
    for (i=0; i < n; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1245
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1246
        if (!_cmsRead15Fixed16Number(io, &Params[i])) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1247
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1248
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1249
    NewGamma = cmsBuildParametricToneCurve(self ->ContextID, Type+1, Params);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1250
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1251
    *nItems = 1;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1252
    return NewGamma;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1253
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1254
    cmsUNUSED_PARAMETER(SizeOfTag);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1255
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1256
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1257
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1258
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1259
cmsBool  Type_ParametricCurve_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1260
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1261
    cmsToneCurve* Curve = (cmsToneCurve*) Ptr;
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1262
    int i, nParams, typen;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1263
    static const int ParamsByType[] = { 0, 1, 3, 4, 5, 7 };
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1264
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1265
    typen = Curve -> Segments[0].Type;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1266
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1267
    if (Curve ->nSegments > 1 || typen < 1) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1268
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1269
        cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Multisegment or Inverted parametric curves cannot be written");
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1270
        return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1271
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1272
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1273
    if (typen > 5) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1274
        cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported parametric curve");
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1275
        return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1276
    }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1277
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1278
    nParams = ParamsByType[typen];
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1279
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1280
    if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) (Curve ->Segments[0].Type - 1))) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1281
    if (!_cmsWriteUInt16Number(io, 0)) return FALSE;        // Reserved
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1282
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1283
    for (i=0; i < nParams; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1284
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1285
        if (!_cmsWrite15Fixed16Number(io, Curve -> Segments[0].Params[i])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1286
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1287
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1288
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1289
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1290
    cmsUNUSED_PARAMETER(nItems);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1291
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1292
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1293
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1294
void* Type_ParametricCurve_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1295
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1296
    return (void*) cmsDupToneCurve((cmsToneCurve*) Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1297
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1298
    cmsUNUSED_PARAMETER(n);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1299
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1300
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1301
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1302
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1303
void Type_ParametricCurve_Free(struct _cms_typehandler_struct* self, void* Ptr)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1304
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1305
    cmsToneCurve* gamma = (cmsToneCurve*) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1306
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1307
    cmsFreeToneCurve(gamma);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1308
    return;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1309
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1310
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1311
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1312
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1313
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1314
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1315
// Type cmsSigDateTimeType
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1316
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1317
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1318
// A 12-byte value representation of the time and date, where the byte usage is assigned
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1319
// as specified in table 1. The actual values are encoded as 16-bit unsigned integers
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1320
// (uInt16Number - see 5.1.6).
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1321
//
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1322
// All the dateTimeNumber values in a profile shall be in Coordinated Universal Time
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1323
// (UTC, also known as GMT or ZULU Time). Profile writers are required to convert local
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1324
// time to UTC when setting these values. Programmes that display these values may show
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1325
// the dateTimeNumber as UTC, show the equivalent local time (at current locale), or
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1326
// display both UTC and local versions of the dateTimeNumber.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1327
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1328
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1329
void *Type_DateTime_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1330
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1331
    cmsDateTimeNumber timestamp;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1332
    struct tm * NewDateTime;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1333
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1334
    *nItems = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1335
    NewDateTime = (struct tm*) _cmsMalloc(self ->ContextID, sizeof(struct tm));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1336
    if (NewDateTime == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1337
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1338
    if (io->Read(io, &timestamp, sizeof(cmsDateTimeNumber), 1) != 1) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1339
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1340
     _cmsDecodeDateTimeNumber(&timestamp, NewDateTime);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1341
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1342
     *nItems = 1;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1343
     return NewDateTime;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1344
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1345
     cmsUNUSED_PARAMETER(SizeOfTag);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1346
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1347
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1348
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1349
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1350
cmsBool  Type_DateTime_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1351
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1352
    struct tm * DateTime = (struct tm*) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1353
    cmsDateTimeNumber timestamp;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1354
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1355
    _cmsEncodeDateTimeNumber(&timestamp, DateTime);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1356
    if (!io ->Write(io, sizeof(cmsDateTimeNumber), &timestamp)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1357
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1358
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1359
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1360
    cmsUNUSED_PARAMETER(nItems);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1361
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1362
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1363
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1364
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1365
void* Type_DateTime_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1366
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1367
    return _cmsDupMem(self ->ContextID, Ptr, sizeof(struct tm));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1368
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1369
    cmsUNUSED_PARAMETER(n);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1370
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1371
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1372
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1373
void Type_DateTime_Free(struct _cms_typehandler_struct* self, void* Ptr)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1374
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1375
    _cmsFree(self ->ContextID, Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1376
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1377
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1378
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1379
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1380
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1381
// Type icMeasurementType
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1382
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1383
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1384
/*
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1385
The measurementType information refers only to the internal profile data and is
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1386
meant to provide profile makers an alternative to the default measurement
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1387
specifications.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1388
*/
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1389
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1390
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1391
void *Type_Measurement_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1392
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1393
    cmsICCMeasurementConditions mc;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1394
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1395
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1396
    memset(&mc, 0, sizeof(mc));
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1397
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1398
    if (!_cmsReadUInt32Number(io, &mc.Observer)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1399
    if (!_cmsReadXYZNumber(io,    &mc.Backing)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1400
    if (!_cmsReadUInt32Number(io, &mc.Geometry)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1401
    if (!_cmsRead15Fixed16Number(io, &mc.Flare)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1402
    if (!_cmsReadUInt32Number(io, &mc.IlluminantType)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1403
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1404
    *nItems = 1;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1405
    return _cmsDupMem(self ->ContextID, &mc, sizeof(cmsICCMeasurementConditions));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1406
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1407
    cmsUNUSED_PARAMETER(SizeOfTag);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1408
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1409
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1410
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1411
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1412
cmsBool  Type_Measurement_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1413
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1414
    cmsICCMeasurementConditions* mc =(cmsICCMeasurementConditions*) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1415
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1416
    if (!_cmsWriteUInt32Number(io, mc->Observer)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1417
    if (!_cmsWriteXYZNumber(io,    &mc->Backing)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1418
    if (!_cmsWriteUInt32Number(io, mc->Geometry)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1419
    if (!_cmsWrite15Fixed16Number(io, mc->Flare)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1420
    if (!_cmsWriteUInt32Number(io, mc->IlluminantType)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1421
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1422
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1423
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1424
    cmsUNUSED_PARAMETER(nItems);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1425
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1426
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1427
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1428
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1429
void* Type_Measurement_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1430
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1431
     return _cmsDupMem(self ->ContextID, Ptr, sizeof(cmsICCMeasurementConditions));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1432
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1433
     cmsUNUSED_PARAMETER(n);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1434
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1435
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1436
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1437
void Type_Measurement_Free(struct _cms_typehandler_struct* self, void* Ptr)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1438
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1439
   _cmsFree(self ->ContextID, Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1440
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1441
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1442
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1443
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1444
// Type cmsSigMultiLocalizedUnicodeType
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1445
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1446
//
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1447
//   Do NOT trust SizeOfTag as there is an issue on the definition of profileSequenceDescTag. See the TechNote from
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1448
//   Max Derhak and Rohit Patil about this: basically the size of the string table should be guessed and cannot be
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1449
//   taken from the size of tag if this tag is embedded as part of bigger structures (profileSequenceDescTag, for instance)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1450
//
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1451
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1452
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1453
void *Type_MLU_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1454
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1455
    cmsMLU* mlu;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1456
    cmsUInt32Number Count, RecLen, NumOfWchar;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1457
    cmsUInt32Number SizeOfHeader;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1458
    cmsUInt32Number  Len, Offset;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1459
    cmsUInt32Number  i;
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1460
    wchar_t*         Block;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1461
    cmsUInt32Number  BeginOfThisString, EndOfThisString, LargestPosition;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1462
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1463
    *nItems = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1464
    if (!_cmsReadUInt32Number(io, &Count)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1465
    if (!_cmsReadUInt32Number(io, &RecLen)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1466
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1467
    if (RecLen != 12) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1468
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1469
        cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "multiLocalizedUnicodeType of len != 12 is not supported.");
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1470
        return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1471
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1472
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1473
    mlu = cmsMLUalloc(self ->ContextID, Count);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1474
    if (mlu == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1475
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1476
    mlu ->UsedEntries = Count;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1477
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1478
    SizeOfHeader = 12 * Count + sizeof(_cmsTagBase);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1479
    LargestPosition = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1480
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1481
    for (i=0; i < Count; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1483
        if (!_cmsReadUInt16Number(io, &mlu ->Entries[i].Language)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1484
        if (!_cmsReadUInt16Number(io, &mlu ->Entries[i].Country))  goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1485
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1486
        // Now deal with Len and offset.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1487
        if (!_cmsReadUInt32Number(io, &Len)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1488
        if (!_cmsReadUInt32Number(io, &Offset)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1489
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1490
        // Check for overflow
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1491
        if (Offset < (SizeOfHeader + 8)) goto Error;
47419
c08d54553a36 8183028: Improve CMS header processing
prr
parents: 47409
diff changeset
  1492
        if (((Offset + Len) < Len) || ((Offset + Len) > SizeOfTag + 8)) goto Error;
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1493
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1494
        // True begin of the string
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1495
        BeginOfThisString = Offset - SizeOfHeader - 8;
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1496
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1497
        // Ajust to wchar_t elements
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1498
        mlu ->Entries[i].Len = (Len * sizeof(wchar_t)) / sizeof(cmsUInt16Number);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1499
        mlu ->Entries[i].StrW = (BeginOfThisString * sizeof(wchar_t)) / sizeof(cmsUInt16Number);
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1500
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1501
        // To guess maximum size, add offset + len
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1502
        EndOfThisString = BeginOfThisString + Len;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1503
        if (EndOfThisString > LargestPosition)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1504
            LargestPosition = EndOfThisString;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1505
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1506
40152
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  1507
    // Now read the remaining of tag and fill all strings. Subtract the directory
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1508
    SizeOfTag   = (LargestPosition * sizeof(wchar_t)) / sizeof(cmsUInt16Number);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1509
    if (SizeOfTag == 0)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1510
    {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1511
        Block = NULL;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1512
        NumOfWchar = 0;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1513
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1514
    }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1515
    else
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1516
    {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1517
        Block = (wchar_t*) _cmsMalloc(self ->ContextID, SizeOfTag);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1518
        if (Block == NULL) goto Error;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1519
        NumOfWchar = SizeOfTag / sizeof(wchar_t);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1520
        if (!_cmsReadWCharArray(io, NumOfWchar, Block)) goto Error;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1521
    }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1522
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1523
    mlu ->MemPool  = Block;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1524
    mlu ->PoolSize = SizeOfTag;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1525
    mlu ->PoolUsed = SizeOfTag;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1526
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1527
    *nItems = 1;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1528
    return (void*) mlu;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1529
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1530
Error:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1531
    if (mlu) cmsMLUfree(mlu);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1532
    return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1533
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1534
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1535
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1536
cmsBool  Type_MLU_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1537
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1538
    cmsMLU* mlu =(cmsMLU*) Ptr;
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1539
    cmsUInt32Number HeaderSize;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1540
    cmsUInt32Number  Len, Offset;
40152
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  1541
    cmsUInt32Number i;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1542
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1543
    if (Ptr == NULL) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1544
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1545
          // Empty placeholder
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1546
          if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1547
          if (!_cmsWriteUInt32Number(io, 12)) return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1548
          return TRUE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1549
    }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1550
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1551
    if (!_cmsWriteUInt32Number(io, mlu ->UsedEntries)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1552
    if (!_cmsWriteUInt32Number(io, 12)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1553
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1554
    HeaderSize = 12 * mlu ->UsedEntries + sizeof(_cmsTagBase);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1555
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1556
    for (i=0; i < mlu ->UsedEntries; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1557
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1558
        Len    =  mlu ->Entries[i].Len;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1559
        Offset =  mlu ->Entries[i].StrW;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1560
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1561
        Len    = (Len * sizeof(cmsUInt16Number)) / sizeof(wchar_t);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1562
        Offset = (Offset * sizeof(cmsUInt16Number)) / sizeof(wchar_t) + HeaderSize + 8;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1563
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1564
        if (!_cmsWriteUInt16Number(io, mlu ->Entries[i].Language)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1565
        if (!_cmsWriteUInt16Number(io, mlu ->Entries[i].Country))  return FALSE;
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1566
        if (!_cmsWriteUInt32Number(io, Len)) return FALSE;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1567
        if (!_cmsWriteUInt32Number(io, Offset)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1568
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1569
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1570
    if (!_cmsWriteWCharArray(io, mlu ->PoolUsed / sizeof(wchar_t), (wchar_t*)  mlu ->MemPool)) return FALSE;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1571
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1572
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1573
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1574
    cmsUNUSED_PARAMETER(nItems);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1575
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1576
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1577
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1578
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1579
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1580
void* Type_MLU_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1581
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1582
    return (void*) cmsMLUdup((cmsMLU*) Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1583
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1584
    cmsUNUSED_PARAMETER(n);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1585
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1586
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1587
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1588
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1589
void Type_MLU_Free(struct _cms_typehandler_struct* self, void* Ptr)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1590
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1591
    cmsMLUfree((cmsMLU*) Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1592
    return;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1593
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1594
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1595
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1596
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1597
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1598
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1599
// Type cmsSigLut8Type
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1600
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1601
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1602
// Decide which LUT type to use on writting
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1603
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1604
cmsTagTypeSignature DecideLUTtypeA2B(cmsFloat64Number ICCVersion, const void *Data)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1605
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1606
    cmsPipeline* Lut = (cmsPipeline*) Data;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1607
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1608
    if (ICCVersion < 4.0) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1609
        if (Lut ->SaveAs8Bits) return cmsSigLut8Type;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1610
        return cmsSigLut16Type;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1611
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1612
    else {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1613
         return cmsSigLutAtoBType;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1614
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1615
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1616
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1617
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1618
cmsTagTypeSignature DecideLUTtypeB2A(cmsFloat64Number ICCVersion, const void *Data)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1619
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1620
    cmsPipeline* Lut = (cmsPipeline*) Data;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1621
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1622
    if (ICCVersion < 4.0) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1623
        if (Lut ->SaveAs8Bits) return cmsSigLut8Type;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1624
        return cmsSigLut16Type;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1625
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1626
    else {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1627
         return cmsSigLutBtoAType;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1628
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1629
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1630
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1631
/*
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1632
This structure represents a colour transform using tables of 8-bit precision.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1633
This type contains four processing elements: a 3 by 3 matrix (which shall be
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1634
the identity matrix unless the input colour space is XYZ), a set of one dimensional
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1635
input tables, a multidimensional lookup table, and a set of one dimensional output
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1636
tables. Data is processed using these elements via the following sequence:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1637
(matrix) -> (1d input tables)  -> (multidimensional lookup table - CLUT) -> (1d output tables)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1638
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1639
Byte Position   Field Length (bytes)  Content Encoded as...
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1640
8                  1          Number of Input Channels (i)    uInt8Number
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1641
9                  1          Number of Output Channels (o)   uInt8Number
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1642
10                 1          Number of CLUT grid points (identical for each side) (g) uInt8Number
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1643
11                 1          Reserved for padding (fill with 00h)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1644
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1645
12..15             4          Encoded e00 parameter   s15Fixed16Number
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1646
*/
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1647
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1648
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1649
// Read 8 bit tables as gamma functions
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1650
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1651
cmsBool  Read8bitTables(cmsContext ContextID, cmsIOHANDLER* io, cmsPipeline* lut, int nChannels)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1652
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1653
    cmsUInt8Number* Temp = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1654
    int i, j;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1655
    cmsToneCurve* Tables[cmsMAXCHANNELS];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1656
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1657
    if (nChannels > cmsMAXCHANNELS) return FALSE;
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1658
    if (nChannels <= 0) return FALSE;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1659
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1660
    memset(Tables, 0, sizeof(Tables));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1661
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1662
    Temp = (cmsUInt8Number*) _cmsMalloc(ContextID, 256);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1663
    if (Temp == NULL) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1664
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1665
    for (i=0; i < nChannels; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1666
        Tables[i] = cmsBuildTabulatedToneCurve16(ContextID, 256, NULL);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1667
        if (Tables[i] == NULL) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1668
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1669
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1670
    for (i=0; i < nChannels; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1671
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1672
        if (io ->Read(io, Temp, 256, 1) != 1) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1673
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1674
        for (j=0; j < 256; j++)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1675
            Tables[i]->Table16[j] = (cmsUInt16Number) FROM_8_TO_16(Temp[j]);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1676
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1677
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1678
    _cmsFree(ContextID, Temp);
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1679
    Temp = NULL;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1680
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1681
    if (!cmsPipelineInsertStage(lut, cmsAT_END, cmsStageAllocToneCurves(ContextID, nChannels, Tables)))
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1682
        goto Error;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1683
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1684
    for (i=0; i < nChannels; i++)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1685
        cmsFreeToneCurve(Tables[i]);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1686
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1687
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1688
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1689
Error:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1690
    for (i=0; i < nChannels; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1691
        if (Tables[i]) cmsFreeToneCurve(Tables[i]);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1692
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1693
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1694
    if (Temp) _cmsFree(ContextID, Temp);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1695
    return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1696
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1697
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1698
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1699
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1700
cmsBool Write8bitTables(cmsContext ContextID, cmsIOHANDLER* io, cmsUInt32Number n, _cmsStageToneCurvesData* Tables)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1701
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1702
    int j;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1703
    cmsUInt32Number i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1704
    cmsUInt8Number val;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1705
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1706
    for (i=0; i < n; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1707
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1708
        if (Tables) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1709
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1710
            // Usual case of identity curves
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1711
            if ((Tables ->TheCurves[i]->nEntries == 2) &&
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1712
                (Tables->TheCurves[i]->Table16[0] == 0) &&
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1713
                (Tables->TheCurves[i]->Table16[1] == 65535)) {
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1714
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1715
                    for (j=0; j < 256; j++) {
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1716
                        if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) j)) return FALSE;
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1717
                    }
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1718
            }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1719
            else
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1720
                if (Tables ->TheCurves[i]->nEntries != 256) {
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1721
                    cmsSignalError(ContextID, cmsERROR_RANGE, "LUT8 needs 256 entries on prelinearization");
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1722
                    return FALSE;
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1723
                }
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1724
                else
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1725
                    for (j=0; j < 256; j++) {
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1726
30491
ea1c291ee28f 8078331: Upgrade JDK to use LittleCMS 2.7
prr
parents: 26747
diff changeset
  1727
                        val = (cmsUInt8Number) FROM_16_TO_8(Tables->TheCurves[i]->Table16[j]);
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1728
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1729
                        if (!_cmsWriteUInt8Number(io, val)) return FALSE;
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1730
                    }
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1731
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1732
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1733
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1734
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1735
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1736
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1737
// Check overflow
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1738
static
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1739
cmsUInt32Number uipow(cmsUInt32Number n, cmsUInt32Number a, cmsUInt32Number b)
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1740
{
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1741
    cmsUInt32Number rv = 1, rc;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1742
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1743
    if (a == 0) return 0;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1744
    if (n == 0) return 0;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1745
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1746
    for (; b > 0; b--) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1747
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1748
        rv *= a;
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1749
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1750
        // Check for overflow
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1751
        if (rv > UINT_MAX / a) return (cmsUInt32Number) -1;
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1752
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1753
    }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1754
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1755
    rc = rv * n;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1756
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1757
    if (rv != rc / n) return (cmsUInt32Number) -1;
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1758
    return rc;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1759
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1760
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1761
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1762
// That will create a MPE LUT with Matrix, pre tables, CLUT and post tables.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1763
// 8 bit lut may be scaled easely to v4 PCS, but we need also to properly adjust
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1764
// PCS on BToAxx tags and AtoB if abstract. We need to fix input direction.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1765
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1766
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1767
void *Type_LUT8_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1768
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1769
    cmsUInt8Number InputChannels, OutputChannels, CLUTpoints;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1770
    cmsUInt8Number* Temp = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1771
    cmsPipeline* NewLUT = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1772
    cmsUInt32Number nTabSize, i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1773
    cmsFloat64Number Matrix[3*3];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1774
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1775
    *nItems = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1776
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1777
    if (!_cmsReadUInt8Number(io, &InputChannels)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1778
    if (!_cmsReadUInt8Number(io, &OutputChannels)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1779
    if (!_cmsReadUInt8Number(io, &CLUTpoints)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1780
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1781
     if (CLUTpoints == 1) goto Error; // Impossible value, 0 for no CLUT and then 2 at least
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1782
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1783
    // Padding
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1784
    if (!_cmsReadUInt8Number(io, NULL)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1785
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1786
    // Do some checking
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1787
    if (InputChannels > cmsMAXCHANNELS)  goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1788
    if (OutputChannels > cmsMAXCHANNELS) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1789
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1790
   // Allocates an empty Pipeline
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1791
    NewLUT = cmsPipelineAlloc(self ->ContextID, InputChannels, OutputChannels);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1792
    if (NewLUT == NULL) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1793
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1794
    // Read the Matrix
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1795
    if (!_cmsRead15Fixed16Number(io,  &Matrix[0])) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1796
    if (!_cmsRead15Fixed16Number(io,  &Matrix[1])) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1797
    if (!_cmsRead15Fixed16Number(io,  &Matrix[2])) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1798
    if (!_cmsRead15Fixed16Number(io,  &Matrix[3])) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1799
    if (!_cmsRead15Fixed16Number(io,  &Matrix[4])) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1800
    if (!_cmsRead15Fixed16Number(io,  &Matrix[5])) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1801
    if (!_cmsRead15Fixed16Number(io,  &Matrix[6])) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1802
    if (!_cmsRead15Fixed16Number(io,  &Matrix[7])) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1803
    if (!_cmsRead15Fixed16Number(io,  &Matrix[8])) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1804
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1805
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1806
    // Only operates if not identity...
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1807
    if ((InputChannels == 3) && !_cmsMAT3isIdentity((cmsMAT3*) Matrix)) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1808
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1809
        if (!cmsPipelineInsertStage(NewLUT, cmsAT_BEGIN, cmsStageAllocMatrix(self ->ContextID, 3, 3, Matrix, NULL)))
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1810
            goto Error;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1811
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1812
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1813
    // Get input tables
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1814
    if (!Read8bitTables(self ->ContextID, io,  NewLUT, InputChannels)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1815
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1816
    // Get 3D CLUT. Check the overflow....
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1817
    nTabSize = uipow(OutputChannels, CLUTpoints, InputChannels);
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1818
    if (nTabSize == (cmsUInt32Number) -1) goto Error;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1819
    if (nTabSize > 0) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1820
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1821
        cmsUInt16Number *PtrW, *T;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1822
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1823
        PtrW = T  = (cmsUInt16Number*) _cmsCalloc(self ->ContextID, nTabSize, sizeof(cmsUInt16Number));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1824
        if (T  == NULL) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1825
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1826
        Temp = (cmsUInt8Number*) _cmsMalloc(self ->ContextID, nTabSize);
26609
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  1827
        if (Temp == NULL) {
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  1828
            _cmsFree(self ->ContextID, T);
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  1829
            goto Error;
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  1830
        }
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  1831
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  1832
        if (io ->Read(io, Temp, nTabSize, 1) != 1) {
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  1833
            _cmsFree(self ->ContextID, T);
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  1834
            _cmsFree(self ->ContextID, Temp);
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  1835
            goto Error;
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  1836
        }
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1837
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1838
        for (i = 0; i < nTabSize; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1839
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1840
            *PtrW++ = FROM_8_TO_16(Temp[i]);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1841
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1842
        _cmsFree(self ->ContextID, Temp);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1843
        Temp = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1844
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1845
        if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, cmsStageAllocCLut16bit(self ->ContextID, CLUTpoints, InputChannels, OutputChannels, T)))
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1846
            goto Error;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1847
        _cmsFree(self ->ContextID, T);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1848
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1849
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1850
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1851
    // Get output tables
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1852
    if (!Read8bitTables(self ->ContextID, io,  NewLUT, OutputChannels)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1853
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1854
    *nItems = 1;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1855
    return NewLUT;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1856
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1857
Error:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1858
    if (NewLUT != NULL) cmsPipelineFree(NewLUT);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1859
    return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1860
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1861
    cmsUNUSED_PARAMETER(SizeOfTag);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1862
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1863
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1864
// We only allow a specific MPE structure: Matrix plus prelin, plus clut, plus post-lin.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1865
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1866
cmsBool  Type_LUT8_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1867
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1868
    cmsUInt32Number j, nTabSize;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1869
    cmsUInt8Number  val;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1870
    cmsPipeline* NewLUT = (cmsPipeline*) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1871
    cmsStage* mpe;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1872
    _cmsStageToneCurvesData* PreMPE = NULL, *PostMPE = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1873
    _cmsStageMatrixData* MatMPE = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1874
    _cmsStageCLutData* clut = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1875
    int clutPoints;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1876
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1877
    // Disassemble the LUT into components.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1878
    mpe = NewLUT -> Elements;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1879
    if (mpe ->Type == cmsSigMatrixElemType) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1880
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1881
        MatMPE = (_cmsStageMatrixData*) mpe ->Data;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1882
        mpe = mpe -> Next;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1883
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1884
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1885
    if (mpe != NULL && mpe ->Type == cmsSigCurveSetElemType) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1886
        PreMPE = (_cmsStageToneCurvesData*) mpe ->Data;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1887
        mpe = mpe -> Next;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1888
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1889
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1890
    if (mpe != NULL && mpe ->Type == cmsSigCLutElemType) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1891
        clut  = (_cmsStageCLutData*) mpe -> Data;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1892
        mpe = mpe ->Next;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1893
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1894
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1895
    if (mpe != NULL && mpe ->Type == cmsSigCurveSetElemType) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1896
        PostMPE = (_cmsStageToneCurvesData*) mpe ->Data;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1897
        mpe = mpe -> Next;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1898
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1899
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1900
    // That should be all
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1901
    if (mpe != NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1902
        cmsSignalError(mpe->ContextID, cmsERROR_UNKNOWN_EXTENSION, "LUT is not suitable to be saved as LUT8");
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1903
        return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1904
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1905
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1906
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1907
    if (clut == NULL)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1908
        clutPoints = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1909
    else
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1910
        clutPoints    = clut->Params->nSamples[0];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1911
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1912
    if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) NewLUT ->InputChannels)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1913
    if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) NewLUT ->OutputChannels)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1914
    if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) clutPoints)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1915
    if (!_cmsWriteUInt8Number(io, 0)) return FALSE; // Padding
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1916
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1917
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1918
    if (MatMPE != NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1919
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1920
        if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[0])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1921
        if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[1])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1922
        if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[2])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1923
        if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[3])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1924
        if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[4])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1925
        if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[5])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1926
        if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[6])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1927
        if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[7])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1928
        if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[8])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1929
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1930
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1931
    else {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1932
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1933
        if (!_cmsWrite15Fixed16Number(io, 1)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1934
        if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1935
        if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1936
        if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1937
        if (!_cmsWrite15Fixed16Number(io, 1)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1938
        if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1939
        if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1940
        if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1941
        if (!_cmsWrite15Fixed16Number(io, 1)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1942
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1943
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1944
    // The prelinearization table
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1945
    if (!Write8bitTables(self ->ContextID, io, NewLUT ->InputChannels, PreMPE)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1946
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1947
    nTabSize = uipow(NewLUT->OutputChannels, clutPoints, NewLUT ->InputChannels);
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  1948
    if (nTabSize == (cmsUInt32Number) -1) return FALSE;
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1949
    if (nTabSize > 0) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1950
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1951
        // The 3D CLUT.
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1952
        if (clut != NULL) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1953
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1954
            for (j=0; j < nTabSize; j++) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1955
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1956
                val = (cmsUInt8Number) FROM_16_TO_8(clut ->Tab.T[j]);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1957
                if (!_cmsWriteUInt8Number(io, val)) return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1958
            }
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1959
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1960
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1961
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1962
    // The postlinearization table
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1963
    if (!Write8bitTables(self ->ContextID, io, NewLUT ->OutputChannels, PostMPE)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1964
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1965
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1966
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1967
    cmsUNUSED_PARAMETER(nItems);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1968
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1969
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1970
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1971
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1972
void* Type_LUT8_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1973
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1974
    return (void*) cmsPipelineDup((cmsPipeline*) Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1975
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1976
    cmsUNUSED_PARAMETER(n);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1977
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1978
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1979
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1980
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1981
void Type_LUT8_Free(struct _cms_typehandler_struct* self, void* Ptr)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1982
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1983
    cmsPipelineFree((cmsPipeline*) Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1984
    return;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1985
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1986
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1987
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1988
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1989
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1990
// Type cmsSigLut16Type
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1991
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1992
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1993
// Read 16 bit tables as gamma functions
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1994
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1995
cmsBool  Read16bitTables(cmsContext ContextID, cmsIOHANDLER* io, cmsPipeline* lut, int nChannels, int nEntries)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1996
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1997
    int i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1998
    cmsToneCurve* Tables[cmsMAXCHANNELS];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  1999
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2000
    // Maybe an empty table? (this is a lcms extension)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2001
    if (nEntries <= 0) return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2002
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2003
    // Check for malicious profiles
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2004
    if (nEntries < 2) return FALSE;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2005
    if (nChannels > cmsMAXCHANNELS) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2006
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2007
    // Init table to zero
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2008
    memset(Tables, 0, sizeof(Tables));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2009
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2010
    for (i=0; i < nChannels; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2011
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2012
        Tables[i] = cmsBuildTabulatedToneCurve16(ContextID, nEntries, NULL);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2013
        if (Tables[i] == NULL) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2014
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2015
        if (!_cmsReadUInt16Array(io, nEntries, Tables[i]->Table16)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2016
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2017
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2018
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2019
    // Add the table (which may certainly be an identity, but this is up to the optimizer, not the reading code)
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2020
    if (!cmsPipelineInsertStage(lut, cmsAT_END, cmsStageAllocToneCurves(ContextID, nChannels, Tables)))
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2021
        goto Error;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2022
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2023
    for (i=0; i < nChannels; i++)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2024
        cmsFreeToneCurve(Tables[i]);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2025
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2026
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2027
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2028
Error:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2029
    for (i=0; i < nChannels; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2030
        if (Tables[i]) cmsFreeToneCurve(Tables[i]);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2031
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2032
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2033
    return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2034
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2035
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2036
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2037
cmsBool Write16bitTables(cmsContext ContextID, cmsIOHANDLER* io, _cmsStageToneCurvesData* Tables)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2038
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2039
    int j;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2040
    cmsUInt32Number i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2041
    cmsUInt16Number val;
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2042
    int nEntries;
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2043
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2044
    _cmsAssert(Tables != NULL);
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2045
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2046
    nEntries = Tables->TheCurves[0]->nEntries;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2047
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2048
    for (i=0; i < Tables ->nCurves; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2049
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2050
        for (j=0; j < nEntries; j++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2051
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2052
            val = Tables->TheCurves[i]->Table16[j];
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2053
            if (!_cmsWriteUInt16Number(io, val)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2054
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2055
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2056
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2057
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2058
    cmsUNUSED_PARAMETER(ContextID);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2059
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2060
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2061
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2062
void *Type_LUT16_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2063
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2064
    cmsUInt8Number InputChannels, OutputChannels, CLUTpoints;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2065
    cmsPipeline* NewLUT = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2066
    cmsUInt32Number nTabSize;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2067
    cmsFloat64Number Matrix[3*3];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2068
    cmsUInt16Number InputEntries, OutputEntries;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2069
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2070
    *nItems = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2071
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2072
    if (!_cmsReadUInt8Number(io, &InputChannels)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2073
    if (!_cmsReadUInt8Number(io, &OutputChannels)) return NULL;
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2074
    if (!_cmsReadUInt8Number(io, &CLUTpoints)) return NULL;   // 255 maximum
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2075
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2076
    // Padding
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2077
    if (!_cmsReadUInt8Number(io, NULL)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2078
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2079
    // Do some checking
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2080
    if (InputChannels > cmsMAXCHANNELS)  goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2081
    if (OutputChannels > cmsMAXCHANNELS) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2082
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2083
    // Allocates an empty LUT
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2084
    NewLUT = cmsPipelineAlloc(self ->ContextID, InputChannels, OutputChannels);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2085
    if (NewLUT == NULL) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2086
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2087
    // Read the Matrix
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2088
    if (!_cmsRead15Fixed16Number(io,  &Matrix[0])) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2089
    if (!_cmsRead15Fixed16Number(io,  &Matrix[1])) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2090
    if (!_cmsRead15Fixed16Number(io,  &Matrix[2])) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2091
    if (!_cmsRead15Fixed16Number(io,  &Matrix[3])) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2092
    if (!_cmsRead15Fixed16Number(io,  &Matrix[4])) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2093
    if (!_cmsRead15Fixed16Number(io,  &Matrix[5])) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2094
    if (!_cmsRead15Fixed16Number(io,  &Matrix[6])) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2095
    if (!_cmsRead15Fixed16Number(io,  &Matrix[7])) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2096
    if (!_cmsRead15Fixed16Number(io,  &Matrix[8])) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2097
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2098
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2099
    // Only operates on 3 channels
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2100
    if ((InputChannels == 3) && !_cmsMAT3isIdentity((cmsMAT3*) Matrix)) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2101
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2102
        if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, cmsStageAllocMatrix(self ->ContextID, 3, 3, Matrix, NULL)))
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2103
            goto Error;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2104
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2105
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2106
    if (!_cmsReadUInt16Number(io, &InputEntries)) goto Error;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2107
    if (!_cmsReadUInt16Number(io, &OutputEntries)) goto Error;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2108
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2109
    if (InputEntries > 0x7FFF || OutputEntries > 0x7FFF) goto Error;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2110
    if (CLUTpoints == 1) goto Error; // Impossible value, 0 for no CLUT and then 2 at least
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2111
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2112
    // Get input tables
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2113
    if (!Read16bitTables(self ->ContextID, io,  NewLUT, InputChannels, InputEntries)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2114
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2115
    // Get 3D CLUT
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2116
    nTabSize = uipow(OutputChannels, CLUTpoints, InputChannels);
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2117
    if (nTabSize == (cmsUInt32Number) -1) goto Error;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2118
    if (nTabSize > 0) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2119
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2120
        cmsUInt16Number *T;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2121
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2122
        T  = (cmsUInt16Number*) _cmsCalloc(self ->ContextID, nTabSize, sizeof(cmsUInt16Number));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2123
        if (T  == NULL) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2124
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2125
        if (!_cmsReadUInt16Array(io, nTabSize, T)) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2126
            _cmsFree(self ->ContextID, T);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2127
            goto Error;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2128
        }
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2129
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2130
        if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, cmsStageAllocCLut16bit(self ->ContextID, CLUTpoints, InputChannels, OutputChannels, T))) {
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2131
            _cmsFree(self ->ContextID, T);
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2132
            goto Error;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2133
        }
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2134
        _cmsFree(self ->ContextID, T);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2135
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2136
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2137
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2138
    // Get output tables
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2139
    if (!Read16bitTables(self ->ContextID, io,  NewLUT, OutputChannels, OutputEntries)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2140
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2141
    *nItems = 1;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2142
    return NewLUT;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2143
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2144
Error:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2145
    if (NewLUT != NULL) cmsPipelineFree(NewLUT);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2146
    return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2147
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2148
    cmsUNUSED_PARAMETER(SizeOfTag);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2149
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2150
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2151
// We only allow some specific MPE structures: Matrix plus prelin, plus clut, plus post-lin.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2152
// Some empty defaults are created for missing parts
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2153
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2154
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2155
cmsBool  Type_LUT16_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2156
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2157
    cmsUInt32Number nTabSize;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2158
    cmsPipeline* NewLUT = (cmsPipeline*) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2159
    cmsStage* mpe;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2160
    _cmsStageToneCurvesData* PreMPE = NULL, *PostMPE = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2161
    _cmsStageMatrixData* MatMPE = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2162
    _cmsStageCLutData* clut = NULL;
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2163
    int i, InputChannels, OutputChannels, clutPoints;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2164
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2165
    // Disassemble the LUT into components.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2166
    mpe = NewLUT -> Elements;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2167
    if (mpe != NULL && mpe ->Type == cmsSigMatrixElemType) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2168
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2169
        MatMPE = (_cmsStageMatrixData*) mpe ->Data;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2170
        mpe = mpe -> Next;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2171
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2172
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2173
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2174
    if (mpe != NULL && mpe ->Type == cmsSigCurveSetElemType) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2175
        PreMPE = (_cmsStageToneCurvesData*) mpe ->Data;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2176
        mpe = mpe -> Next;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2177
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2178
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2179
    if (mpe != NULL && mpe ->Type == cmsSigCLutElemType) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2180
        clut  = (_cmsStageCLutData*) mpe -> Data;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2181
        mpe = mpe ->Next;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2182
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2183
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2184
    if (mpe != NULL && mpe ->Type == cmsSigCurveSetElemType) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2185
        PostMPE = (_cmsStageToneCurvesData*) mpe ->Data;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2186
        mpe = mpe -> Next;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2187
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2188
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2189
    // That should be all
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2190
    if (mpe != NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2191
        cmsSignalError(mpe->ContextID, cmsERROR_UNKNOWN_EXTENSION, "LUT is not suitable to be saved as LUT16");
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2192
        return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2193
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2194
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2195
    InputChannels  = cmsPipelineInputChannels(NewLUT);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2196
    OutputChannels = cmsPipelineOutputChannels(NewLUT);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2197
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2198
    if (clut == NULL)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2199
        clutPoints = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2200
    else
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2201
        clutPoints    = clut->Params->nSamples[0];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2202
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2203
    if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) InputChannels)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2204
    if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) OutputChannels)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2205
    if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) clutPoints)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2206
    if (!_cmsWriteUInt8Number(io, 0)) return FALSE; // Padding
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2207
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2208
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2209
    if (MatMPE != NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2210
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2211
        if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[0])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2212
        if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[1])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2213
        if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[2])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2214
        if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[3])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2215
        if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[4])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2216
        if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[5])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2217
        if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[6])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2218
        if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[7])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2219
        if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[8])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2220
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2221
    else {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2222
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2223
        if (!_cmsWrite15Fixed16Number(io, 1)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2224
        if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2225
        if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2226
        if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2227
        if (!_cmsWrite15Fixed16Number(io, 1)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2228
        if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2229
        if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2230
        if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2231
        if (!_cmsWrite15Fixed16Number(io, 1)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2232
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2233
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2234
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2235
    if (PreMPE != NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2236
        if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) PreMPE ->TheCurves[0]->nEntries)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2237
    } else {
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2238
            if (!_cmsWriteUInt16Number(io, 2)) return FALSE;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2239
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2240
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2241
    if (PostMPE != NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2242
        if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) PostMPE ->TheCurves[0]->nEntries)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2243
    } else {
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2244
        if (!_cmsWriteUInt16Number(io, 2)) return FALSE;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2245
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2246
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2247
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2248
    // The prelinearization table
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2249
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2250
    if (PreMPE != NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2251
        if (!Write16bitTables(self ->ContextID, io, PreMPE)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2252
    }
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2253
    else {
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2254
        for (i=0; i < InputChannels; i++) {
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2255
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2256
            if (!_cmsWriteUInt16Number(io, 0)) return FALSE;
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2257
            if (!_cmsWriteUInt16Number(io, 0xffff)) return FALSE;
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2258
        }
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2259
    }
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2260
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2261
    nTabSize = uipow(OutputChannels, clutPoints, InputChannels);
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2262
    if (nTabSize == (cmsUInt32Number) -1) return FALSE;
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2263
    if (nTabSize > 0) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2264
        // The 3D CLUT.
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2265
        if (clut != NULL) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2266
            if (!_cmsWriteUInt16Array(io, nTabSize, clut->Tab.T)) return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2267
        }
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2268
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2269
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2270
    // The postlinearization table
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2271
    if (PostMPE != NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2272
        if (!Write16bitTables(self ->ContextID, io, PostMPE)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2273
    }
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2274
    else {
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2275
        for (i=0; i < OutputChannels; i++) {
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2276
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2277
            if (!_cmsWriteUInt16Number(io, 0)) return FALSE;
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2278
            if (!_cmsWriteUInt16Number(io, 0xffff)) return FALSE;
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2279
        }
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2280
    }
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2281
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2282
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2283
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2284
    cmsUNUSED_PARAMETER(nItems);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2285
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2286
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2287
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2288
void* Type_LUT16_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2289
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2290
    return (void*) cmsPipelineDup((cmsPipeline*) Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2291
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2292
    cmsUNUSED_PARAMETER(n);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2293
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2294
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2295
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2296
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2297
void Type_LUT16_Free(struct _cms_typehandler_struct* self, void* Ptr)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2298
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2299
    cmsPipelineFree((cmsPipeline*) Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2300
    return;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2301
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2302
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2303
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2304
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2305
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2306
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2307
// Type cmsSigLutAToBType
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2308
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2309
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2310
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2311
// V4 stuff. Read matrix for LutAtoB and LutBtoA
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2312
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2313
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2314
cmsStage* ReadMatrix(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number Offset)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2315
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2316
    cmsFloat64Number dMat[3*3];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2317
    cmsFloat64Number dOff[3];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2318
    cmsStage* Mat;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2319
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2320
    // Go to address
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2321
    if (!io -> Seek(io, Offset)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2322
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2323
    // Read the Matrix
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2324
    if (!_cmsRead15Fixed16Number(io, &dMat[0])) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2325
    if (!_cmsRead15Fixed16Number(io, &dMat[1])) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2326
    if (!_cmsRead15Fixed16Number(io, &dMat[2])) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2327
    if (!_cmsRead15Fixed16Number(io, &dMat[3])) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2328
    if (!_cmsRead15Fixed16Number(io, &dMat[4])) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2329
    if (!_cmsRead15Fixed16Number(io, &dMat[5])) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2330
    if (!_cmsRead15Fixed16Number(io, &dMat[6])) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2331
    if (!_cmsRead15Fixed16Number(io, &dMat[7])) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2332
    if (!_cmsRead15Fixed16Number(io, &dMat[8])) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2333
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2334
    if (!_cmsRead15Fixed16Number(io, &dOff[0])) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2335
    if (!_cmsRead15Fixed16Number(io, &dOff[1])) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2336
    if (!_cmsRead15Fixed16Number(io, &dOff[2])) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2337
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2338
    Mat = cmsStageAllocMatrix(self ->ContextID, 3, 3, dMat, dOff);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2339
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2340
     return Mat;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2341
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2342
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2343
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2344
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2345
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2346
//  V4 stuff. Read CLUT part for LutAtoB and LutBtoA
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2347
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2348
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2349
cmsStage* ReadCLUT(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number Offset, int InputChannels, int OutputChannels)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2350
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2351
    cmsUInt8Number  gridPoints8[cmsMAXCHANNELS]; // Number of grid points in each dimension.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2352
    cmsUInt32Number GridPoints[cmsMAXCHANNELS], i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2353
    cmsUInt8Number  Precision;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2354
    cmsStage* CLUT;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2355
    _cmsStageCLutData* Data;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2356
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2357
    if (!io -> Seek(io, Offset)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2358
    if (io -> Read(io, gridPoints8, cmsMAXCHANNELS, 1) != 1) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2359
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2360
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2361
    for (i=0; i < cmsMAXCHANNELS; i++) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2362
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2363
        if (gridPoints8[i] == 1) return NULL; // Impossible value, 0 for no CLUT and then 2 at least
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2364
        GridPoints[i] = gridPoints8[i];
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2365
    }
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2366
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2367
    if (!_cmsReadUInt8Number(io, &Precision)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2368
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2369
    if (!_cmsReadUInt8Number(io, NULL)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2370
    if (!_cmsReadUInt8Number(io, NULL)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2371
    if (!_cmsReadUInt8Number(io, NULL)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2372
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2373
    CLUT = cmsStageAllocCLut16bitGranular(self ->ContextID, GridPoints, InputChannels, OutputChannels, NULL);
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2374
    if (CLUT == NULL) return NULL;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2375
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2376
    Data = (_cmsStageCLutData*) CLUT ->Data;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2377
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2378
    // Precision can be 1 or 2 bytes
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2379
    if (Precision == 1) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2380
26609
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  2381
        cmsUInt8Number  v;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2382
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2383
        for (i=0; i < Data ->nEntries; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2384
26609
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  2385
            if (io ->Read(io, &v, sizeof(cmsUInt8Number), 1) != 1) return NULL;
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  2386
            Data ->Tab.T[i] = FROM_8_TO_16(v);
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2387
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2388
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2389
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2390
    else
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2391
        if (Precision == 2) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2392
26609
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  2393
            if (!_cmsReadUInt16Array(io, Data->nEntries, Data ->Tab.T)) {
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  2394
                cmsStageFree(CLUT);
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  2395
                return NULL;
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  2396
            }
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  2397
        }
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  2398
        else {
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  2399
            cmsStageFree(CLUT);
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  2400
            cmsSignalError(self ->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unknown precision of '%d'", Precision);
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  2401
            return NULL;
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  2402
        }
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  2403
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  2404
        return CLUT;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2405
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2406
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2407
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2408
cmsToneCurve* ReadEmbeddedCurve(struct _cms_typehandler_struct* self, cmsIOHANDLER* io)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2409
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2410
    cmsTagTypeSignature  BaseType;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2411
    cmsUInt32Number nItems;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2412
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2413
    BaseType = _cmsReadTypeBase(io);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2414
    switch (BaseType) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2415
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2416
            case cmsSigCurveType:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2417
                return (cmsToneCurve*) Type_Curve_Read(self, io, &nItems, 0);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2418
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2419
            case cmsSigParametricCurveType:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2420
                return (cmsToneCurve*) Type_ParametricCurve_Read(self, io, &nItems, 0);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2421
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2422
            default:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2423
                {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2424
                    char String[5];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2425
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2426
                    _cmsTagSignature2String(String, (cmsTagSignature) BaseType);
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2427
                    cmsSignalError(self ->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unknown curve type '%s'", String);
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2428
                }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2429
                return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2430
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2431
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2432
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2433
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2434
// Read a set of curves from specific offset
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2435
static
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2436
cmsStage* ReadSetOfCurves(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number Offset, cmsUInt32Number nCurves)
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2437
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2438
    cmsToneCurve* Curves[cmsMAXCHANNELS];
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2439
    cmsUInt32Number i;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2440
    cmsStage* Lin = NULL;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2441
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2442
    if (nCurves > cmsMAXCHANNELS) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2443
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2444
    if (!io -> Seek(io, Offset)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2445
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2446
    for (i=0; i < nCurves; i++)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2447
        Curves[i] = NULL;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2448
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2449
    for (i=0; i < nCurves; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2450
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2451
        Curves[i] = ReadEmbeddedCurve(self, io);
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2452
        if (Curves[i] == NULL) goto Error;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2453
        if (!_cmsReadAlignment(io)) goto Error;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2454
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2455
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2456
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2457
    Lin = cmsStageAllocToneCurves(self ->ContextID, nCurves, Curves);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2458
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2459
Error:
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2460
    for (i=0; i < nCurves; i++)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2461
        cmsFreeToneCurve(Curves[i]);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2462
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2463
    return Lin;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2464
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2465
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2466
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2467
// LutAtoB type
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2468
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2469
// This structure represents a colour transform. The type contains up to five processing
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2470
// elements which are stored in the AtoBTag tag in the following order: a set of one
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2471
// dimensional curves, a 3 by 3 matrix with offset terms, a set of one dimensional curves,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2472
// a multidimensional lookup table, and a set of one dimensional output curves.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2473
// Data are processed using these elements via the following sequence:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2474
//
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2475
//("A" curves) -> (multidimensional lookup table - CLUT) -> ("M" curves) -> (matrix) -> ("B" curves).
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2476
//
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2477
/*
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2478
It is possible to use any or all of these processing elements. At least one processing element
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2479
must be included.Only the following combinations are allowed:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2480
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2481
B
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2482
M - Matrix - B
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2483
A - CLUT - B
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2484
A - CLUT - M - Matrix - B
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2485
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2486
*/
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2487
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2488
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2489
void* Type_LUTA2B_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2490
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2491
    cmsUInt32Number      BaseOffset;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2492
    cmsUInt8Number       inputChan;      // Number of input channels
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2493
    cmsUInt8Number       outputChan;     // Number of output channels
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2494
    cmsUInt32Number      offsetB;        // Offset to first "B" curve
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2495
    cmsUInt32Number      offsetMat;      // Offset to matrix
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2496
    cmsUInt32Number      offsetM;        // Offset to first "M" curve
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2497
    cmsUInt32Number      offsetC;        // Offset to CLUT
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2498
    cmsUInt32Number      offsetA;        // Offset to first "A" curve
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2499
    cmsPipeline* NewLUT = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2500
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2501
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2502
    BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2503
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2504
    if (!_cmsReadUInt8Number(io, &inputChan)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2505
    if (!_cmsReadUInt8Number(io, &outputChan)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2506
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2507
    if (!_cmsReadUInt16Number(io, NULL)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2508
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2509
    if (!_cmsReadUInt32Number(io, &offsetB)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2510
    if (!_cmsReadUInt32Number(io, &offsetMat)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2511
    if (!_cmsReadUInt32Number(io, &offsetM)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2512
    if (!_cmsReadUInt32Number(io, &offsetC)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2513
    if (!_cmsReadUInt32Number(io, &offsetA)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2514
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2515
   // Allocates an empty LUT
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2516
    NewLUT = cmsPipelineAlloc(self ->ContextID, inputChan, outputChan);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2517
    if (NewLUT == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2518
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2519
    if (offsetA!= 0) {
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2520
        if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, ReadSetOfCurves(self, io, BaseOffset + offsetA, inputChan)))
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2521
            goto Error;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2522
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2523
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2524
    if (offsetC != 0) {
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2525
        if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, ReadCLUT(self, io, BaseOffset + offsetC, inputChan, outputChan)))
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2526
            goto Error;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2527
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2528
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2529
    if (offsetM != 0) {
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2530
        if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, ReadSetOfCurves(self, io, BaseOffset + offsetM, outputChan)))
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2531
            goto Error;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2532
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2533
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2534
    if (offsetMat != 0) {
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2535
        if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, ReadMatrix(self, io, BaseOffset + offsetMat)))
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2536
            goto Error;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2537
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2538
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2539
    if (offsetB != 0) {
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2540
        if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, ReadSetOfCurves(self, io, BaseOffset + offsetB, outputChan)))
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2541
            goto Error;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2542
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2543
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2544
    *nItems = 1;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2545
    return NewLUT;
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2546
Error:
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2547
    cmsPipelineFree(NewLUT);
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2548
    return NULL;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2549
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2550
    cmsUNUSED_PARAMETER(SizeOfTag);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2551
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2552
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2553
// Write a set of curves
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2554
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2555
cmsBool  WriteMatrix(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsStage* mpe)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2556
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2557
    _cmsStageMatrixData* m = (_cmsStageMatrixData*) mpe -> Data;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2558
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2559
    // Write the Matrix
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2560
    if (!_cmsWrite15Fixed16Number(io, m -> Double[0])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2561
    if (!_cmsWrite15Fixed16Number(io, m -> Double[1])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2562
    if (!_cmsWrite15Fixed16Number(io, m -> Double[2])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2563
    if (!_cmsWrite15Fixed16Number(io, m -> Double[3])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2564
    if (!_cmsWrite15Fixed16Number(io, m -> Double[4])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2565
    if (!_cmsWrite15Fixed16Number(io, m -> Double[5])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2566
    if (!_cmsWrite15Fixed16Number(io, m -> Double[6])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2567
    if (!_cmsWrite15Fixed16Number(io, m -> Double[7])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2568
    if (!_cmsWrite15Fixed16Number(io, m -> Double[8])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2569
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2570
    if (m ->Offset != NULL) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2571
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2572
    if (!_cmsWrite15Fixed16Number(io, m -> Offset[0])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2573
    if (!_cmsWrite15Fixed16Number(io, m -> Offset[1])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2574
    if (!_cmsWrite15Fixed16Number(io, m -> Offset[2])) return FALSE;
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2575
    }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2576
    else {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2577
        if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2578
        if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2579
        if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2580
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2581
    }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2582
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2583
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2584
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2585
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2586
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2587
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2588
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2589
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2590
// Write a set of curves
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2591
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2592
cmsBool WriteSetOfCurves(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsTagTypeSignature Type, cmsStage* mpe)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2593
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2594
    cmsUInt32Number i, n;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2595
    cmsTagTypeSignature CurrentType;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2596
    cmsToneCurve** Curves;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2597
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2598
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2599
    n      = cmsStageOutputChannels(mpe);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2600
    Curves = _cmsStageGetPtrToCurveSet(mpe);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2601
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2602
    for (i=0; i < n; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2603
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2604
        // If this is a table-based curve, use curve type even on V4
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2605
        CurrentType = Type;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2606
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2607
        if ((Curves[i] ->nSegments == 0)||
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2608
            ((Curves[i]->nSegments == 2) && (Curves[i] ->Segments[1].Type == 0)) )
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2609
            CurrentType = cmsSigCurveType;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2610
        else
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2611
        if (Curves[i] ->Segments[0].Type < 0)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2612
            CurrentType = cmsSigCurveType;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2613
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2614
        if (!_cmsWriteTypeBase(io, CurrentType)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2615
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2616
        switch (CurrentType) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2617
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2618
            case cmsSigCurveType:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2619
                if (!Type_Curve_Write(self, io, Curves[i], 1)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2620
                break;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2621
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2622
            case cmsSigParametricCurveType:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2623
                if (!Type_ParametricCurve_Write(self, io, Curves[i], 1)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2624
                break;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2625
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2626
            default:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2627
                {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2628
                    char String[5];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2629
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2630
                    _cmsTagSignature2String(String, (cmsTagSignature) Type);
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2631
                    cmsSignalError(self ->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unknown curve type '%s'", String);
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2632
                }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2633
                return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2634
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2635
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2636
        if (!_cmsWriteAlignment(io)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2637
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2638
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2639
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2640
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2641
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2642
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2643
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2644
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2645
cmsBool WriteCLUT(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt8Number  Precision, cmsStage* mpe)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2646
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2647
    cmsUInt8Number  gridPoints[cmsMAXCHANNELS]; // Number of grid points in each dimension.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2648
    cmsUInt32Number i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2649
    _cmsStageCLutData* CLUT = ( _cmsStageCLutData*) mpe -> Data;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2650
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2651
    if (CLUT ->HasFloatValues) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2652
         cmsSignalError(self ->ContextID, cmsERROR_NOT_SUITABLE, "Cannot save floating point data, CLUT are 8 or 16 bit only");
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2653
         return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2654
    }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2655
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2656
    memset(gridPoints, 0, sizeof(gridPoints));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2657
    for (i=0; i < (cmsUInt32Number) CLUT ->Params ->nInputs; i++)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2658
        gridPoints[i] = (cmsUInt8Number) CLUT ->Params ->nSamples[i];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2659
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2660
    if (!io -> Write(io, cmsMAXCHANNELS*sizeof(cmsUInt8Number), gridPoints)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2661
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2662
    if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) Precision)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2663
    if (!_cmsWriteUInt8Number(io, 0)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2664
    if (!_cmsWriteUInt8Number(io, 0)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2665
    if (!_cmsWriteUInt8Number(io, 0)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2666
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2667
    // Precision can be 1 or 2 bytes
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2668
    if (Precision == 1) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2669
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2670
        for (i=0; i < CLUT->nEntries; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2671
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2672
            if (!_cmsWriteUInt8Number(io, FROM_16_TO_8(CLUT->Tab.T[i]))) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2673
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2674
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2675
    else
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2676
        if (Precision == 2) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2677
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2678
            if (!_cmsWriteUInt16Array(io, CLUT->nEntries, CLUT ->Tab.T)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2679
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2680
        else {
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  2681
             cmsSignalError(self ->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unknown precision of '%d'", Precision);
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2682
            return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2683
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2684
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2685
        if (!_cmsWriteAlignment(io)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2686
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2687
        return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2688
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2689
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2690
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2691
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2692
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2693
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2694
cmsBool Type_LUTA2B_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2695
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2696
    cmsPipeline* Lut = (cmsPipeline*) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2697
    int inputChan, outputChan;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2698
    cmsStage *A = NULL, *B = NULL, *M = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2699
    cmsStage * Matrix = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2700
    cmsStage * CLUT = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2701
    cmsUInt32Number offsetB = 0, offsetMat = 0, offsetM = 0, offsetC = 0, offsetA = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2702
    cmsUInt32Number BaseOffset, DirectoryPos, CurrentPos;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2703
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2704
    // Get the base for all offsets
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2705
    BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2706
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2707
    if (Lut ->Elements != NULL)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2708
        if (!cmsPipelineCheckAndRetreiveStages(Lut, 1, cmsSigCurveSetElemType, &B))
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2709
            if (!cmsPipelineCheckAndRetreiveStages(Lut, 3, cmsSigCurveSetElemType, cmsSigMatrixElemType, cmsSigCurveSetElemType, &M, &Matrix, &B))
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2710
                if (!cmsPipelineCheckAndRetreiveStages(Lut, 3, cmsSigCurveSetElemType, cmsSigCLutElemType, cmsSigCurveSetElemType, &A, &CLUT, &B))
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2711
                    if (!cmsPipelineCheckAndRetreiveStages(Lut, 5, cmsSigCurveSetElemType, cmsSigCLutElemType, cmsSigCurveSetElemType,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2712
                        cmsSigMatrixElemType, cmsSigCurveSetElemType, &A, &CLUT, &M, &Matrix, &B)) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2713
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2714
                            cmsSignalError(self->ContextID, cmsERROR_NOT_SUITABLE, "LUT is not suitable to be saved as LutAToB");
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2715
                            return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2716
                    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2717
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2718
    // Get input, output channels
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2719
    inputChan  = cmsPipelineInputChannels(Lut);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2720
    outputChan = cmsPipelineOutputChannels(Lut);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2721
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2722
    // Write channel count
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2723
    if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) inputChan)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2724
    if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) outputChan)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2725
    if (!_cmsWriteUInt16Number(io, 0)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2726
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2727
    // Keep directory to be filled latter
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2728
    DirectoryPos = io ->Tell(io);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2729
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2730
    // Write the directory
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2731
    if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2732
    if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2733
    if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2734
    if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2735
    if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2736
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2737
    if (A != NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2738
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2739
        offsetA = io ->Tell(io) - BaseOffset;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2740
        if (!WriteSetOfCurves(self, io, cmsSigParametricCurveType, A)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2741
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2742
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2743
    if (CLUT != NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2744
        offsetC = io ->Tell(io) - BaseOffset;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2745
        if (!WriteCLUT(self, io, Lut ->SaveAs8Bits ? 1 : 2, CLUT)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2746
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2747
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2748
    if (M != NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2749
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2750
        offsetM = io ->Tell(io) - BaseOffset;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2751
        if (!WriteSetOfCurves(self, io, cmsSigParametricCurveType, M)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2752
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2753
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2754
    if (Matrix != NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2755
        offsetMat = io ->Tell(io) - BaseOffset;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2756
        if (!WriteMatrix(self, io, Matrix)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2757
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2758
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2759
    if (B != NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2760
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2761
        offsetB = io ->Tell(io) - BaseOffset;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2762
        if (!WriteSetOfCurves(self, io, cmsSigParametricCurveType, B)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2763
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2764
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2765
    CurrentPos = io ->Tell(io);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2766
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2767
    if (!io ->Seek(io, DirectoryPos)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2768
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2769
    if (!_cmsWriteUInt32Number(io, offsetB)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2770
    if (!_cmsWriteUInt32Number(io, offsetMat)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2771
    if (!_cmsWriteUInt32Number(io, offsetM)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2772
    if (!_cmsWriteUInt32Number(io, offsetC)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2773
    if (!_cmsWriteUInt32Number(io, offsetA)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2774
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2775
    if (!io ->Seek(io, CurrentPos)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2776
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2777
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2778
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2779
    cmsUNUSED_PARAMETER(nItems);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2780
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2781
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2782
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2783
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2784
void* Type_LUTA2B_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2785
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2786
    return (void*) cmsPipelineDup((cmsPipeline*) Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2787
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2788
    cmsUNUSED_PARAMETER(n);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2789
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2790
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2791
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2792
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2793
void Type_LUTA2B_Free(struct _cms_typehandler_struct* self, void* Ptr)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2794
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2795
    cmsPipelineFree((cmsPipeline*) Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2796
    return;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2797
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2798
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2799
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2800
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2801
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2802
// LutBToA type
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2803
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2804
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2805
void* Type_LUTB2A_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2806
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2807
    cmsUInt8Number       inputChan;      // Number of input channels
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2808
    cmsUInt8Number       outputChan;     // Number of output channels
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2809
    cmsUInt32Number      BaseOffset;     // Actual position in file
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2810
    cmsUInt32Number      offsetB;        // Offset to first "B" curve
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2811
    cmsUInt32Number      offsetMat;      // Offset to matrix
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2812
    cmsUInt32Number      offsetM;        // Offset to first "M" curve
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2813
    cmsUInt32Number      offsetC;        // Offset to CLUT
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2814
    cmsUInt32Number      offsetA;        // Offset to first "A" curve
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2815
    cmsPipeline* NewLUT = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2816
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2817
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2818
    BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2819
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2820
    if (!_cmsReadUInt8Number(io, &inputChan)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2821
    if (!_cmsReadUInt8Number(io, &outputChan)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2822
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2823
    // Padding
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2824
    if (!_cmsReadUInt16Number(io, NULL)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2825
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2826
    if (!_cmsReadUInt32Number(io, &offsetB)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2827
    if (!_cmsReadUInt32Number(io, &offsetMat)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2828
    if (!_cmsReadUInt32Number(io, &offsetM)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2829
    if (!_cmsReadUInt32Number(io, &offsetC)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2830
    if (!_cmsReadUInt32Number(io, &offsetA)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2831
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2832
    // Allocates an empty LUT
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2833
    NewLUT = cmsPipelineAlloc(self ->ContextID, inputChan, outputChan);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2834
    if (NewLUT == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2835
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2836
    if (offsetB != 0) {
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2837
        if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, ReadSetOfCurves(self, io, BaseOffset + offsetB, inputChan)))
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2838
            goto Error;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2839
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2840
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2841
    if (offsetMat != 0) {
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2842
        if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, ReadMatrix(self, io, BaseOffset + offsetMat)))
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2843
            goto Error;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2844
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2845
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2846
    if (offsetM != 0) {
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2847
        if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, ReadSetOfCurves(self, io, BaseOffset + offsetM, inputChan)))
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2848
            goto Error;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2849
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2850
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2851
    if (offsetC != 0) {
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2852
        if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, ReadCLUT(self, io, BaseOffset + offsetC, inputChan, outputChan)))
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2853
            goto Error;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2854
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2855
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2856
    if (offsetA!= 0) {
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2857
        if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, ReadSetOfCurves(self, io, BaseOffset + offsetA, outputChan)))
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2858
            goto Error;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2859
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2860
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2861
    *nItems = 1;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2862
    return NewLUT;
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2863
Error:
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2864
    cmsPipelineFree(NewLUT);
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  2865
    return NULL;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2866
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2867
    cmsUNUSED_PARAMETER(SizeOfTag);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2868
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2869
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2870
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2871
/*
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2872
B
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2873
B - Matrix - M
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2874
B - CLUT - A
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2875
B - Matrix - M - CLUT - A
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2876
*/
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2877
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2878
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2879
cmsBool  Type_LUTB2A_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2880
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2881
    cmsPipeline* Lut = (cmsPipeline*) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2882
    int inputChan, outputChan;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2883
    cmsStage *A = NULL, *B = NULL, *M = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2884
    cmsStage *Matrix = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2885
    cmsStage *CLUT = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2886
    cmsUInt32Number offsetB = 0, offsetMat = 0, offsetM = 0, offsetC = 0, offsetA = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2887
    cmsUInt32Number BaseOffset, DirectoryPos, CurrentPos;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2888
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2889
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2890
    BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2891
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2892
    if (!cmsPipelineCheckAndRetreiveStages(Lut, 1, cmsSigCurveSetElemType, &B))
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2893
        if (!cmsPipelineCheckAndRetreiveStages(Lut, 3, cmsSigCurveSetElemType, cmsSigMatrixElemType, cmsSigCurveSetElemType, &B, &Matrix, &M))
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2894
            if (!cmsPipelineCheckAndRetreiveStages(Lut, 3, cmsSigCurveSetElemType, cmsSigCLutElemType, cmsSigCurveSetElemType, &B, &CLUT, &A))
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2895
                if (!cmsPipelineCheckAndRetreiveStages(Lut, 5, cmsSigCurveSetElemType, cmsSigMatrixElemType, cmsSigCurveSetElemType,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2896
                    cmsSigCLutElemType, cmsSigCurveSetElemType, &B, &Matrix, &M, &CLUT, &A)) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2897
                        cmsSignalError(self->ContextID, cmsERROR_NOT_SUITABLE, "LUT is not suitable to be saved as LutBToA");
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2898
                        return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2899
                }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2900
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2901
    inputChan  = cmsPipelineInputChannels(Lut);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2902
    outputChan = cmsPipelineOutputChannels(Lut);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2903
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2904
    if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) inputChan)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2905
    if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) outputChan)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2906
    if (!_cmsWriteUInt16Number(io, 0)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2907
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2908
    DirectoryPos = io ->Tell(io);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2909
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2910
    if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2911
    if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2912
    if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2913
    if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2914
    if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2915
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2916
    if (A != NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2917
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2918
        offsetA = io ->Tell(io) - BaseOffset;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2919
        if (!WriteSetOfCurves(self, io, cmsSigParametricCurveType, A)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2920
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2921
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2922
    if (CLUT != NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2923
        offsetC = io ->Tell(io) - BaseOffset;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2924
        if (!WriteCLUT(self, io, Lut ->SaveAs8Bits ? 1 : 2, CLUT)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2925
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2926
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2927
    if (M != NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2928
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2929
        offsetM = io ->Tell(io) - BaseOffset;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2930
        if (!WriteSetOfCurves(self, io, cmsSigParametricCurveType, M)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2931
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2932
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2933
    if (Matrix != NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2934
        offsetMat = io ->Tell(io) - BaseOffset;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2935
        if (!WriteMatrix(self, io, Matrix)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2936
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2937
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2938
    if (B != NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2939
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2940
        offsetB = io ->Tell(io) - BaseOffset;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2941
        if (!WriteSetOfCurves(self, io, cmsSigParametricCurveType, B)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2942
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2943
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2944
    CurrentPos = io ->Tell(io);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2945
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2946
    if (!io ->Seek(io, DirectoryPos)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2947
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2948
    if (!_cmsWriteUInt32Number(io, offsetB)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2949
    if (!_cmsWriteUInt32Number(io, offsetMat)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2950
    if (!_cmsWriteUInt32Number(io, offsetM)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2951
    if (!_cmsWriteUInt32Number(io, offsetC)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2952
    if (!_cmsWriteUInt32Number(io, offsetA)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2953
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2954
    if (!io ->Seek(io, CurrentPos)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2955
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2956
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2957
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2958
    cmsUNUSED_PARAMETER(nItems);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2959
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2960
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2961
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2962
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2963
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2964
void* Type_LUTB2A_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2965
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2966
    return (void*) cmsPipelineDup((cmsPipeline*) Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2967
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2968
    cmsUNUSED_PARAMETER(n);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2969
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2970
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2971
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2972
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2973
void Type_LUTB2A_Free(struct _cms_typehandler_struct* self, void* Ptr)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2974
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2975
    cmsPipelineFree((cmsPipeline*) Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2976
    return;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2977
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2978
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2979
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2980
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2981
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2982
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2983
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2984
// Type cmsSigColorantTableType
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2985
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2986
/*
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2987
The purpose of this tag is to identify the colorants used in the profile by a
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2988
unique name and set of XYZ or L*a*b* values to give the colorant an unambiguous
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2989
value. The first colorant listed is the colorant of the first device channel of
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2990
a lut tag. The second colorant listed is the colorant of the second device channel
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2991
of a lut tag, and so on.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2992
*/
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2993
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2994
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2995
void *Type_ColorantTable_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2996
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2997
    cmsUInt32Number i, Count;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2998
    cmsNAMEDCOLORLIST* List;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  2999
    char Name[34];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3000
    cmsUInt16Number PCS[3];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3001
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3002
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3003
    if (!_cmsReadUInt32Number(io, &Count)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3004
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3005
    if (Count > cmsMAXCHANNELS) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3006
        cmsSignalError(self->ContextID, cmsERROR_RANGE, "Too many colorants '%d'", Count);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3007
        return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3008
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3009
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3010
    List = cmsAllocNamedColorList(self ->ContextID, Count, 0, "", "");
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3011
    for (i=0; i < Count; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3012
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3013
        if (io ->Read(io, Name, 32, 1) != 1) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3014
        Name[33] = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3015
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3016
        if (!_cmsReadUInt16Array(io, 3, PCS)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3017
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3018
        if (!cmsAppendNamedColor(List, Name, PCS, NULL)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3019
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3020
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3021
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3022
    *nItems = 1;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3023
    return List;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3024
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3025
Error:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3026
    *nItems = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3027
    cmsFreeNamedColorList(List);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3028
    return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3029
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3030
    cmsUNUSED_PARAMETER(SizeOfTag);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3031
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3032
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3033
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3034
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3035
// Saves a colorant table. It is using the named color structure for simplicity sake
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3036
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3037
cmsBool  Type_ColorantTable_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3038
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3039
    cmsNAMEDCOLORLIST* NamedColorList = (cmsNAMEDCOLORLIST*) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3040
    int i, nColors;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3041
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3042
    nColors = cmsNamedColorCount(NamedColorList);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3043
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3044
    if (!_cmsWriteUInt32Number(io, nColors)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3045
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3046
    for (i=0; i < nColors; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3047
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3048
        char root[33];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3049
        cmsUInt16Number PCS[3];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3050
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3051
        if (!cmsNamedColorInfo(NamedColorList, i, root, NULL, NULL, PCS, NULL)) return 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3052
        root[32] = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3053
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3054
        if (!io ->Write(io, 32, root)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3055
        if (!_cmsWriteUInt16Array(io, 3, PCS)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3056
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3057
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3058
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3059
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3060
    cmsUNUSED_PARAMETER(nItems);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3061
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3062
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3063
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3064
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3065
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3066
void* Type_ColorantTable_Dup(struct _cms_typehandler_struct* self, const void* Ptr, cmsUInt32Number n)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3067
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3068
    cmsNAMEDCOLORLIST* nc = (cmsNAMEDCOLORLIST*) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3069
    return (void*) cmsDupNamedColorList(nc);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3070
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3071
    cmsUNUSED_PARAMETER(n);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3072
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3073
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3074
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3075
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3076
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3077
void Type_ColorantTable_Free(struct _cms_typehandler_struct* self, void* Ptr)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3078
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3079
    cmsFreeNamedColorList((cmsNAMEDCOLORLIST*) Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3080
    return;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3081
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3082
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3083
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3084
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3085
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3086
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3087
// Type cmsSigNamedColor2Type
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3088
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3089
//
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3090
//The namedColor2Type is a count value and array of structures that provide color
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3091
//coordinates for 7-bit ASCII color names. For each named color, a PCS and optional
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3092
//device representation of the color are given. Both representations are 16-bit values.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3093
//The device representation corresponds to the header’s “color space of data” field.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3094
//This representation should be consistent with the “number of device components”
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3095
//field in the namedColor2Type. If this field is 0, device coordinates are not provided.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3096
//The PCS representation corresponds to the header’s PCS field. The PCS representation
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3097
//is always provided. Color names are fixed-length, 32-byte fields including null
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3098
//termination. In order to maintain maximum portability, it is strongly recommended
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3099
//that special characters of the 7-bit ASCII set not be used.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3100
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3101
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3102
void *Type_NamedColor_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3103
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3104
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3105
    cmsUInt32Number      vendorFlag;     // Bottom 16 bits for ICC use
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3106
    cmsUInt32Number      count;          // Count of named colors
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3107
    cmsUInt32Number      nDeviceCoords;  // Num of device coordinates
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3108
    char                 prefix[32];     // Prefix for each color name
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3109
    char                 suffix[32];     // Suffix for each color name
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3110
    cmsNAMEDCOLORLIST*  v;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3111
    cmsUInt32Number i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3112
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3113
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3114
    *nItems = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3115
    if (!_cmsReadUInt32Number(io, &vendorFlag)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3116
    if (!_cmsReadUInt32Number(io, &count)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3117
    if (!_cmsReadUInt32Number(io, &nDeviceCoords)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3118
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3119
    if (io -> Read(io, prefix, 32, 1) != 1) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3120
    if (io -> Read(io, suffix, 32, 1) != 1) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3121
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3122
    prefix[31] = suffix[31] = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3123
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3124
    v = cmsAllocNamedColorList(self ->ContextID, count, nDeviceCoords, prefix, suffix);
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3125
    if (v == NULL) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3126
        cmsSignalError(self->ContextID, cmsERROR_RANGE, "Too many named colors '%d'", count);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3127
        return NULL;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3128
    }
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3129
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3130
    if (nDeviceCoords > cmsMAXCHANNELS) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3131
        cmsSignalError(self->ContextID, cmsERROR_RANGE, "Too many device coordinates '%d'", nDeviceCoords);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3132
        return 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3133
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3134
    for (i=0; i < count; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3135
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3136
        cmsUInt16Number PCS[3];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3137
        cmsUInt16Number Colorant[cmsMAXCHANNELS];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3138
        char Root[33];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3139
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3140
        memset(Colorant, 0, sizeof(Colorant));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3141
        if (io -> Read(io, Root, 32, 1) != 1) return NULL;
40152
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  3142
        Root[32] = 0;  // To prevent exploits
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  3143
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3144
        if (!_cmsReadUInt16Array(io, 3, PCS)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3145
        if (!_cmsReadUInt16Array(io, nDeviceCoords, Colorant)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3146
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3147
        if (!cmsAppendNamedColor(v, Root, PCS, Colorant)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3148
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3149
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3150
    *nItems = 1;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3151
    return (void*) v ;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3152
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3153
Error:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3154
    cmsFreeNamedColorList(v);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3155
    return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3156
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3157
    cmsUNUSED_PARAMETER(SizeOfTag);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3158
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3159
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3160
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3161
// Saves a named color list into a named color profile
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3162
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3163
cmsBool Type_NamedColor_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3164
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3165
    cmsNAMEDCOLORLIST* NamedColorList = (cmsNAMEDCOLORLIST*) Ptr;
40152
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  3166
    char                prefix[33];     // Prefix for each color name
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  3167
    char                suffix[33];     // Suffix for each color name
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3168
    int i, nColors;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3169
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3170
    nColors = cmsNamedColorCount(NamedColorList);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3171
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3172
    if (!_cmsWriteUInt32Number(io, 0)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3173
    if (!_cmsWriteUInt32Number(io, nColors)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3174
    if (!_cmsWriteUInt32Number(io, NamedColorList ->ColorantCount)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3175
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3176
    strncpy(prefix, (const char*) NamedColorList->Prefix, 32);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3177
    strncpy(suffix, (const char*) NamedColorList->Suffix, 32);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3178
40152
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  3179
    suffix[32] = prefix[32] = 0;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3180
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3181
    if (!io ->Write(io, 32, prefix)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3182
    if (!io ->Write(io, 32, suffix)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3183
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3184
    for (i=0; i < nColors; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3185
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3186
       cmsUInt16Number PCS[3];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3187
       cmsUInt16Number Colorant[cmsMAXCHANNELS];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3188
       char Root[33];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3189
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3190
        if (!cmsNamedColorInfo(NamedColorList, i, Root, NULL, NULL, PCS, Colorant)) return 0;
40152
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  3191
        Root[32] = 0;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3192
        if (!io ->Write(io, 32 , Root)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3193
        if (!_cmsWriteUInt16Array(io, 3, PCS)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3194
        if (!_cmsWriteUInt16Array(io, NamedColorList ->ColorantCount, Colorant)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3195
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3196
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3197
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3198
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3199
    cmsUNUSED_PARAMETER(nItems);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3200
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3201
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3202
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3203
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3204
void* Type_NamedColor_Dup(struct _cms_typehandler_struct* self, const void* Ptr, cmsUInt32Number n)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3205
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3206
    cmsNAMEDCOLORLIST* nc = (cmsNAMEDCOLORLIST*) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3207
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3208
    return (void*) cmsDupNamedColorList(nc);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3209
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3210
    cmsUNUSED_PARAMETER(n);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3211
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3212
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3213
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3214
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3215
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3216
void Type_NamedColor_Free(struct _cms_typehandler_struct* self, void* Ptr)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3217
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3218
    cmsFreeNamedColorList((cmsNAMEDCOLORLIST*) Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3219
    return;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3220
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3221
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3222
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3223
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3224
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3225
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3226
// Type cmsSigProfileSequenceDescType
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3227
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3228
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3229
// This type is an array of structures, each of which contains information from the
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3230
// header fields and tags from the original profiles which were combined to create
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3231
// the final profile. The order of the structures is the order in which the profiles
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3232
// were combined and includes a structure for the final profile. This provides a
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3233
// description of the profile sequence from source to destination,
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3234
// typically used with the DeviceLink profile.
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3235
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3236
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3237
cmsBool ReadEmbeddedText(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsMLU** mlu, cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3238
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3239
    cmsTagTypeSignature  BaseType;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3240
    cmsUInt32Number nItems;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3241
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3242
    BaseType = _cmsReadTypeBase(io);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3243
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3244
    switch (BaseType) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3245
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3246
       case cmsSigTextType:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3247
           if (*mlu) cmsMLUfree(*mlu);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3248
           *mlu = (cmsMLU*)Type_Text_Read(self, io, &nItems, SizeOfTag);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3249
           return (*mlu != NULL);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3250
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3251
       case cmsSigTextDescriptionType:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3252
           if (*mlu) cmsMLUfree(*mlu);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3253
           *mlu =  (cmsMLU*) Type_Text_Description_Read(self, io, &nItems, SizeOfTag);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3254
           return (*mlu != NULL);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3255
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3256
           /*
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3257
           TBD: Size is needed for MLU, and we have no idea on which is the available size
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3258
           */
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3259
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3260
       case cmsSigMultiLocalizedUnicodeType:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3261
           if (*mlu) cmsMLUfree(*mlu);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3262
           *mlu =  (cmsMLU*) Type_MLU_Read(self, io, &nItems, SizeOfTag);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3263
           return (*mlu != NULL);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3264
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3265
       default: return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3266
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3267
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3268
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3269
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3270
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3271
void *Type_ProfileSequenceDesc_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3272
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3273
    cmsSEQ* OutSeq;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3274
    cmsUInt32Number i, Count;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3275
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3276
    *nItems = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3277
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3278
    if (!_cmsReadUInt32Number(io, &Count)) return NULL;
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3279
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3280
    if (SizeOfTag < sizeof(cmsUInt32Number)) return NULL;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3281
    SizeOfTag -= sizeof(cmsUInt32Number);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3282
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3283
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3284
    OutSeq = cmsAllocProfileSequenceDescription(self ->ContextID, Count);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3285
    if (OutSeq == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3286
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3287
    OutSeq ->n = Count;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3288
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3289
    // Get structures as well
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3290
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3291
    for (i=0; i < Count; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3292
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3293
        cmsPSEQDESC* sec = &OutSeq -> seq[i];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3294
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3295
        if (!_cmsReadUInt32Number(io, &sec ->deviceMfg)) goto Error;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3296
        if (SizeOfTag < sizeof(cmsUInt32Number)) goto Error;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3297
        SizeOfTag -= sizeof(cmsUInt32Number);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3298
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3299
        if (!_cmsReadUInt32Number(io, &sec ->deviceModel)) goto Error;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3300
        if (SizeOfTag < sizeof(cmsUInt32Number)) goto Error;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3301
        SizeOfTag -= sizeof(cmsUInt32Number);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3302
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3303
        if (!_cmsReadUInt64Number(io, &sec ->attributes)) goto Error;
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  3304
        if (SizeOfTag < sizeof(cmsUInt64Number)) goto Error;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3305
        SizeOfTag -= sizeof(cmsUInt64Number);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3306
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3307
        if (!_cmsReadUInt32Number(io, (cmsUInt32Number *)&sec ->technology)) goto Error;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3308
        if (SizeOfTag < sizeof(cmsUInt32Number)) goto Error;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3309
        SizeOfTag -= sizeof(cmsUInt32Number);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3310
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3311
        if (!ReadEmbeddedText(self, io, &sec ->Manufacturer, SizeOfTag)) goto Error;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3312
        if (!ReadEmbeddedText(self, io, &sec ->Model, SizeOfTag)) goto Error;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3313
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3314
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3315
    *nItems = 1;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3316
    return OutSeq;
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3317
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3318
Error:
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3319
    cmsFreeProfileSequenceDescription(OutSeq);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3320
    return NULL;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3321
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3322
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3323
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3324
// Aux--Embed a text description type. It can be of type text description or multilocalized unicode
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3325
// and it depends of the version number passed on cmsTagDescriptor structure instead of stack
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3326
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3327
cmsBool  SaveDescription(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsMLU* Text)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3328
{
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3329
    if (self ->ICCVersion < 0x4000000) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3330
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3331
        if (!_cmsWriteTypeBase(io, cmsSigTextDescriptionType)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3332
        return Type_Text_Description_Write(self, io, Text, 1);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3333
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3334
    else {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3335
        if (!_cmsWriteTypeBase(io, cmsSigMultiLocalizedUnicodeType)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3336
        return Type_MLU_Write(self, io, Text, 1);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3337
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3338
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3339
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3340
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3341
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3342
cmsBool  Type_ProfileSequenceDesc_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3343
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3344
    cmsSEQ* Seq = (cmsSEQ*) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3345
    cmsUInt32Number i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3346
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3347
    if (!_cmsWriteUInt32Number(io, Seq->n)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3348
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3349
    for (i=0; i < Seq ->n; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3350
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3351
        cmsPSEQDESC* sec = &Seq -> seq[i];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3352
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3353
        if (!_cmsWriteUInt32Number(io, sec ->deviceMfg)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3354
        if (!_cmsWriteUInt32Number(io, sec ->deviceModel)) return FALSE;
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3355
        if (!_cmsWriteUInt64Number(io, &sec ->attributes)) return FALSE;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3356
        if (!_cmsWriteUInt32Number(io, sec ->technology)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3357
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3358
        if (!SaveDescription(self, io, sec ->Manufacturer)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3359
        if (!SaveDescription(self, io, sec ->Model)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3360
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3361
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3362
     return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3363
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3364
     cmsUNUSED_PARAMETER(nItems);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3365
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3366
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3367
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3368
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3369
void* Type_ProfileSequenceDesc_Dup(struct _cms_typehandler_struct* self, const void* Ptr, cmsUInt32Number n)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3370
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3371
    return (void*) cmsDupProfileSequenceDescription((cmsSEQ*) Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3372
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3373
    cmsUNUSED_PARAMETER(n);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3374
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3375
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3376
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3377
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3378
void Type_ProfileSequenceDesc_Free(struct _cms_typehandler_struct* self, void* Ptr)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3379
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3380
    cmsFreeProfileSequenceDescription((cmsSEQ*) Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3381
    return;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3382
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3383
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3384
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3385
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3386
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3387
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3388
// Type cmsSigProfileSequenceIdType
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3389
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3390
/*
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3391
In certain workflows using ICC Device Link Profiles, it is necessary to identify the
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3392
original profiles that were combined to create the Device Link Profile.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3393
This type is an array of structures, each of which contains information for
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3394
identification of a profile used in a sequence
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3395
*/
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3396
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3397
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3398
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3399
cmsBool ReadSeqID(struct _cms_typehandler_struct* self,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3400
                                             cmsIOHANDLER* io,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3401
                                             void* Cargo,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3402
                                             cmsUInt32Number n,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3403
                                             cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3404
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3405
    cmsSEQ* OutSeq = (cmsSEQ*) Cargo;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3406
    cmsPSEQDESC* seq = &OutSeq ->seq[n];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3407
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3408
    if (io -> Read(io, seq ->ProfileID.ID8, 16, 1) != 1) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3409
    if (!ReadEmbeddedText(self, io, &seq ->Description, SizeOfTag)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3410
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3411
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3412
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3413
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3414
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3415
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3416
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3417
void *Type_ProfileSequenceId_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3418
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3419
    cmsSEQ* OutSeq;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3420
    cmsUInt32Number Count;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3421
    cmsUInt32Number BaseOffset;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3422
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3423
    *nItems = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3424
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3425
    // Get actual position as a basis for element offsets
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3426
    BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3427
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3428
    // Get table count
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3429
    if (!_cmsReadUInt32Number(io, &Count)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3430
    SizeOfTag -= sizeof(cmsUInt32Number);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3431
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3432
    // Allocate an empty structure
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3433
    OutSeq = cmsAllocProfileSequenceDescription(self ->ContextID, Count);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3434
    if (OutSeq == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3435
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3436
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3437
    // Read the position table
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3438
    if (!ReadPositionTable(self, io, Count, BaseOffset, OutSeq, ReadSeqID)) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3439
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3440
        cmsFreeProfileSequenceDescription(OutSeq);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3441
        return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3442
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3443
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3444
    // Success
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3445
    *nItems = 1;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3446
    return OutSeq;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3447
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3448
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3449
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3450
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3451
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3452
cmsBool WriteSeqID(struct _cms_typehandler_struct* self,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3453
                                             cmsIOHANDLER* io,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3454
                                             void* Cargo,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3455
                                             cmsUInt32Number n,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3456
                                             cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3457
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3458
    cmsSEQ* Seq = (cmsSEQ*) Cargo;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3459
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3460
    if (!io ->Write(io, 16, Seq ->seq[n].ProfileID.ID8)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3461
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3462
    // Store here the MLU
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3463
    if (!SaveDescription(self, io, Seq ->seq[n].Description)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3464
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3465
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3466
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3467
    cmsUNUSED_PARAMETER(SizeOfTag);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3468
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3469
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3470
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3471
cmsBool  Type_ProfileSequenceId_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3472
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3473
    cmsSEQ* Seq = (cmsSEQ*) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3474
    cmsUInt32Number BaseOffset;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3475
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3476
    // Keep the base offset
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3477
    BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3478
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3479
    // This is the table count
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3480
    if (!_cmsWriteUInt32Number(io, Seq ->n)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3481
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3482
    // This is the position table and content
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3483
    if (!WritePositionTable(self, io, 0, Seq ->n, BaseOffset, Seq, WriteSeqID)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3484
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3485
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3486
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3487
    cmsUNUSED_PARAMETER(nItems);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3488
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3489
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3490
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3491
void* Type_ProfileSequenceId_Dup(struct _cms_typehandler_struct* self, const void* Ptr, cmsUInt32Number n)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3492
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3493
    return (void*) cmsDupProfileSequenceDescription((cmsSEQ*) Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3494
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3495
    cmsUNUSED_PARAMETER(n);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3496
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3497
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3498
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3499
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3500
void Type_ProfileSequenceId_Free(struct _cms_typehandler_struct* self, void* Ptr)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3501
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3502
    cmsFreeProfileSequenceDescription((cmsSEQ*) Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3503
    return;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3504
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3505
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3506
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3507
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3508
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3509
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3510
// Type cmsSigUcrBgType
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3511
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3512
/*
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3513
This type contains curves representing the under color removal and black
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3514
generation and a text string which is a general description of the method used
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3515
for the ucr/bg.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3516
*/
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3517
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3518
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3519
void *Type_UcrBg_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3520
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3521
    cmsUcrBg* n = (cmsUcrBg*) _cmsMallocZero(self ->ContextID, sizeof(cmsUcrBg));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3522
    cmsUInt32Number CountUcr, CountBg;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3523
    char* ASCIIString;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3524
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3525
    *nItems = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3526
    if (n == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3527
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3528
    // First curve is Under color removal
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3529
    if (!_cmsReadUInt32Number(io, &CountUcr)) return NULL;
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3530
    if (SizeOfTag < sizeof(cmsUInt32Number)) return NULL;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3531
    SizeOfTag -= sizeof(cmsUInt32Number);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3532
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3533
    n ->Ucr = cmsBuildTabulatedToneCurve16(self ->ContextID, CountUcr, NULL);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3534
    if (n ->Ucr == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3535
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3536
    if (!_cmsReadUInt16Array(io, CountUcr, n ->Ucr->Table16)) return NULL;
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3537
    if (SizeOfTag < sizeof(cmsUInt32Number)) return NULL;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3538
    SizeOfTag -= CountUcr * sizeof(cmsUInt16Number);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3539
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3540
    // Second curve is Black generation
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3541
    if (!_cmsReadUInt32Number(io, &CountBg)) return NULL;
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3542
    if (SizeOfTag < sizeof(cmsUInt32Number)) return NULL;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3543
    SizeOfTag -= sizeof(cmsUInt32Number);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3544
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3545
    n ->Bg = cmsBuildTabulatedToneCurve16(self ->ContextID, CountBg, NULL);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3546
    if (n ->Bg == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3547
    if (!_cmsReadUInt16Array(io, CountBg, n ->Bg->Table16)) return NULL;
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3548
    if (SizeOfTag < CountBg * sizeof(cmsUInt16Number)) return NULL;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3549
    SizeOfTag -= CountBg * sizeof(cmsUInt16Number);
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3550
    if (SizeOfTag == UINT_MAX) return NULL;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3551
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3552
    // Now comes the text. The length is specified by the tag size
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3553
    n ->Desc = cmsMLUalloc(self ->ContextID, 1);
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3554
    if (n ->Desc == NULL) return NULL;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3555
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3556
    ASCIIString = (char*) _cmsMalloc(self ->ContextID, SizeOfTag + 1);
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3557
    if (io ->Read(io, ASCIIString, sizeof(char), SizeOfTag) != SizeOfTag) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3558
    ASCIIString[SizeOfTag] = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3559
    cmsMLUsetASCII(n ->Desc, cmsNoLanguage, cmsNoCountry, ASCIIString);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3560
    _cmsFree(self ->ContextID, ASCIIString);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3561
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3562
    *nItems = 1;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3563
    return (void*) n;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3564
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3565
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3566
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3567
cmsBool  Type_UcrBg_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3568
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3569
    cmsUcrBg* Value = (cmsUcrBg*) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3570
    cmsUInt32Number TextSize;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3571
    char* Text;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3572
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3573
    // First curve is Under color removal
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3574
    if (!_cmsWriteUInt32Number(io, Value ->Ucr ->nEntries)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3575
    if (!_cmsWriteUInt16Array(io, Value ->Ucr ->nEntries, Value ->Ucr ->Table16)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3576
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3577
    // Then black generation
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3578
    if (!_cmsWriteUInt32Number(io, Value ->Bg ->nEntries)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3579
    if (!_cmsWriteUInt16Array(io, Value ->Bg ->nEntries, Value ->Bg ->Table16)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3580
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3581
    // Now comes the text. The length is specified by the tag size
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3582
    TextSize = cmsMLUgetASCII(Value ->Desc, cmsNoLanguage, cmsNoCountry, NULL, 0);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3583
    Text     = (char*) _cmsMalloc(self ->ContextID, TextSize);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3584
    if (cmsMLUgetASCII(Value ->Desc, cmsNoLanguage, cmsNoCountry, Text, TextSize) != TextSize) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3585
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3586
    if (!io ->Write(io, TextSize, Text)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3587
    _cmsFree(self ->ContextID, Text);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3588
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3589
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3590
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3591
    cmsUNUSED_PARAMETER(nItems);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3592
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3593
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3594
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3595
void* Type_UcrBg_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3596
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3597
    cmsUcrBg* Src = (cmsUcrBg*) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3598
    cmsUcrBg* NewUcrBg = (cmsUcrBg*) _cmsMallocZero(self ->ContextID, sizeof(cmsUcrBg));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3599
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3600
    if (NewUcrBg == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3601
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3602
    NewUcrBg ->Bg   = cmsDupToneCurve(Src ->Bg);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3603
    NewUcrBg ->Ucr  = cmsDupToneCurve(Src ->Ucr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3604
    NewUcrBg ->Desc = cmsMLUdup(Src ->Desc);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3605
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3606
    return (void*) NewUcrBg;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3607
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3608
    cmsUNUSED_PARAMETER(n);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3609
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3610
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3611
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3612
void Type_UcrBg_Free(struct _cms_typehandler_struct* self, void *Ptr)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3613
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3614
   cmsUcrBg* Src = (cmsUcrBg*) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3615
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3616
   if (Src ->Ucr) cmsFreeToneCurve(Src ->Ucr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3617
   if (Src ->Bg)  cmsFreeToneCurve(Src ->Bg);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3618
   if (Src ->Desc) cmsMLUfree(Src ->Desc);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3619
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3620
   _cmsFree(self ->ContextID, Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3621
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3622
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3623
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3624
// Type cmsSigCrdInfoType
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3625
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3626
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3627
/*
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3628
This type contains the PostScript product name to which this profile corresponds
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3629
and the names of the companion CRDs. Recall that a single profile can generate
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3630
multiple CRDs. It is implemented as a MLU being the language code "PS" and then
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3631
country varies for each element:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3632
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3633
                nm: PostScript product name
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3634
                #0: Rendering intent 0 CRD name
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3635
                #1: Rendering intent 1 CRD name
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3636
                #2: Rendering intent 2 CRD name
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3637
                #3: Rendering intent 3 CRD name
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3638
*/
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3639
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3640
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3641
40152
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  3642
// Auxiliary, read an string specified as count + string
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3643
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3644
cmsBool  ReadCountAndSting(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsMLU* mlu, cmsUInt32Number* SizeOfTag, const char* Section)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3645
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3646
    cmsUInt32Number Count;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3647
    char* Text;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3648
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3649
    if (*SizeOfTag < sizeof(cmsUInt32Number)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3650
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3651
    if (!_cmsReadUInt32Number(io, &Count)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3652
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3653
    if (Count > UINT_MAX - sizeof(cmsUInt32Number)) return FALSE;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3654
    if (*SizeOfTag < Count + sizeof(cmsUInt32Number)) return FALSE;
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3655
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3656
    Text     = (char*) _cmsMalloc(self ->ContextID, Count+1);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3657
    if (Text == NULL) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3658
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3659
    if (io ->Read(io, Text, sizeof(cmsUInt8Number), Count) != Count) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3660
        _cmsFree(self ->ContextID, Text);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3661
        return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3662
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3663
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3664
    Text[Count] = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3665
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3666
    cmsMLUsetASCII(mlu, "PS", Section, Text);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3667
    _cmsFree(self ->ContextID, Text);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3668
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3669
    *SizeOfTag -= (Count + sizeof(cmsUInt32Number));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3670
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3671
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3672
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3673
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3674
cmsBool  WriteCountAndSting(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsMLU* mlu, const char* Section)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3675
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3676
 cmsUInt32Number TextSize;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3677
 char* Text;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3678
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3679
    TextSize = cmsMLUgetASCII(mlu, "PS", Section, NULL, 0);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3680
    Text     = (char*) _cmsMalloc(self ->ContextID, TextSize);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3681
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3682
    if (!_cmsWriteUInt32Number(io, TextSize)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3683
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3684
    if (cmsMLUgetASCII(mlu, "PS", Section, Text, TextSize) == 0) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3685
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3686
    if (!io ->Write(io, TextSize, Text)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3687
    _cmsFree(self ->ContextID, Text);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3688
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3689
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3690
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3691
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3692
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3693
void *Type_CrdInfo_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3694
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3695
    cmsMLU* mlu = cmsMLUalloc(self ->ContextID, 5);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3696
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3697
    *nItems = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3698
    if (!ReadCountAndSting(self, io, mlu, &SizeOfTag, "nm")) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3699
    if (!ReadCountAndSting(self, io, mlu, &SizeOfTag, "#0")) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3700
    if (!ReadCountAndSting(self, io, mlu, &SizeOfTag, "#1")) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3701
    if (!ReadCountAndSting(self, io, mlu, &SizeOfTag, "#2")) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3702
    if (!ReadCountAndSting(self, io, mlu, &SizeOfTag, "#3")) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3703
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3704
    *nItems = 1;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3705
    return (void*) mlu;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3706
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3707
Error:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3708
    cmsMLUfree(mlu);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3709
    return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3710
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3711
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3712
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3713
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3714
cmsBool  Type_CrdInfo_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3715
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3716
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3717
    cmsMLU* mlu = (cmsMLU*) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3718
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3719
    if (!WriteCountAndSting(self, io, mlu, "nm")) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3720
    if (!WriteCountAndSting(self, io, mlu, "#0")) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3721
    if (!WriteCountAndSting(self, io, mlu, "#1")) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3722
    if (!WriteCountAndSting(self, io, mlu, "#2")) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3723
    if (!WriteCountAndSting(self, io, mlu, "#3")) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3724
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3725
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3726
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3727
Error:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3728
    return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3729
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3730
    cmsUNUSED_PARAMETER(nItems);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3731
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3732
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3733
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3734
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3735
void* Type_CrdInfo_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3736
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3737
    return (void*) cmsMLUdup((cmsMLU*) Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3738
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3739
    cmsUNUSED_PARAMETER(n);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3740
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3741
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3742
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3743
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3744
void Type_CrdInfo_Free(struct _cms_typehandler_struct* self, void *Ptr)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3745
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3746
    cmsMLUfree((cmsMLU*) Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3747
    return;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3748
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3749
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3750
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3751
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3752
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3753
// Type cmsSigScreeningType
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3754
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3755
//
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3756
//The screeningType describes various screening parameters including screen
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3757
//frequency, screening angle, and spot shape.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3758
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3759
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3760
void *Type_Screening_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3761
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3762
    cmsScreening* sc = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3763
    cmsUInt32Number i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3764
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3765
    sc = (cmsScreening*) _cmsMallocZero(self ->ContextID, sizeof(cmsScreening));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3766
    if (sc == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3767
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3768
    *nItems = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3769
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3770
    if (!_cmsReadUInt32Number(io, &sc ->Flag)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3771
    if (!_cmsReadUInt32Number(io, &sc ->nChannels)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3772
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3773
    if (sc ->nChannels > cmsMAXCHANNELS - 1)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3774
        sc ->nChannels = cmsMAXCHANNELS - 1;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3775
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3776
    for (i=0; i < sc ->nChannels; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3777
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3778
        if (!_cmsRead15Fixed16Number(io, &sc ->Channels[i].Frequency)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3779
        if (!_cmsRead15Fixed16Number(io, &sc ->Channels[i].ScreenAngle)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3780
        if (!_cmsReadUInt32Number(io, &sc ->Channels[i].SpotShape)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3781
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3782
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3783
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3784
    *nItems = 1;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3785
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3786
    return (void*) sc;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3787
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3788
Error:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3789
    if (sc != NULL)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3790
        _cmsFree(self ->ContextID, sc);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3791
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3792
    return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3793
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3794
    cmsUNUSED_PARAMETER(SizeOfTag);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3795
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3796
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3797
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3798
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3799
cmsBool Type_Screening_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3800
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3801
    cmsScreening* sc = (cmsScreening* ) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3802
    cmsUInt32Number i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3803
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3804
    if (!_cmsWriteUInt32Number(io, sc ->Flag)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3805
    if (!_cmsWriteUInt32Number(io, sc ->nChannels)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3806
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3807
    for (i=0; i < sc ->nChannels; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3808
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3809
        if (!_cmsWrite15Fixed16Number(io, sc ->Channels[i].Frequency)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3810
        if (!_cmsWrite15Fixed16Number(io, sc ->Channels[i].ScreenAngle)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3811
        if (!_cmsWriteUInt32Number(io, sc ->Channels[i].SpotShape)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3812
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3813
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3814
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3815
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3816
    cmsUNUSED_PARAMETER(nItems);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3817
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3818
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3819
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3820
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3821
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3822
void* Type_Screening_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3823
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3824
   return _cmsDupMem(self ->ContextID, Ptr, sizeof(cmsScreening));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3825
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3826
   cmsUNUSED_PARAMETER(n);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3827
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3828
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3829
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3830
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3831
void Type_Screening_Free(struct _cms_typehandler_struct* self, void* Ptr)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3832
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3833
   _cmsFree(self ->ContextID, Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3834
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3835
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3836
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3837
// Type cmsSigViewingConditionsType
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3838
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3839
//
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3840
//This type represents a set of viewing condition parameters including:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3841
//CIE ’absolute’ illuminant white point tristimulus values and CIE ’absolute’
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3842
//surround tristimulus values.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3843
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3844
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3845
void *Type_ViewingConditions_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3846
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3847
    cmsICCViewingConditions* vc = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3848
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3849
    vc = (cmsICCViewingConditions*) _cmsMallocZero(self ->ContextID, sizeof(cmsICCViewingConditions));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3850
    if (vc == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3851
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3852
    *nItems = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3853
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3854
    if (!_cmsReadXYZNumber(io, &vc ->IlluminantXYZ)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3855
    if (!_cmsReadXYZNumber(io, &vc ->SurroundXYZ)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3856
    if (!_cmsReadUInt32Number(io, &vc ->IlluminantType)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3857
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3858
    *nItems = 1;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3859
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3860
    return (void*) vc;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3861
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3862
Error:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3863
    if (vc != NULL)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3864
        _cmsFree(self ->ContextID, vc);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3865
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3866
    return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3867
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3868
    cmsUNUSED_PARAMETER(SizeOfTag);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3869
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3870
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3871
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3872
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3873
cmsBool Type_ViewingConditions_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3874
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3875
    cmsICCViewingConditions* sc = (cmsICCViewingConditions* ) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3876
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3877
    if (!_cmsWriteXYZNumber(io, &sc ->IlluminantXYZ)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3878
    if (!_cmsWriteXYZNumber(io, &sc ->SurroundXYZ)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3879
    if (!_cmsWriteUInt32Number(io, sc ->IlluminantType)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3880
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3881
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3882
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3883
    cmsUNUSED_PARAMETER(nItems);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3884
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3885
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3886
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3887
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3888
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3889
void* Type_ViewingConditions_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3890
{
40152
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  3891
   return _cmsDupMem(self->ContextID, Ptr, sizeof(cmsICCViewingConditions));
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3892
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3893
   cmsUNUSED_PARAMETER(n);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3894
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3895
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3896
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3897
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3898
void Type_ViewingConditions_Free(struct _cms_typehandler_struct* self, void* Ptr)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3899
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3900
   _cmsFree(self ->ContextID, Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3901
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3902
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3903
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3904
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3905
// Type cmsSigMultiProcessElementType
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3906
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3907
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3908
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3909
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3910
void* GenericMPEdup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3911
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3912
    return (void*) cmsStageDup((cmsStage*) Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3913
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3914
    cmsUNUSED_PARAMETER(n);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3915
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3916
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3917
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3918
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3919
void GenericMPEfree(struct _cms_typehandler_struct* self, void *Ptr)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3920
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3921
    cmsStageFree((cmsStage*) Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3922
    return;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3923
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3924
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3925
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3926
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3927
// Each curve is stored in one or more curve segments, with break-points specified between curve segments.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3928
// The first curve segment always starts at –Infinity, and the last curve segment always ends at +Infinity. The
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3929
// first and last curve segments shall be specified in terms of a formula, whereas the other segments shall be
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3930
// specified either in terms of a formula, or by a sampled curve.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3931
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3932
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3933
// Read an embedded segmented curve
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3934
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3935
cmsToneCurve* ReadSegmentedCurve(struct _cms_typehandler_struct* self, cmsIOHANDLER* io)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3936
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3937
    cmsCurveSegSignature ElementSig;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3938
    cmsUInt32Number i, j;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3939
    cmsUInt16Number nSegments;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3940
    cmsCurveSegment*  Segments;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3941
    cmsToneCurve* Curve;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3942
    cmsFloat32Number PrevBreak = -1E22F;    // - infinite
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3943
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3944
    // Take signature and channels for each element.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3945
     if (!_cmsReadUInt32Number(io, (cmsUInt32Number*) &ElementSig)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3946
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3947
     // That should be a segmented curve
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3948
     if (ElementSig != cmsSigSegmentedCurve) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3949
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3950
     if (!_cmsReadUInt32Number(io, NULL)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3951
     if (!_cmsReadUInt16Number(io, &nSegments)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3952
     if (!_cmsReadUInt16Number(io, NULL)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3953
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  3954
     if (nSegments < 1) return NULL;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3955
     Segments = (cmsCurveSegment*) _cmsCalloc(self ->ContextID, nSegments, sizeof(cmsCurveSegment));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3956
     if (Segments == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3957
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3958
     // Read breakpoints
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3959
     for (i=0; i < (cmsUInt32Number) nSegments - 1; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3960
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3961
         Segments[i].x0 = PrevBreak;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3962
         if (!_cmsReadFloat32Number(io, &Segments[i].x1)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3963
         PrevBreak = Segments[i].x1;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3964
     }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3965
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3966
     Segments[nSegments-1].x0 = PrevBreak;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3967
     Segments[nSegments-1].x1 = 1E22F;     // A big cmsFloat32Number number
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3968
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3969
     // Read segments
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3970
     for (i=0; i < nSegments; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3971
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3972
          if (!_cmsReadUInt32Number(io, (cmsUInt32Number*) &ElementSig)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3973
          if (!_cmsReadUInt32Number(io, NULL)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3974
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3975
           switch (ElementSig) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3976
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3977
            case cmsSigFormulaCurveSeg: {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3978
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3979
                cmsUInt16Number Type;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3980
                cmsUInt32Number ParamsByType[] = {4, 5, 5 };
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3981
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3982
                if (!_cmsReadUInt16Number(io, &Type)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3983
                if (!_cmsReadUInt16Number(io, NULL)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3984
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3985
                Segments[i].Type = Type + 6;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3986
                if (Type > 2) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3987
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3988
                for (j=0; j < ParamsByType[Type]; j++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3989
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3990
                    cmsFloat32Number f;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3991
                    if (!_cmsReadFloat32Number(io, &f)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3992
                    Segments[i].Params[j] = f;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3993
                }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3994
                }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3995
                break;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3996
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3997
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3998
            case cmsSigSampledCurveSeg: {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  3999
                cmsUInt32Number Count;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4000
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4001
                if (!_cmsReadUInt32Number(io, &Count)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4002
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4003
                Segments[i].nGridPoints = Count;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4004
                Segments[i].SampledPoints = (cmsFloat32Number*) _cmsCalloc(self ->ContextID, Count, sizeof(cmsFloat32Number));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4005
                if (Segments[i].SampledPoints == NULL) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4006
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4007
                for (j=0; j < Count; j++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4008
                    if (!_cmsReadFloat32Number(io, &Segments[i].SampledPoints[j])) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4009
                }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4010
                }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4011
                break;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4012
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4013
            default:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4014
                {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4015
                char String[5];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4016
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4017
                _cmsTagSignature2String(String, (cmsTagSignature) ElementSig);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4018
                cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unknown curve element type '%s' found.", String);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4019
                }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4020
                return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4021
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4022
         }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4023
     }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4024
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4025
     Curve = cmsBuildSegmentedToneCurve(self ->ContextID, nSegments, Segments);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4026
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4027
     for (i=0; i < nSegments; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4028
         if (Segments[i].SampledPoints) _cmsFree(self ->ContextID, Segments[i].SampledPoints);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4029
     }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4030
     _cmsFree(self ->ContextID, Segments);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4031
     return Curve;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4032
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4033
Error:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4034
     if (Segments) _cmsFree(self ->ContextID, Segments);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4035
     return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4036
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4037
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4038
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4039
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4040
cmsBool ReadMPECurve(struct _cms_typehandler_struct* self,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4041
                     cmsIOHANDLER* io,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4042
                     void* Cargo,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4043
                     cmsUInt32Number n,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4044
                     cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4045
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4046
      cmsToneCurve** GammaTables = ( cmsToneCurve**) Cargo;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4047
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4048
      GammaTables[n] = ReadSegmentedCurve(self, io);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4049
      return (GammaTables[n] != NULL);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4050
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4051
      cmsUNUSED_PARAMETER(SizeOfTag);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4052
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4053
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4054
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4055
void *Type_MPEcurve_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4056
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4057
    cmsStage* mpe = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4058
    cmsUInt16Number InputChans, OutputChans;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4059
    cmsUInt32Number i, BaseOffset;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4060
    cmsToneCurve** GammaTables;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4061
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4062
    *nItems = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4063
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4064
    // Get actual position as a basis for element offsets
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4065
    BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4066
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4067
    if (!_cmsReadUInt16Number(io, &InputChans)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4068
    if (!_cmsReadUInt16Number(io, &OutputChans)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4069
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4070
    if (InputChans != OutputChans) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4071
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4072
    GammaTables = (cmsToneCurve**) _cmsCalloc(self ->ContextID, InputChans, sizeof(cmsToneCurve*));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4073
    if (GammaTables == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4074
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4075
    if (ReadPositionTable(self, io, InputChans, BaseOffset, GammaTables, ReadMPECurve)) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4076
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4077
        mpe = cmsStageAllocToneCurves(self ->ContextID, InputChans, GammaTables);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4078
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4079
    else {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4080
        mpe = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4081
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4082
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4083
    for (i=0; i < InputChans; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4084
        if (GammaTables[i]) cmsFreeToneCurve(GammaTables[i]);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4085
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4086
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4087
    _cmsFree(self ->ContextID, GammaTables);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4088
    *nItems = (mpe != NULL) ? 1 : 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4089
    return mpe;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4090
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4091
    cmsUNUSED_PARAMETER(SizeOfTag);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4092
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4093
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4094
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4095
// Write a single segmented curve. NO CHECK IS PERFORMED ON VALIDITY
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4096
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4097
cmsBool WriteSegmentedCurve(cmsIOHANDLER* io, cmsToneCurve* g)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4098
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4099
    cmsUInt32Number i, j;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4100
    cmsCurveSegment* Segments = g ->Segments;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4101
    cmsUInt32Number nSegments = g ->nSegments;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4102
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4103
    if (!_cmsWriteUInt32Number(io, cmsSigSegmentedCurve)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4104
    if (!_cmsWriteUInt32Number(io, 0)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4105
    if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) nSegments)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4106
    if (!_cmsWriteUInt16Number(io, 0)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4107
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4108
    // Write the break-points
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4109
    for (i=0; i < nSegments - 1; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4110
        if (!_cmsWriteFloat32Number(io, Segments[i].x1)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4111
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4112
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4113
    // Write the segments
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4114
    for (i=0; i < g ->nSegments; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4115
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4116
        cmsCurveSegment* ActualSeg = Segments + i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4117
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4118
        if (ActualSeg -> Type == 0) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4119
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4120
            // This is a sampled curve
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4121
            if (!_cmsWriteUInt32Number(io, (cmsUInt32Number) cmsSigSampledCurveSeg)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4122
            if (!_cmsWriteUInt32Number(io, 0)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4123
            if (!_cmsWriteUInt32Number(io, ActualSeg -> nGridPoints)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4124
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4125
            for (j=0; j < g ->Segments[i].nGridPoints; j++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4126
                if (!_cmsWriteFloat32Number(io, ActualSeg -> SampledPoints[j])) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4127
            }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4128
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4129
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4130
        else {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4131
            int Type;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4132
            cmsUInt32Number ParamsByType[] = { 4, 5, 5 };
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4133
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4134
            // This is a formula-based
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4135
            if (!_cmsWriteUInt32Number(io, (cmsUInt32Number) cmsSigFormulaCurveSeg)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4136
            if (!_cmsWriteUInt32Number(io, 0)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4137
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4138
            // We only allow 1, 2 and 3 as types
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4139
            Type = ActualSeg ->Type - 6;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4140
            if (Type > 2 || Type < 0) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4141
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4142
            if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) Type)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4143
            if (!_cmsWriteUInt16Number(io, 0)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4144
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4145
            for (j=0; j < ParamsByType[Type]; j++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4146
                if (!_cmsWriteFloat32Number(io, (cmsFloat32Number) ActualSeg ->Params[j])) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4147
            }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4148
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4149
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4150
        // It seems there is no need to align. Code is here, and for safety commented out
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4151
        // if (!_cmsWriteAlignment(io)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4152
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4153
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4154
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4155
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4156
Error:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4157
    return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4158
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4159
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4160
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4161
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4162
cmsBool WriteMPECurve(struct _cms_typehandler_struct* self,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4163
                      cmsIOHANDLER* io,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4164
                      void* Cargo,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4165
                      cmsUInt32Number n,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4166
                      cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4167
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4168
    _cmsStageToneCurvesData* Curves  = (_cmsStageToneCurvesData*) Cargo;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4169
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4170
    return WriteSegmentedCurve(io, Curves ->TheCurves[n]);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4171
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4172
    cmsUNUSED_PARAMETER(SizeOfTag);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4173
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4174
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4175
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4176
// Write a curve, checking first for validity
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4177
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4178
cmsBool  Type_MPEcurve_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4179
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4180
    cmsUInt32Number BaseOffset;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4181
    cmsStage* mpe = (cmsStage*) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4182
    _cmsStageToneCurvesData* Curves = (_cmsStageToneCurvesData*) mpe ->Data;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4183
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4184
    BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4185
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4186
    // Write the header. Since those are curves, input and output channels are same
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4187
    if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) mpe ->InputChannels)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4188
    if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) mpe ->InputChannels)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4189
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4190
    if (!WritePositionTable(self, io, 0,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4191
                                mpe ->InputChannels, BaseOffset, Curves, WriteMPECurve)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4192
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4193
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4194
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4195
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4196
    cmsUNUSED_PARAMETER(nItems);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4197
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4198
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4199
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4200
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4201
// The matrix is organized as an array of PxQ+Q elements, where P is the number of input channels to the
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4202
// matrix, and Q is the number of output channels. The matrix elements are each float32Numbers. The array
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4203
// is organized as follows:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4204
// array = [e11, e12, …, e1P, e21, e22, …, e2P, …, eQ1, eQ2, …, eQP, e1, e2, …, eQ]
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4205
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4206
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4207
void *Type_MPEmatrix_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4208
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4209
    cmsStage* mpe;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4210
    cmsUInt16Number   InputChans, OutputChans;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4211
    cmsUInt32Number   nElems, i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4212
    cmsFloat64Number* Matrix;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4213
    cmsFloat64Number* Offsets;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4214
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4215
    if (!_cmsReadUInt16Number(io, &InputChans)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4216
    if (!_cmsReadUInt16Number(io, &OutputChans)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4217
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4218
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4219
    nElems = InputChans * OutputChans;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4220
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4221
    // Input and output chans may be ANY (up to 0xffff)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4222
    Matrix = (cmsFloat64Number*) _cmsCalloc(self ->ContextID, nElems, sizeof(cmsFloat64Number));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4223
    if (Matrix == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4224
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4225
    Offsets = (cmsFloat64Number*) _cmsCalloc(self ->ContextID, OutputChans, sizeof(cmsFloat64Number));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4226
    if (Offsets == NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4227
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4228
        _cmsFree(self ->ContextID, Matrix);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4229
        return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4230
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4231
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4232
    for (i=0; i < nElems; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4233
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4234
        cmsFloat32Number v;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4235
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4236
        if (!_cmsReadFloat32Number(io, &v)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4237
        Matrix[i] = v;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4238
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4239
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4240
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4241
    for (i=0; i < OutputChans; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4242
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4243
        cmsFloat32Number v;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4244
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4245
        if (!_cmsReadFloat32Number(io, &v)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4246
        Offsets[i] = v;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4247
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4248
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4249
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4250
    mpe = cmsStageAllocMatrix(self ->ContextID, OutputChans, InputChans, Matrix, Offsets);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4251
    _cmsFree(self ->ContextID, Matrix);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4252
    _cmsFree(self ->ContextID, Offsets);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4253
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4254
    *nItems = 1;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4255
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4256
    return mpe;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4257
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4258
    cmsUNUSED_PARAMETER(SizeOfTag);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4259
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4260
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4261
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4262
cmsBool  Type_MPEmatrix_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4263
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4264
    cmsUInt32Number i, nElems;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4265
    cmsStage* mpe = (cmsStage*) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4266
    _cmsStageMatrixData* Matrix = (_cmsStageMatrixData*) mpe ->Data;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4267
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4268
    if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) mpe ->InputChannels)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4269
    if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) mpe ->OutputChannels)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4270
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4271
    nElems = mpe ->InputChannels * mpe ->OutputChannels;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4272
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4273
    for (i=0; i < nElems; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4274
        if (!_cmsWriteFloat32Number(io, (cmsFloat32Number) Matrix->Double[i])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4275
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4276
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4277
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4278
    for (i=0; i < mpe ->OutputChannels; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4279
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4280
        if (Matrix ->Offset == NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4281
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4282
               if (!_cmsWriteFloat32Number(io, 0)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4283
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4284
        else {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4285
               if (!_cmsWriteFloat32Number(io, (cmsFloat32Number) Matrix->Offset[i])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4286
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4287
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4288
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4289
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4290
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4291
    cmsUNUSED_PARAMETER(nItems);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4292
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4293
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4294
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4295
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4296
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4297
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4298
void *Type_MPEclut_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4299
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4300
    cmsStage* mpe = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4301
    cmsUInt16Number InputChans, OutputChans;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4302
    cmsUInt8Number Dimensions8[16];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4303
    cmsUInt32Number i, nMaxGrids, GridPoints[MAX_INPUT_DIMENSIONS];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4304
    _cmsStageCLutData* clut;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4305
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4306
    if (!_cmsReadUInt16Number(io, &InputChans)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4307
    if (!_cmsReadUInt16Number(io, &OutputChans)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4308
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  4309
    if (InputChans == 0) goto Error;
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  4310
    if (OutputChans == 0) goto Error;
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  4311
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4312
    if (io ->Read(io, Dimensions8, sizeof(cmsUInt8Number), 16) != 16)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4313
        goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4314
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4315
    // Copy MAX_INPUT_DIMENSIONS at most. Expand to cmsUInt32Number
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4316
    nMaxGrids = InputChans > MAX_INPUT_DIMENSIONS ? MAX_INPUT_DIMENSIONS : InputChans;
41567
10ed0e790b06 8157759: LCMS Transform Sampling Enhancement
vadim
parents: 40152
diff changeset
  4317
    for (i=0; i < nMaxGrids; i++) {
10ed0e790b06 8157759: LCMS Transform Sampling Enhancement
vadim
parents: 40152
diff changeset
  4318
        if (Dimensions8[i] == 1) goto Error; // Impossible value, 0 for no CLUT and then 2 at least
10ed0e790b06 8157759: LCMS Transform Sampling Enhancement
vadim
parents: 40152
diff changeset
  4319
        GridPoints[i] = (cmsUInt32Number)Dimensions8[i];
10ed0e790b06 8157759: LCMS Transform Sampling Enhancement
vadim
parents: 40152
diff changeset
  4320
    }
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4321
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4322
    // Allocate the true CLUT
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4323
    mpe = cmsStageAllocCLutFloatGranular(self ->ContextID, GridPoints, InputChans, OutputChans, NULL);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4324
    if (mpe == NULL) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4325
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4326
    // Read the data
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4327
    clut = (_cmsStageCLutData*) mpe ->Data;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4328
    for (i=0; i < clut ->nEntries; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4329
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4330
        if (!_cmsReadFloat32Number(io, &clut ->Tab.TFloat[i])) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4331
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4332
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4333
    *nItems = 1;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4334
    return mpe;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4335
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4336
Error:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4337
    *nItems = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4338
    if (mpe != NULL) cmsStageFree(mpe);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4339
    return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4340
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4341
    cmsUNUSED_PARAMETER(SizeOfTag);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4342
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4343
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4344
// Write a CLUT in floating point
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4345
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4346
cmsBool  Type_MPEclut_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4347
{
40152
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  4348
    cmsUInt8Number Dimensions8[16];  // 16 because the spec says 16 and not max number of channels
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4349
    cmsUInt32Number i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4350
    cmsStage* mpe = (cmsStage*) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4351
    _cmsStageCLutData* clut = (_cmsStageCLutData*) mpe ->Data;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4352
40152
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  4353
    // Check for maximum number of channels supported by lcms
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  4354
    if (mpe -> InputChannels > MAX_INPUT_DIMENSIONS) return FALSE;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4355
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4356
    // Only floats are supported in MPE
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4357
    if (clut ->HasFloatValues == FALSE) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4358
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4359
    if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) mpe ->InputChannels)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4360
    if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) mpe ->OutputChannels)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4361
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4362
    memset(Dimensions8, 0, sizeof(Dimensions8));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4363
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4364
    for (i=0; i < mpe ->InputChannels; i++)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4365
        Dimensions8[i] = (cmsUInt8Number) clut ->Params ->nSamples[i];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4366
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4367
    if (!io ->Write(io, 16, Dimensions8)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4368
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4369
    for (i=0; i < clut ->nEntries; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4370
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4371
        if (!_cmsWriteFloat32Number(io, clut ->Tab.TFloat[i])) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4372
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4373
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4374
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4375
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4376
    cmsUNUSED_PARAMETER(nItems);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4377
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4378
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4379
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4380
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4381
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4382
// This is the list of built-in MPE types
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4383
static _cmsTagTypeLinkedList SupportedMPEtypes[] = {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4384
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4385
{{ (cmsTagTypeSignature) cmsSigBAcsElemType, NULL, NULL, NULL, NULL, NULL, 0 }, &SupportedMPEtypes[1] },   // Ignore those elements for now
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4386
{{ (cmsTagTypeSignature) cmsSigEAcsElemType, NULL, NULL, NULL, NULL, NULL, 0 }, &SupportedMPEtypes[2] },   // (That's what the spec says)
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4387
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4388
{TYPE_MPE_HANDLER((cmsTagTypeSignature) cmsSigCurveSetElemType,     MPEcurve),      &SupportedMPEtypes[3] },
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4389
{TYPE_MPE_HANDLER((cmsTagTypeSignature) cmsSigMatrixElemType,       MPEmatrix),     &SupportedMPEtypes[4] },
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4390
{TYPE_MPE_HANDLER((cmsTagTypeSignature) cmsSigCLutElemType,         MPEclut),        NULL },
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4391
};
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4392
26609
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  4393
_cmsTagTypePluginChunkType _cmsMPETypePluginChunk = { NULL };
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4394
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4395
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4396
cmsBool ReadMPEElem(struct _cms_typehandler_struct* self,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4397
                    cmsIOHANDLER* io,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4398
                    void* Cargo,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4399
                    cmsUInt32Number n,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4400
                    cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4401
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4402
    cmsStageSignature ElementSig;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4403
    cmsTagTypeHandler* TypeHandler;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4404
    cmsUInt32Number nItems;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4405
    cmsPipeline *NewLUT = (cmsPipeline *) Cargo;
26609
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  4406
    _cmsTagTypePluginChunkType* MPETypePluginChunk  = ( _cmsTagTypePluginChunkType*) _cmsContextGetClientChunk(self->ContextID, MPEPlugin);
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  4407
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4408
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4409
    // Take signature and channels for each element.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4410
    if (!_cmsReadUInt32Number(io, (cmsUInt32Number*) &ElementSig)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4411
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4412
    // The reserved placeholder
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4413
    if (!_cmsReadUInt32Number(io, NULL)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4414
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4415
    // Read diverse MPE types
26609
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  4416
    TypeHandler = GetHandler((cmsTagTypeSignature) ElementSig, MPETypePluginChunk ->TagTypes, SupportedMPEtypes);
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4417
    if (TypeHandler == NULL)  {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4418
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4419
        char String[5];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4420
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4421
        _cmsTagSignature2String(String, (cmsTagSignature) ElementSig);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4422
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4423
        // An unknown element was found.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4424
        cmsSignalError(self ->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unknown MPE type '%s' found.", String);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4425
        return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4426
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4427
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4428
    // If no read method, just ignore the element (valid for cmsSigBAcsElemType and cmsSigEAcsElemType)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4429
    // Read the MPE. No size is given
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4430
    if (TypeHandler ->ReadPtr != NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4431
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4432
        // This is a real element which should be read and processed
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  4433
        if (!cmsPipelineInsertStage(NewLUT, cmsAT_END, (cmsStage*) TypeHandler ->ReadPtr(self, io, &nItems, SizeOfTag)))
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  4434
            return FALSE;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4435
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4436
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4437
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4438
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4439
    cmsUNUSED_PARAMETER(SizeOfTag);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4440
    cmsUNUSED_PARAMETER(n);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4441
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4442
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4443
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4444
// This is the main dispatcher for MPE
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4445
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4446
void *Type_MPE_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4447
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4448
    cmsUInt16Number InputChans, OutputChans;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4449
    cmsUInt32Number ElementCount;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4450
    cmsPipeline *NewLUT = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4451
    cmsUInt32Number BaseOffset;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4452
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4453
    // Get actual position as a basis for element offsets
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4454
    BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4455
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4456
    // Read channels and element count
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4457
    if (!_cmsReadUInt16Number(io, &InputChans)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4458
    if (!_cmsReadUInt16Number(io, &OutputChans)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4459
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4460
    // Allocates an empty LUT
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4461
    NewLUT = cmsPipelineAlloc(self ->ContextID, InputChans, OutputChans);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4462
    if (NewLUT == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4463
47409
72af2394abce 8171261: Stability fixes for lcms
prr
parents: 47216
diff changeset
  4464
    if (!_cmsReadUInt32Number(io, &ElementCount)) goto Error;
72af2394abce 8171261: Stability fixes for lcms
prr
parents: 47216
diff changeset
  4465
    if (!ReadPositionTable(self, io, ElementCount, BaseOffset, NewLUT, ReadMPEElem)) goto Error;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4466
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4467
    // Success
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4468
    *nItems = 1;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4469
    return NewLUT;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4470
47409
72af2394abce 8171261: Stability fixes for lcms
prr
parents: 47216
diff changeset
  4471
    // Error
72af2394abce 8171261: Stability fixes for lcms
prr
parents: 47216
diff changeset
  4472
Error:
72af2394abce 8171261: Stability fixes for lcms
prr
parents: 47216
diff changeset
  4473
    if (NewLUT != NULL) cmsPipelineFree(NewLUT);
72af2394abce 8171261: Stability fixes for lcms
prr
parents: 47216
diff changeset
  4474
    *nItems = 0;
72af2394abce 8171261: Stability fixes for lcms
prr
parents: 47216
diff changeset
  4475
    return NULL;
72af2394abce 8171261: Stability fixes for lcms
prr
parents: 47216
diff changeset
  4476
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4477
    cmsUNUSED_PARAMETER(SizeOfTag);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4478
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4479
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4480
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4481
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4482
// This one is a liitle bit more complex, so we don't use position tables this time.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4483
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4484
cmsBool Type_MPE_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4485
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4486
    cmsUInt32Number i, BaseOffset, DirectoryPos, CurrentPos;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4487
    int inputChan, outputChan;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4488
    cmsUInt32Number ElemCount;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4489
    cmsUInt32Number *ElementOffsets = NULL, *ElementSizes = NULL, Before;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4490
    cmsStageSignature ElementSig;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4491
    cmsPipeline* Lut = (cmsPipeline*) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4492
    cmsStage* Elem = Lut ->Elements;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4493
    cmsTagTypeHandler* TypeHandler;
26609
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  4494
    _cmsTagTypePluginChunkType* MPETypePluginChunk  = ( _cmsTagTypePluginChunkType*) _cmsContextGetClientChunk(self->ContextID, MPEPlugin);
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4495
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4496
    BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4497
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4498
    inputChan  = cmsPipelineInputChannels(Lut);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4499
    outputChan = cmsPipelineOutputChannels(Lut);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4500
    ElemCount  = cmsPipelineStageCount(Lut);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4501
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  4502
    ElementOffsets = (cmsUInt32Number *) _cmsCalloc(self ->ContextID, ElemCount, sizeof(cmsUInt32Number));
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4503
    if (ElementOffsets == NULL) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4504
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  4505
    ElementSizes = (cmsUInt32Number *) _cmsCalloc(self ->ContextID, ElemCount, sizeof(cmsUInt32Number));
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4506
    if (ElementSizes == NULL) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4507
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4508
    // Write the head
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4509
    if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) inputChan)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4510
    if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) outputChan)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4511
    if (!_cmsWriteUInt32Number(io, (cmsUInt16Number) ElemCount)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4512
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4513
    DirectoryPos = io ->Tell(io);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4514
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4515
    // Write a fake directory to be filled latter on
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4516
    for (i=0; i < ElemCount; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4517
        if (!_cmsWriteUInt32Number(io, 0)) goto Error;  // Offset
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4518
        if (!_cmsWriteUInt32Number(io, 0)) goto Error;  // size
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4519
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4520
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4521
    // Write each single tag. Keep track of the size as well.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4522
    for (i=0; i < ElemCount; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4523
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4524
        ElementOffsets[i] = io ->Tell(io) - BaseOffset;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4525
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4526
        ElementSig = Elem ->Type;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4527
26609
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  4528
        TypeHandler = GetHandler((cmsTagTypeSignature) ElementSig, MPETypePluginChunk->TagTypes, SupportedMPEtypes);
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4529
        if (TypeHandler == NULL)  {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4530
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4531
                char String[5];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4532
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4533
                _cmsTagSignature2String(String, (cmsTagSignature) ElementSig);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4534
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4535
                 // An unknow element was found.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4536
                 cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Found unknown MPE type '%s'", String);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4537
                 goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4538
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4539
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4540
        if (!_cmsWriteUInt32Number(io, ElementSig)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4541
        if (!_cmsWriteUInt32Number(io, 0)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4542
        Before = io ->Tell(io);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4543
        if (!TypeHandler ->WritePtr(self, io, Elem, 1)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4544
        if (!_cmsWriteAlignment(io)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4545
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4546
        ElementSizes[i] = io ->Tell(io) - Before;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4547
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4548
        Elem = Elem ->Next;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4549
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4550
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4551
    // Write the directory
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4552
    CurrentPos = io ->Tell(io);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4553
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4554
    if (!io ->Seek(io, DirectoryPos)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4555
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4556
    for (i=0; i < ElemCount; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4557
        if (!_cmsWriteUInt32Number(io, ElementOffsets[i])) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4558
        if (!_cmsWriteUInt32Number(io, ElementSizes[i])) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4559
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4560
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4561
    if (!io ->Seek(io, CurrentPos)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4562
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4563
    if (ElementOffsets != NULL) _cmsFree(self ->ContextID, ElementOffsets);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4564
    if (ElementSizes != NULL) _cmsFree(self ->ContextID, ElementSizes);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4565
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4566
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4567
Error:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4568
    if (ElementOffsets != NULL) _cmsFree(self ->ContextID, ElementOffsets);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4569
    if (ElementSizes != NULL) _cmsFree(self ->ContextID, ElementSizes);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4570
    return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4571
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4572
    cmsUNUSED_PARAMETER(nItems);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4573
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4574
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4575
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4576
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4577
void* Type_MPE_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4578
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4579
    return (void*) cmsPipelineDup((cmsPipeline*) Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4580
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4581
    cmsUNUSED_PARAMETER(n);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4582
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4583
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4584
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4585
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4586
void Type_MPE_Free(struct _cms_typehandler_struct* self, void *Ptr)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4587
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4588
    cmsPipelineFree((cmsPipeline*) Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4589
    return;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4590
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4591
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4592
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4593
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4594
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4595
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4596
// Type cmsSigVcgtType
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4597
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4598
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4599
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4600
#define cmsVideoCardGammaTableType    0
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4601
#define cmsVideoCardGammaFormulaType  1
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4602
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4603
// Used internally
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4604
typedef struct {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4605
    double Gamma;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4606
    double Min;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4607
    double Max;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4608
} _cmsVCGTGAMMA;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4609
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4610
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4611
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4612
void *Type_vcgt_Read(struct _cms_typehandler_struct* self,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4613
                     cmsIOHANDLER* io,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4614
                     cmsUInt32Number* nItems,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4615
                     cmsUInt32Number SizeOfTag)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4616
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4617
    cmsUInt32Number TagType, n, i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4618
    cmsToneCurve** Curves;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4619
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4620
    *nItems = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4621
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4622
    // Read tag type
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4623
    if (!_cmsReadUInt32Number(io, &TagType)) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4624
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4625
    // Allocate space for the array
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4626
    Curves = ( cmsToneCurve**) _cmsCalloc(self ->ContextID, 3, sizeof(cmsToneCurve*));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4627
    if (Curves == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4628
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4629
    // There are two possible flavors
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4630
    switch (TagType) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4631
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4632
    // Gamma is stored as a table
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4633
    case cmsVideoCardGammaTableType:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4634
    {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4635
       cmsUInt16Number nChannels, nElems, nBytes;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4636
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4637
       // Check channel count, which should be 3 (we don't support monochrome this time)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4638
       if (!_cmsReadUInt16Number(io, &nChannels)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4639
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4640
       if (nChannels != 3) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4641
           cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported number of channels for VCGT '%d'", nChannels);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4642
           goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4643
       }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4644
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4645
       // Get Table element count and bytes per element
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4646
       if (!_cmsReadUInt16Number(io, &nElems)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4647
       if (!_cmsReadUInt16Number(io, &nBytes)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4648
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4649
       // Adobe's quirk fixup. Fixing broken profiles...
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4650
       if (nElems == 256 && nBytes == 1 && SizeOfTag == 1576)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4651
           nBytes = 2;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4652
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4653
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4654
       // Populate tone curves
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4655
       for (n=0; n < 3; n++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4656
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4657
           Curves[n] = cmsBuildTabulatedToneCurve16(self ->ContextID, nElems, NULL);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4658
           if (Curves[n] == NULL) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4659
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4660
           // On depending on byte depth
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4661
           switch (nBytes) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4662
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4663
           // One byte, 0..255
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4664
           case 1:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4665
               for (i=0; i < nElems; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4666
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4667
                   cmsUInt8Number v;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4668
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4669
                      if (!_cmsReadUInt8Number(io, &v)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4670
                      Curves[n] ->Table16[i] = FROM_8_TO_16(v);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4671
               }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4672
               break;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4673
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4674
           // One word 0..65535
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4675
           case 2:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4676
              if (!_cmsReadUInt16Array(io, nElems, Curves[n]->Table16)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4677
              break;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4678
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4679
          // Unsupported
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4680
           default:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4681
              cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported bit depth for VCGT '%d'", nBytes * 8);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4682
              goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4683
           }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4684
       } // For all 3 channels
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4685
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4686
    break;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4687
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4688
   // In this case, gamma is stored as a formula
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4689
   case cmsVideoCardGammaFormulaType:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4690
   {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4691
       _cmsVCGTGAMMA Colorant[3];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4692
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4693
        // Populate tone curves
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4694
       for (n=0; n < 3; n++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4695
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4696
           double Params[10];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4697
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4698
           if (!_cmsRead15Fixed16Number(io, &Colorant[n].Gamma)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4699
           if (!_cmsRead15Fixed16Number(io, &Colorant[n].Min)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4700
           if (!_cmsRead15Fixed16Number(io, &Colorant[n].Max)) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4701
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4702
            // Parametric curve type 5 is:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4703
            // Y = (aX + b)^Gamma + e | X >= d
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4704
            // Y = cX + f             | X < d
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4705
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4706
            // vcgt formula is:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4707
            // Y = (Max – Min) * (X ^ Gamma) + Min
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4708
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4709
            // So, the translation is
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4710
            // a = (Max – Min) ^ ( 1 / Gamma)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4711
            // e = Min
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4712
            // b=c=d=f=0
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4713
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4714
           Params[0] = Colorant[n].Gamma;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4715
           Params[1] = pow((Colorant[n].Max - Colorant[n].Min), (1.0 / Colorant[n].Gamma));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4716
           Params[2] = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4717
           Params[3] = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4718
           Params[4] = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4719
           Params[5] = Colorant[n].Min;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4720
           Params[6] = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4721
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4722
           Curves[n] = cmsBuildParametricToneCurve(self ->ContextID, 5, Params);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4723
           if (Curves[n] == NULL) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4724
       }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4725
   }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4726
   break;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4727
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4728
   // Unsupported
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4729
   default:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4730
      cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported tag type for VCGT '%d'", TagType);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4731
      goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4732
   }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4733
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4734
   *nItems = 1;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4735
   return (void*) Curves;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4736
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4737
// Regret,  free all resources
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4738
Error:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4739
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4740
    cmsFreeToneCurveTriple(Curves);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4741
    _cmsFree(self ->ContextID, Curves);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4742
    return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4743
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4744
     cmsUNUSED_PARAMETER(SizeOfTag);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4745
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4746
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4747
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4748
// We don't support all flavors, only 16bits tables and formula
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4749
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4750
cmsBool Type_vcgt_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4751
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4752
    cmsToneCurve** Curves =  (cmsToneCurve**) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4753
    cmsUInt32Number i, j;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4754
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4755
    if (cmsGetToneCurveParametricType(Curves[0]) == 5 &&
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4756
        cmsGetToneCurveParametricType(Curves[1]) == 5 &&
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4757
        cmsGetToneCurveParametricType(Curves[2]) == 5) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4758
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4759
            if (!_cmsWriteUInt32Number(io, cmsVideoCardGammaFormulaType)) return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4760
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4761
            // Save parameters
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4762
            for (i=0; i < 3; i++) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4763
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4764
                _cmsVCGTGAMMA v;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4765
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4766
                v.Gamma = Curves[i] ->Segments[0].Params[0];
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4767
                v.Min   = Curves[i] ->Segments[0].Params[5];
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4768
                v.Max   = pow(Curves[i] ->Segments[0].Params[1], v.Gamma) + v.Min;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4769
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4770
                if (!_cmsWrite15Fixed16Number(io, v.Gamma)) return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4771
                if (!_cmsWrite15Fixed16Number(io, v.Min)) return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4772
                if (!_cmsWrite15Fixed16Number(io, v.Max)) return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4773
            }
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4774
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4775
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4776
    else {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4777
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4778
        // Always store as a table of 256 words
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4779
        if (!_cmsWriteUInt32Number(io, cmsVideoCardGammaTableType)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4780
        if (!_cmsWriteUInt16Number(io, 3)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4781
        if (!_cmsWriteUInt16Number(io, 256)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4782
        if (!_cmsWriteUInt16Number(io, 2)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4783
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4784
        for (i=0; i < 3; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4785
            for (j=0; j < 256; j++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4786
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4787
                cmsFloat32Number v = cmsEvalToneCurveFloat(Curves[i], (cmsFloat32Number) (j / 255.0));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4788
                cmsUInt16Number  n = _cmsQuickSaturateWord(v * 65535.0);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4789
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4790
                if (!_cmsWriteUInt16Number(io, n)) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4791
            }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4792
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4793
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4794
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4795
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4796
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4797
    cmsUNUSED_PARAMETER(self);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4798
    cmsUNUSED_PARAMETER(nItems);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4799
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4800
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4801
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4802
void* Type_vcgt_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4803
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4804
    cmsToneCurve** OldCurves =  (cmsToneCurve**) Ptr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4805
    cmsToneCurve** NewCurves;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4806
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4807
    NewCurves = ( cmsToneCurve**) _cmsCalloc(self ->ContextID, 3, sizeof(cmsToneCurve*));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4808
    if (NewCurves == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4809
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4810
    NewCurves[0] = cmsDupToneCurve(OldCurves[0]);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4811
    NewCurves[1] = cmsDupToneCurve(OldCurves[1]);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4812
    NewCurves[2] = cmsDupToneCurve(OldCurves[2]);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4813
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4814
    return (void*) NewCurves;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4815
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4816
    cmsUNUSED_PARAMETER(n);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4817
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4818
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4819
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4820
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4821
void Type_vcgt_Free(struct _cms_typehandler_struct* self, void* Ptr)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4822
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4823
    cmsFreeToneCurveTriple((cmsToneCurve**) Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4824
    _cmsFree(self ->ContextID, Ptr);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4825
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  4826
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4827
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4828
// ********************************************************************************
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4829
// Type cmsSigDictType
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4830
// ********************************************************************************
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4831
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4832
// Single column of the table can point to wchar or MLUC elements. Holds arrays of data
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4833
typedef struct {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4834
    cmsContext ContextID;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4835
    cmsUInt32Number *Offsets;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4836
    cmsUInt32Number *Sizes;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4837
} _cmsDICelem;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4838
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4839
typedef struct {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4840
    _cmsDICelem Name, Value, DisplayName, DisplayValue;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4841
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4842
} _cmsDICarray;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4843
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4844
// Allocate an empty array element
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4845
static
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4846
cmsBool AllocElem(cmsContext ContextID, _cmsDICelem* e,  cmsUInt32Number Count)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4847
{
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  4848
    e->Offsets = (cmsUInt32Number *) _cmsCalloc(ContextID, Count, sizeof(cmsUInt32Number));
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4849
    if (e->Offsets == NULL) return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4850
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  4851
    e->Sizes = (cmsUInt32Number *) _cmsCalloc(ContextID, Count, sizeof(cmsUInt32Number));
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4852
    if (e->Sizes == NULL) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4853
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4854
        _cmsFree(ContextID, e -> Offsets);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4855
        return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4856
    }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4857
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4858
    e ->ContextID = ContextID;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4859
    return TRUE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4860
}
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4861
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4862
// Free an array element
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4863
static
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4864
void FreeElem(_cmsDICelem* e)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4865
{
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4866
    if (e ->Offsets != NULL)  _cmsFree(e -> ContextID, e -> Offsets);
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  4867
    if (e ->Sizes   != NULL)  _cmsFree(e -> ContextID, e -> Sizes);
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4868
    e->Offsets = e ->Sizes = NULL;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4869
}
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4870
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4871
// Get rid of whole array
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4872
static
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4873
void FreeArray( _cmsDICarray* a)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4874
{
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4875
    if (a ->Name.Offsets != NULL) FreeElem(&a->Name);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4876
    if (a ->Value.Offsets != NULL) FreeElem(&a ->Value);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4877
    if (a ->DisplayName.Offsets != NULL) FreeElem(&a->DisplayName);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4878
    if (a ->DisplayValue.Offsets != NULL) FreeElem(&a ->DisplayValue);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4879
}
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4880
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4881
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4882
// Allocate whole array
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4883
static
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4884
cmsBool AllocArray(cmsContext ContextID, _cmsDICarray* a, cmsUInt32Number Count, cmsUInt32Number Length)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4885
{
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4886
    // Empty values
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4887
    memset(a, 0, sizeof(_cmsDICarray));
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4888
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4889
    // On depending on record size, create column arrays
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4890
    if (!AllocElem(ContextID, &a ->Name, Count)) goto Error;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4891
    if (!AllocElem(ContextID, &a ->Value, Count)) goto Error;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4892
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4893
    if (Length > 16) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4894
        if (!AllocElem(ContextID, &a -> DisplayName, Count)) goto Error;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4895
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4896
    }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4897
    if (Length > 24) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4898
        if (!AllocElem(ContextID, &a ->DisplayValue, Count)) goto Error;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4899
    }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4900
    return TRUE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4901
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4902
Error:
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4903
    FreeArray(a);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4904
    return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4905
}
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4906
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4907
// Read one element
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4908
static
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4909
cmsBool ReadOneElem(cmsIOHANDLER* io,  _cmsDICelem* e, cmsUInt32Number i, cmsUInt32Number BaseOffset)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4910
{
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4911
    if (!_cmsReadUInt32Number(io, &e->Offsets[i])) return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4912
    if (!_cmsReadUInt32Number(io, &e ->Sizes[i])) return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4913
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4914
    // An offset of zero has special meaning and shal be preserved
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4915
    if (e ->Offsets[i] > 0)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4916
        e ->Offsets[i] += BaseOffset;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4917
    return TRUE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4918
}
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4919
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4920
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4921
static
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4922
cmsBool ReadOffsetArray(cmsIOHANDLER* io,  _cmsDICarray* a, cmsUInt32Number Count, cmsUInt32Number Length, cmsUInt32Number BaseOffset)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4923
{
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4924
    cmsUInt32Number i;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4925
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4926
    // Read column arrays
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4927
    for (i=0; i < Count; i++) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4928
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4929
        if (!ReadOneElem(io, &a -> Name, i, BaseOffset)) return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4930
        if (!ReadOneElem(io, &a -> Value, i, BaseOffset)) return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4931
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4932
        if (Length > 16) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4933
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4934
            if (!ReadOneElem(io, &a ->DisplayName, i, BaseOffset)) return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4935
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4936
        }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4937
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4938
        if (Length > 24) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4939
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4940
            if (!ReadOneElem(io, & a -> DisplayValue, i, BaseOffset)) return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4941
        }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4942
    }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4943
    return TRUE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4944
}
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4945
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4946
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4947
// Write one element
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4948
static
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4949
cmsBool WriteOneElem(cmsIOHANDLER* io,  _cmsDICelem* e, cmsUInt32Number i)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4950
{
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4951
    if (!_cmsWriteUInt32Number(io, e->Offsets[i])) return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4952
    if (!_cmsWriteUInt32Number(io, e ->Sizes[i])) return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4953
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4954
    return TRUE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4955
}
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4956
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4957
static
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4958
cmsBool WriteOffsetArray(cmsIOHANDLER* io,  _cmsDICarray* a, cmsUInt32Number Count, cmsUInt32Number Length)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4959
{
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4960
    cmsUInt32Number i;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4961
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4962
    for (i=0; i < Count; i++) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4963
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4964
        if (!WriteOneElem(io, &a -> Name, i)) return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4965
        if (!WriteOneElem(io, &a -> Value, i))  return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4966
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4967
        if (Length > 16) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4968
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4969
            if (!WriteOneElem(io, &a -> DisplayName, i))  return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4970
        }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4971
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4972
        if (Length > 24) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4973
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4974
            if (!WriteOneElem(io, &a -> DisplayValue, i))  return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4975
        }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4976
    }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4977
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4978
    return TRUE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4979
}
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4980
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4981
static
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4982
cmsBool ReadOneWChar(cmsIOHANDLER* io,  _cmsDICelem* e, cmsUInt32Number i, wchar_t ** wcstr)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4983
{
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4984
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4985
    cmsUInt32Number nChars;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4986
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4987
      // Special case for undefined strings (see ICC Votable
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4988
      // Proposal Submission, Dictionary Type and Metadata TAG Definition)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4989
      if (e -> Offsets[i] == 0) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4990
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4991
          *wcstr = NULL;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4992
          return TRUE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4993
      }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4994
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4995
      if (!io -> Seek(io, e -> Offsets[i])) return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4996
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4997
      nChars = e ->Sizes[i] / sizeof(cmsUInt16Number);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4998
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  4999
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5000
      *wcstr = (wchar_t*) _cmsMallocZero(e ->ContextID, (nChars + 1) * sizeof(wchar_t));
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5001
      if (*wcstr == NULL) return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5002
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5003
      if (!_cmsReadWCharArray(io, nChars, *wcstr)) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5004
          _cmsFree(e ->ContextID, *wcstr);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5005
          return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5006
      }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5007
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5008
      // End of string marker
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5009
      (*wcstr)[nChars] = 0;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5010
      return TRUE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5011
}
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5012
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5013
static
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5014
cmsUInt32Number mywcslen(const wchar_t *s)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5015
{
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5016
    const wchar_t *p;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5017
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5018
    p = s;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5019
    while (*p)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5020
        p++;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5021
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5022
    return (cmsUInt32Number)(p - s);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5023
}
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5024
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5025
static
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5026
cmsBool WriteOneWChar(cmsIOHANDLER* io,  _cmsDICelem* e, cmsUInt32Number i, const wchar_t * wcstr, cmsUInt32Number BaseOffset)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5027
{
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5028
    cmsUInt32Number Before = io ->Tell(io);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5029
    cmsUInt32Number n;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5030
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5031
    e ->Offsets[i] = Before - BaseOffset;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5032
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5033
    if (wcstr == NULL) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5034
        e ->Sizes[i] = 0;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5035
        e ->Offsets[i] = 0;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5036
        return TRUE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5037
    }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5038
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5039
    n = mywcslen(wcstr);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5040
    if (!_cmsWriteWCharArray(io,  n, wcstr)) return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5041
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5042
    e ->Sizes[i] = io ->Tell(io) - Before;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5043
    return TRUE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5044
}
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5045
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5046
static
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5047
cmsBool ReadOneMLUC(struct _cms_typehandler_struct* self, cmsIOHANDLER* io,  _cmsDICelem* e, cmsUInt32Number i, cmsMLU** mlu)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5048
{
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5049
    cmsUInt32Number nItems = 0;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5050
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5051
    // A way to get null MLUCs
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5052
    if (e -> Offsets[i] == 0 || e ->Sizes[i] == 0) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5053
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5054
        *mlu = NULL;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5055
        return TRUE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5056
    }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5057
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5058
    if (!io -> Seek(io, e -> Offsets[i])) return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5059
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5060
    *mlu = (cmsMLU*) Type_MLU_Read(self, io, &nItems, e ->Sizes[i]);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5061
    return *mlu != NULL;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5062
}
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5063
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5064
static
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5065
cmsBool WriteOneMLUC(struct _cms_typehandler_struct* self, cmsIOHANDLER* io,  _cmsDICelem* e, cmsUInt32Number i, const cmsMLU* mlu, cmsUInt32Number BaseOffset)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5066
{
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5067
    cmsUInt32Number Before;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5068
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5069
     // Special case for undefined strings (see ICC Votable
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5070
     // Proposal Submission, Dictionary Type and Metadata TAG Definition)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5071
     if (mlu == NULL) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5072
        e ->Sizes[i] = 0;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5073
        e ->Offsets[i] = 0;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5074
        return TRUE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5075
    }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5076
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5077
    Before = io ->Tell(io);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5078
    e ->Offsets[i] = Before - BaseOffset;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5079
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5080
    if (!Type_MLU_Write(self, io, (void*) mlu, 1)) return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5081
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5082
    e ->Sizes[i] = io ->Tell(io) - Before;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5083
    return TRUE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5084
}
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5085
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5086
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5087
static
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5088
void *Type_Dictionary_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5089
{
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5090
   cmsHANDLE hDict;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5091
   cmsUInt32Number i, Count, Length;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5092
   cmsUInt32Number BaseOffset;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5093
   _cmsDICarray a;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5094
   wchar_t *NameWCS = NULL, *ValueWCS = NULL;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5095
   cmsMLU *DisplayNameMLU = NULL, *DisplayValueMLU=NULL;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5096
   cmsBool rc;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5097
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5098
    *nItems = 0;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5099
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5100
    // Get actual position as a basis for element offsets
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5101
    BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5102
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5103
    // Get name-value record count
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5104
    if (!_cmsReadUInt32Number(io, &Count)) return NULL;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5105
    SizeOfTag -= sizeof(cmsUInt32Number);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5106
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  5107
    // Get rec length
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5108
    if (!_cmsReadUInt32Number(io, &Length)) return NULL;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5109
    SizeOfTag -= sizeof(cmsUInt32Number);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5110
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5111
    // Check for valid lengths
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5112
    if (Length != 16 && Length != 24 && Length != 32) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5113
         cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unknown record length in dictionary '%d'", Length);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5114
         return NULL;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5115
    }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5116
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5117
    // Creates an empty dictionary
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5118
    hDict = cmsDictAlloc(self -> ContextID);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5119
    if (hDict == NULL) return NULL;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5120
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5121
    // On depending on record size, create column arrays
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5122
    if (!AllocArray(self -> ContextID, &a, Count, Length)) goto Error;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5123
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5124
    // Read column arrays
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5125
    if (!ReadOffsetArray(io, &a, Count, Length, BaseOffset)) goto Error;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5126
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5127
    // Seek to each element and read it
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5128
    for (i=0; i < Count; i++) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5129
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5130
        if (!ReadOneWChar(io, &a.Name, i, &NameWCS)) goto Error;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5131
        if (!ReadOneWChar(io, &a.Value, i, &ValueWCS)) goto Error;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5132
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5133
        if (Length > 16) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5134
            if (!ReadOneMLUC(self, io, &a.DisplayName, i, &DisplayNameMLU)) goto Error;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5135
        }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5136
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5137
        if (Length > 24) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5138
            if (!ReadOneMLUC(self, io, &a.DisplayValue, i, &DisplayValueMLU)) goto Error;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5139
        }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5140
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  5141
        if (NameWCS == NULL || ValueWCS == NULL) {
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  5142
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  5143
            cmsSignalError(self->ContextID, cmsERROR_CORRUPTION_DETECTED, "Bad dictionary Name/Value");
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  5144
            rc = FALSE;
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  5145
        }
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  5146
        else {
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  5147
26609
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5148
            rc = cmsDictAddEntry(hDict, NameWCS, ValueWCS, DisplayNameMLU, DisplayValueMLU);
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  5149
        }
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5150
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5151
        if (NameWCS != NULL) _cmsFree(self ->ContextID, NameWCS);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5152
        if (ValueWCS != NULL) _cmsFree(self ->ContextID, ValueWCS);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5153
        if (DisplayNameMLU != NULL) cmsMLUfree(DisplayNameMLU);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5154
        if (DisplayValueMLU != NULL) cmsMLUfree(DisplayValueMLU);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5155
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  5156
        if (!rc) goto Error;
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5157
    }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5158
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5159
   FreeArray(&a);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5160
   *nItems = 1;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5161
   return (void*) hDict;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5162
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5163
Error:
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5164
   FreeArray(&a);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5165
   cmsDictFree(hDict);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5166
   return NULL;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5167
}
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5168
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5169
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5170
static
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5171
cmsBool Type_Dictionary_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5172
{
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5173
    cmsHANDLE hDict = (cmsHANDLE) Ptr;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5174
    const cmsDICTentry* p;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5175
    cmsBool AnyName, AnyValue;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5176
    cmsUInt32Number i, Count, Length;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5177
    cmsUInt32Number DirectoryPos, CurrentPos, BaseOffset;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5178
   _cmsDICarray a;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5179
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5180
    if (hDict == NULL) return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5181
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5182
    BaseOffset = io ->Tell(io) - sizeof(_cmsTagBase);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5183
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5184
    // Let's inspect the dictionary
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5185
    Count = 0; AnyName = FALSE; AnyValue = FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5186
    for (p = cmsDictGetEntryList(hDict); p != NULL; p = cmsDictNextEntry(p)) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5187
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5188
        if (p ->DisplayName != NULL) AnyName = TRUE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5189
        if (p ->DisplayValue != NULL) AnyValue = TRUE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5190
        Count++;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5191
    }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5192
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5193
    Length = 16;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5194
    if (AnyName)  Length += 8;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5195
    if (AnyValue) Length += 8;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5196
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5197
    if (!_cmsWriteUInt32Number(io, Count)) return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5198
    if (!_cmsWriteUInt32Number(io, Length)) return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5199
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5200
    // Keep starting position of offsets table
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5201
    DirectoryPos = io ->Tell(io);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5202
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5203
    // Allocate offsets array
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5204
    if (!AllocArray(self ->ContextID, &a, Count, Length)) goto Error;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5205
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5206
    // Write a fake directory to be filled latter on
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5207
    if (!WriteOffsetArray(io, &a, Count, Length)) goto Error;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5208
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5209
    // Write each element. Keep track of the size as well.
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5210
    p = cmsDictGetEntryList(hDict);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5211
    for (i=0; i < Count; i++) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5212
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5213
        if (!WriteOneWChar(io, &a.Name, i,  p ->Name, BaseOffset)) goto Error;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5214
        if (!WriteOneWChar(io, &a.Value, i, p ->Value, BaseOffset)) goto Error;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5215
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5216
        if (p ->DisplayName != NULL) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5217
            if (!WriteOneMLUC(self, io, &a.DisplayName, i, p ->DisplayName, BaseOffset)) goto Error;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5218
        }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5219
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5220
        if (p ->DisplayValue != NULL) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5221
            if (!WriteOneMLUC(self, io, &a.DisplayValue, i, p ->DisplayValue, BaseOffset)) goto Error;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5222
        }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5223
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5224
       p = cmsDictNextEntry(p);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5225
    }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5226
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5227
    // Write the directory
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5228
    CurrentPos = io ->Tell(io);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5229
    if (!io ->Seek(io, DirectoryPos)) goto Error;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5230
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5231
    if (!WriteOffsetArray(io, &a, Count, Length)) goto Error;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5232
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5233
    if (!io ->Seek(io, CurrentPos)) goto Error;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5234
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5235
    FreeArray(&a);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5236
    return TRUE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5237
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5238
Error:
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5239
    FreeArray(&a);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5240
    return FALSE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5241
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5242
    cmsUNUSED_PARAMETER(nItems);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5243
}
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5244
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5245
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5246
static
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5247
void* Type_Dictionary_Dup(struct _cms_typehandler_struct* self, const void *Ptr, cmsUInt32Number n)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5248
{
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5249
    return (void*)  cmsDictDup((cmsHANDLE) Ptr);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5250
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5251
    cmsUNUSED_PARAMETER(n);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5252
    cmsUNUSED_PARAMETER(self);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5253
}
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5254
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5255
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5256
static
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5257
void Type_Dictionary_Free(struct _cms_typehandler_struct* self, void* Ptr)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5258
{
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5259
    cmsDictFree((cmsHANDLE) Ptr);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5260
    cmsUNUSED_PARAMETER(self);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5261
}
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5262
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5263
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5264
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5265
// Type support main routines
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5266
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5267
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5268
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5269
// This is the list of built-in types
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5270
static _cmsTagTypeLinkedList SupportedTagTypes[] = {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5271
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5272
{TYPE_HANDLER(cmsSigChromaticityType,          Chromaticity),        &SupportedTagTypes[1] },
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5273
{TYPE_HANDLER(cmsSigColorantOrderType,         ColorantOrderType),   &SupportedTagTypes[2] },
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5274
{TYPE_HANDLER(cmsSigS15Fixed16ArrayType,       S15Fixed16),          &SupportedTagTypes[3] },
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5275
{TYPE_HANDLER(cmsSigU16Fixed16ArrayType,       U16Fixed16),          &SupportedTagTypes[4] },
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5276
{TYPE_HANDLER(cmsSigTextType,                  Text),                &SupportedTagTypes[5] },
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5277
{TYPE_HANDLER(cmsSigTextDescriptionType,       Text_Description),    &SupportedTagTypes[6] },
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5278
{TYPE_HANDLER(cmsSigCurveType,                 Curve),               &SupportedTagTypes[7] },
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5279
{TYPE_HANDLER(cmsSigParametricCurveType,       ParametricCurve),     &SupportedTagTypes[8] },
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5280
{TYPE_HANDLER(cmsSigDateTimeType,              DateTime),            &SupportedTagTypes[9] },
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5281
{TYPE_HANDLER(cmsSigLut8Type,                  LUT8),                &SupportedTagTypes[10] },
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5282
{TYPE_HANDLER(cmsSigLut16Type,                 LUT16),               &SupportedTagTypes[11] },
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5283
{TYPE_HANDLER(cmsSigColorantTableType,         ColorantTable),       &SupportedTagTypes[12] },
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5284
{TYPE_HANDLER(cmsSigNamedColor2Type,           NamedColor),          &SupportedTagTypes[13] },
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5285
{TYPE_HANDLER(cmsSigMultiLocalizedUnicodeType, MLU),                 &SupportedTagTypes[14] },
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5286
{TYPE_HANDLER(cmsSigProfileSequenceDescType,   ProfileSequenceDesc), &SupportedTagTypes[15] },
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5287
{TYPE_HANDLER(cmsSigSignatureType,             Signature),           &SupportedTagTypes[16] },
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5288
{TYPE_HANDLER(cmsSigMeasurementType,           Measurement),         &SupportedTagTypes[17] },
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5289
{TYPE_HANDLER(cmsSigDataType,                  Data),                &SupportedTagTypes[18] },
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5290
{TYPE_HANDLER(cmsSigLutAtoBType,               LUTA2B),              &SupportedTagTypes[19] },
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5291
{TYPE_HANDLER(cmsSigLutBtoAType,               LUTB2A),              &SupportedTagTypes[20] },
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5292
{TYPE_HANDLER(cmsSigUcrBgType,                 UcrBg),               &SupportedTagTypes[21] },
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5293
{TYPE_HANDLER(cmsSigCrdInfoType,               CrdInfo),             &SupportedTagTypes[22] },
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5294
{TYPE_HANDLER(cmsSigMultiProcessElementType,   MPE),                 &SupportedTagTypes[23] },
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5295
{TYPE_HANDLER(cmsSigScreeningType,             Screening),           &SupportedTagTypes[24] },
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5296
{TYPE_HANDLER(cmsSigViewingConditionsType,     ViewingConditions),   &SupportedTagTypes[25] },
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5297
{TYPE_HANDLER(cmsSigXYZType,                   XYZ),                 &SupportedTagTypes[26] },
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5298
{TYPE_HANDLER(cmsCorbisBrokenXYZtype,          XYZ),                 &SupportedTagTypes[27] },
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5299
{TYPE_HANDLER(cmsMonacoBrokenCurveType,        Curve),               &SupportedTagTypes[28] },
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5300
{TYPE_HANDLER(cmsSigProfileSequenceIdType,     ProfileSequenceId),   &SupportedTagTypes[29] },
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5301
{TYPE_HANDLER(cmsSigDictType,                  Dictionary),          &SupportedTagTypes[30] },
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5302
{TYPE_HANDLER(cmsSigVcgtType,                  vcgt),                NULL }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5303
};
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5304
26609
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5305
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5306
_cmsTagTypePluginChunkType _cmsTagTypePluginChunk = { NULL };
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5307
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5308
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5309
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5310
// Duplicates the zone of memory used by the plug-in in the new context
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5311
static
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5312
void DupTagTypeList(struct _cmsContext_struct* ctx,
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5313
                    const struct _cmsContext_struct* src,
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5314
                    int loc)
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5315
{
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5316
   _cmsTagTypePluginChunkType newHead = { NULL };
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5317
   _cmsTagTypeLinkedList*  entry;
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5318
   _cmsTagTypeLinkedList*  Anterior = NULL;
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5319
   _cmsTagTypePluginChunkType* head = (_cmsTagTypePluginChunkType*) src->chunks[loc];
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5320
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5321
   // Walk the list copying all nodes
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5322
   for (entry = head->TagTypes;
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5323
       entry != NULL;
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5324
       entry = entry ->Next) {
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5325
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5326
           _cmsTagTypeLinkedList *newEntry = ( _cmsTagTypeLinkedList *) _cmsSubAllocDup(ctx ->MemPool, entry, sizeof(_cmsTagTypeLinkedList));
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5327
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5328
           if (newEntry == NULL)
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5329
               return;
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5330
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5331
           // We want to keep the linked list order, so this is a little bit tricky
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5332
           newEntry -> Next = NULL;
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5333
           if (Anterior)
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5334
               Anterior -> Next = newEntry;
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5335
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5336
           Anterior = newEntry;
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5337
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5338
           if (newHead.TagTypes == NULL)
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5339
               newHead.TagTypes = newEntry;
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5340
   }
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5341
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5342
   ctx ->chunks[loc] = _cmsSubAllocDup(ctx->MemPool, &newHead, sizeof(_cmsTagTypePluginChunkType));
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5343
}
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5344
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5345
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5346
void _cmsAllocTagTypePluginChunk(struct _cmsContext_struct* ctx,
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5347
                                 const struct _cmsContext_struct* src)
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5348
{
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5349
    if (src != NULL) {
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5350
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5351
        // Duplicate the LIST
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5352
        DupTagTypeList(ctx, src, TagTypePlugin);
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5353
    }
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5354
    else {
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5355
        static _cmsTagTypePluginChunkType TagTypePluginChunk = { NULL };
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5356
        ctx ->chunks[TagTypePlugin] = _cmsSubAllocDup(ctx ->MemPool, &TagTypePluginChunk, sizeof(_cmsTagTypePluginChunkType));
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5357
    }
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5358
}
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5359
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5360
void _cmsAllocMPETypePluginChunk(struct _cmsContext_struct* ctx,
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5361
                               const struct _cmsContext_struct* src)
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5362
{
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5363
    if (src != NULL) {
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5364
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5365
        // Duplicate the LIST
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5366
        DupTagTypeList(ctx, src, MPEPlugin);
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5367
    }
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5368
    else {
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5369
        static _cmsTagTypePluginChunkType TagTypePluginChunk = { NULL };
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5370
        ctx ->chunks[MPEPlugin] = _cmsSubAllocDup(ctx ->MemPool, &TagTypePluginChunk, sizeof(_cmsTagTypePluginChunkType));
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5371
    }
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5372
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5373
}
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5374
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5375
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5376
// Both kind of plug-ins share same structure
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  5377
cmsBool  _cmsRegisterTagTypePlugin(cmsContext id, cmsPluginBase* Data)
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5378
{
26609
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5379
    return RegisterTypesPlugin(id, Data, TagTypePlugin);
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5380
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5381
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  5382
cmsBool  _cmsRegisterMultiProcessElementPlugin(cmsContext id, cmsPluginBase* Data)
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5383
{
26609
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5384
    return RegisterTypesPlugin(id, Data,MPEPlugin);
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5385
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5386
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5387
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5388
// Wrapper for tag types
26609
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5389
cmsTagTypeHandler* _cmsGetTagTypeHandler(cmsContext ContextID, cmsTagTypeSignature sig)
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5390
{
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5391
    _cmsTagTypePluginChunkType* ctx = ( _cmsTagTypePluginChunkType*) _cmsContextGetClientChunk(ContextID, TagTypePlugin);
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5392
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5393
    return GetHandler(sig, ctx->TagTypes, SupportedTagTypes);
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5394
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5395
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5396
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5397
// Tag support main routines
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5398
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5399
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5400
typedef struct _cmsTagLinkedList_st {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5401
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5402
            cmsTagSignature Signature;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5403
            cmsTagDescriptor Descriptor;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5404
            struct _cmsTagLinkedList_st* Next;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5405
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5406
} _cmsTagLinkedList;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5407
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5408
// This is the list of built-in tags
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5409
static _cmsTagLinkedList SupportedTags[] = {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5410
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5411
    { cmsSigAToB0Tag,               { 1, 3,  { cmsSigLut16Type,  cmsSigLutAtoBType, cmsSigLut8Type}, DecideLUTtypeA2B}, &SupportedTags[1]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5412
    { cmsSigAToB1Tag,               { 1, 3,  { cmsSigLut16Type,  cmsSigLutAtoBType, cmsSigLut8Type}, DecideLUTtypeA2B}, &SupportedTags[2]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5413
    { cmsSigAToB2Tag,               { 1, 3,  { cmsSigLut16Type,  cmsSigLutAtoBType, cmsSigLut8Type}, DecideLUTtypeA2B}, &SupportedTags[3]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5414
    { cmsSigBToA0Tag,               { 1, 3,  { cmsSigLut16Type,  cmsSigLutBtoAType, cmsSigLut8Type}, DecideLUTtypeB2A}, &SupportedTags[4]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5415
    { cmsSigBToA1Tag,               { 1, 3,  { cmsSigLut16Type,  cmsSigLutBtoAType, cmsSigLut8Type}, DecideLUTtypeB2A}, &SupportedTags[5]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5416
    { cmsSigBToA2Tag,               { 1, 3,  { cmsSigLut16Type,  cmsSigLutBtoAType, cmsSigLut8Type}, DecideLUTtypeB2A}, &SupportedTags[6]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5417
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5418
    // Allow corbis  and its broken XYZ type
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5419
    { cmsSigRedColorantTag,         { 1, 2, { cmsSigXYZType, cmsCorbisBrokenXYZtype }, DecideXYZtype}, &SupportedTags[7]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5420
    { cmsSigGreenColorantTag,       { 1, 2, { cmsSigXYZType, cmsCorbisBrokenXYZtype }, DecideXYZtype}, &SupportedTags[8]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5421
    { cmsSigBlueColorantTag,        { 1, 2, { cmsSigXYZType, cmsCorbisBrokenXYZtype }, DecideXYZtype}, &SupportedTags[9]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5422
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5423
    { cmsSigRedTRCTag,              { 1, 3, { cmsSigCurveType, cmsSigParametricCurveType, cmsMonacoBrokenCurveType }, DecideCurveType}, &SupportedTags[10]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5424
    { cmsSigGreenTRCTag,            { 1, 3, { cmsSigCurveType, cmsSigParametricCurveType, cmsMonacoBrokenCurveType }, DecideCurveType}, &SupportedTags[11]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5425
    { cmsSigBlueTRCTag,             { 1, 3, { cmsSigCurveType, cmsSigParametricCurveType, cmsMonacoBrokenCurveType }, DecideCurveType}, &SupportedTags[12]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5426
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5427
    { cmsSigCalibrationDateTimeTag, { 1, 1, { cmsSigDateTimeType }, NULL}, &SupportedTags[13]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5428
    { cmsSigCharTargetTag,          { 1, 1, { cmsSigTextType },     NULL}, &SupportedTags[14]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5429
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5430
    { cmsSigChromaticAdaptationTag, { 9, 1, { cmsSigS15Fixed16ArrayType }, NULL}, &SupportedTags[15]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5431
    { cmsSigChromaticityTag,        { 1, 1, { cmsSigChromaticityType    }, NULL}, &SupportedTags[16]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5432
    { cmsSigColorantOrderTag,       { 1, 1, { cmsSigColorantOrderType   }, NULL}, &SupportedTags[17]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5433
    { cmsSigColorantTableTag,       { 1, 1, { cmsSigColorantTableType   }, NULL}, &SupportedTags[18]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5434
    { cmsSigColorantTableOutTag,    { 1, 1, { cmsSigColorantTableType   }, NULL}, &SupportedTags[19]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5435
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5436
    { cmsSigCopyrightTag,           { 1, 3, { cmsSigTextType,  cmsSigMultiLocalizedUnicodeType, cmsSigTextDescriptionType}, DecideTextType}, &SupportedTags[20]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5437
    { cmsSigDateTimeTag,            { 1, 1, { cmsSigDateTimeType }, NULL}, &SupportedTags[21]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5438
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5439
    { cmsSigDeviceMfgDescTag,       { 1, 3, { cmsSigTextDescriptionType, cmsSigMultiLocalizedUnicodeType, cmsSigTextType}, DecideTextDescType}, &SupportedTags[22]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5440
    { cmsSigDeviceModelDescTag,     { 1, 3, { cmsSigTextDescriptionType, cmsSigMultiLocalizedUnicodeType, cmsSigTextType}, DecideTextDescType}, &SupportedTags[23]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5441
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5442
    { cmsSigGamutTag,               { 1, 3, { cmsSigLut16Type, cmsSigLutBtoAType, cmsSigLut8Type }, DecideLUTtypeB2A}, &SupportedTags[24]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5443
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5444
    { cmsSigGrayTRCTag,             { 1, 2, { cmsSigCurveType, cmsSigParametricCurveType }, DecideCurveType}, &SupportedTags[25]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5445
    { cmsSigLuminanceTag,           { 1, 1, { cmsSigXYZType }, NULL}, &SupportedTags[26]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5446
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5447
    { cmsSigMediaBlackPointTag,     { 1, 2, { cmsSigXYZType, cmsCorbisBrokenXYZtype }, NULL}, &SupportedTags[27]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5448
    { cmsSigMediaWhitePointTag,     { 1, 2, { cmsSigXYZType, cmsCorbisBrokenXYZtype }, NULL}, &SupportedTags[28]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5449
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5450
    { cmsSigNamedColor2Tag,         { 1, 1, { cmsSigNamedColor2Type }, NULL}, &SupportedTags[29]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5451
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5452
    { cmsSigPreview0Tag,            { 1, 3,  { cmsSigLut16Type, cmsSigLutBtoAType, cmsSigLut8Type }, DecideLUTtypeB2A}, &SupportedTags[30]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5453
    { cmsSigPreview1Tag,            { 1, 3,  { cmsSigLut16Type, cmsSigLutBtoAType, cmsSigLut8Type }, DecideLUTtypeB2A}, &SupportedTags[31]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5454
    { cmsSigPreview2Tag,            { 1, 3,  { cmsSigLut16Type, cmsSigLutBtoAType, cmsSigLut8Type }, DecideLUTtypeB2A}, &SupportedTags[32]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5455
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5456
    { cmsSigProfileDescriptionTag,  { 1, 3, { cmsSigTextDescriptionType, cmsSigMultiLocalizedUnicodeType, cmsSigTextType}, DecideTextDescType}, &SupportedTags[33]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5457
    { cmsSigProfileSequenceDescTag, { 1, 1, { cmsSigProfileSequenceDescType }, NULL}, &SupportedTags[34]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5458
    { cmsSigTechnologyTag,          { 1, 1, { cmsSigSignatureType }, NULL},  &SupportedTags[35]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5459
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5460
    { cmsSigColorimetricIntentImageStateTag,   { 1, 1, { cmsSigSignatureType }, NULL}, &SupportedTags[36]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5461
    { cmsSigPerceptualRenderingIntentGamutTag, { 1, 1, { cmsSigSignatureType }, NULL}, &SupportedTags[37]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5462
    { cmsSigSaturationRenderingIntentGamutTag, { 1, 1, { cmsSigSignatureType }, NULL}, &SupportedTags[38]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5463
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5464
    { cmsSigMeasurementTag,         { 1, 1, { cmsSigMeasurementType }, NULL}, &SupportedTags[39]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5465
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5466
    { cmsSigPs2CRD0Tag,             { 1, 1, { cmsSigDataType }, NULL}, &SupportedTags[40]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5467
    { cmsSigPs2CRD1Tag,             { 1, 1, { cmsSigDataType }, NULL}, &SupportedTags[41]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5468
    { cmsSigPs2CRD2Tag,             { 1, 1, { cmsSigDataType }, NULL}, &SupportedTags[42]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5469
    { cmsSigPs2CRD3Tag,             { 1, 1, { cmsSigDataType }, NULL}, &SupportedTags[43]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5470
    { cmsSigPs2CSATag,              { 1, 1, { cmsSigDataType }, NULL}, &SupportedTags[44]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5471
    { cmsSigPs2RenderingIntentTag,  { 1, 1, { cmsSigDataType }, NULL}, &SupportedTags[45]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5472
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5473
    { cmsSigViewingCondDescTag,     { 1, 3, { cmsSigTextDescriptionType, cmsSigMultiLocalizedUnicodeType, cmsSigTextType}, DecideTextDescType}, &SupportedTags[46]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5474
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5475
    { cmsSigUcrBgTag,               { 1, 1, { cmsSigUcrBgType}, NULL},    &SupportedTags[47]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5476
    { cmsSigCrdInfoTag,             { 1, 1, { cmsSigCrdInfoType}, NULL},  &SupportedTags[48]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5477
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5478
    { cmsSigDToB0Tag,               { 1, 1, { cmsSigMultiProcessElementType}, NULL}, &SupportedTags[49]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5479
    { cmsSigDToB1Tag,               { 1, 1, { cmsSigMultiProcessElementType}, NULL}, &SupportedTags[50]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5480
    { cmsSigDToB2Tag,               { 1, 1, { cmsSigMultiProcessElementType}, NULL}, &SupportedTags[51]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5481
    { cmsSigDToB3Tag,               { 1, 1, { cmsSigMultiProcessElementType}, NULL}, &SupportedTags[52]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5482
    { cmsSigBToD0Tag,               { 1, 1, { cmsSigMultiProcessElementType}, NULL}, &SupportedTags[53]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5483
    { cmsSigBToD1Tag,               { 1, 1, { cmsSigMultiProcessElementType}, NULL}, &SupportedTags[54]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5484
    { cmsSigBToD2Tag,               { 1, 1, { cmsSigMultiProcessElementType}, NULL}, &SupportedTags[55]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5485
    { cmsSigBToD3Tag,               { 1, 1, { cmsSigMultiProcessElementType}, NULL}, &SupportedTags[56]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5486
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5487
    { cmsSigScreeningDescTag,       { 1, 1, { cmsSigTextDescriptionType },    NULL}, &SupportedTags[57]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5488
    { cmsSigViewingConditionsTag,   { 1, 1, { cmsSigViewingConditionsType },  NULL}, &SupportedTags[58]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5489
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5490
    { cmsSigScreeningTag,           { 1, 1, { cmsSigScreeningType},          NULL }, &SupportedTags[59]},
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5491
    { cmsSigVcgtTag,                { 1, 1, { cmsSigVcgtType},               NULL }, &SupportedTags[60]},
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  5492
    { cmsSigMetaTag,                { 1, 1, { cmsSigDictType},               NULL }, &SupportedTags[61]},
40152
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  5493
    { cmsSigProfileSequenceIdTag,   { 1, 1, { cmsSigProfileSequenceIdType},  NULL }, &SupportedTags[62]},
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  5494
    { cmsSigProfileDescriptionMLTag,{ 1, 1, { cmsSigMultiLocalizedUnicodeType}, NULL}, &SupportedTags[63]},
35cbab101a76 8162488: JDK should be updated to use LittleCMS 2.8
prr
parents: 30491
diff changeset
  5495
    { cmsSigArgyllArtsTag,          { 9, 1, { cmsSigS15Fixed16ArrayType},    NULL}, NULL}
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  5496
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5497
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5498
};
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5499
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5500
/*
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5501
    Not supported                 Why
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5502
    =======================       =========================================
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5503
    cmsSigOutputResponseTag   ==> WARNING, POSSIBLE PATENT ON THIS SUBJECT!
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5504
    cmsSigNamedColorTag       ==> Deprecated
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5505
    cmsSigDataTag             ==> Ancient, unused
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5506
    cmsSigDeviceSettingsTag   ==> Deprecated, useless
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5507
*/
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5508
26609
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5509
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5510
_cmsTagPluginChunkType _cmsTagPluginChunk = { NULL };
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5511
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5512
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5513
// Duplicates the zone of memory used by the plug-in in the new context
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5514
static
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5515
void DupTagList(struct _cmsContext_struct* ctx,
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5516
                    const struct _cmsContext_struct* src)
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5517
{
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5518
   _cmsTagPluginChunkType newHead = { NULL };
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5519
   _cmsTagLinkedList*  entry;
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5520
   _cmsTagLinkedList*  Anterior = NULL;
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5521
   _cmsTagPluginChunkType* head = (_cmsTagPluginChunkType*) src->chunks[TagPlugin];
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5522
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5523
   // Walk the list copying all nodes
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5524
   for (entry = head->Tag;
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5525
       entry != NULL;
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5526
       entry = entry ->Next) {
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5527
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5528
           _cmsTagLinkedList *newEntry = ( _cmsTagLinkedList *) _cmsSubAllocDup(ctx ->MemPool, entry, sizeof(_cmsTagLinkedList));
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5529
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5530
           if (newEntry == NULL)
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5531
               return;
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5532
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5533
           // We want to keep the linked list order, so this is a little bit tricky
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5534
           newEntry -> Next = NULL;
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5535
           if (Anterior)
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5536
               Anterior -> Next = newEntry;
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5537
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5538
           Anterior = newEntry;
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5539
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5540
           if (newHead.Tag == NULL)
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5541
               newHead.Tag = newEntry;
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5542
   }
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5543
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5544
   ctx ->chunks[TagPlugin] = _cmsSubAllocDup(ctx->MemPool, &newHead, sizeof(_cmsTagPluginChunkType));
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5545
}
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5546
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5547
void _cmsAllocTagPluginChunk(struct _cmsContext_struct* ctx,
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5548
                                 const struct _cmsContext_struct* src)
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5549
{
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5550
    if (src != NULL) {
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5551
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5552
        DupTagList(ctx, src);
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5553
    }
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5554
    else {
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5555
        static _cmsTagPluginChunkType TagPluginChunk = { NULL };
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5556
        ctx ->chunks[TagPlugin] = _cmsSubAllocDup(ctx ->MemPool, &TagPluginChunk, sizeof(_cmsTagPluginChunkType));
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5557
    }
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5558
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5559
}
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5560
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  5561
cmsBool  _cmsRegisterTagPlugin(cmsContext id, cmsPluginBase* Data)
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5562
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5563
    cmsPluginTag* Plugin = (cmsPluginTag*) Data;
26609
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5564
    _cmsTagLinkedList *pt;
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5565
    _cmsTagPluginChunkType* TagPluginChunk = ( _cmsTagPluginChunkType*) _cmsContextGetClientChunk(id, TagPlugin);
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5566
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5567
    if (Data == NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5568
26609
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5569
        TagPluginChunk->Tag = NULL;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5570
        return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5571
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5572
23906
8f7f9cb6fe11 8029750: Enhance LCMS color processing
prr
parents: 14300
diff changeset
  5573
    pt = (_cmsTagLinkedList*) _cmsPluginMalloc(id, sizeof(_cmsTagLinkedList));
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5574
    if (pt == NULL) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5575
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5576
    pt ->Signature  = Plugin ->Signature;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5577
    pt ->Descriptor = Plugin ->Descriptor;
26609
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5578
    pt ->Next       = TagPluginChunk ->Tag;
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5579
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5580
    TagPluginChunk ->Tag = pt;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5581
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5582
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5583
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5584
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5585
// Return a descriptor for a given tag or NULL
26609
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5586
cmsTagDescriptor* _cmsGetTagDescriptor(cmsContext ContextID, cmsTagSignature sig)
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5587
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5588
    _cmsTagLinkedList* pt;
26609
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5589
    _cmsTagPluginChunkType* TagPluginChunk = ( _cmsTagPluginChunkType*) _cmsContextGetClientChunk(ContextID, TagPlugin);
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5590
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5591
    for (pt = TagPluginChunk->Tag;
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5592
             pt != NULL;
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5593
             pt = pt ->Next) {
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5594
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5595
                if (sig == pt -> Signature) return &pt ->Descriptor;
de18f570018c 8056122: Upgrade JDK to use LittleCMS 2.6
prr
parents: 25859
diff changeset
  5596
    }
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5597
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5598
    for (pt = SupportedTags;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5599
            pt != NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5600
            pt = pt ->Next) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5601
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5602
                if (sig == pt -> Signature) return &pt ->Descriptor;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5603
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5604
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5605
    return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5606
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
diff changeset
  5607