author | ihse |
Wed, 09 Sep 2015 09:36:39 +0200 | |
changeset 32460 | 9e9bffb3029a |
parent 30491 | ea1c291ee28f |
child 40152 | 35cbab101a76 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
3 |
* |
|
4 |
* This code is free software; you can redistribute it and/or modify it |
|
5 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 6 |
* published by the Free Software Foundation. Oracle designates this |
2 | 7 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 8 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 9 |
* |
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
14 |
* accompanied this code). |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License version |
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
19 |
* |
|
5506 | 20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
21 |
* or visit www.oracle.com if you need additional information or have any |
|
22 |
* questions. |
|
2 | 23 |
*/ |
24 |
||
25 |
// This file is available under and governed by the GNU General Public |
|
26 |
// License version 2 only, as published by the Free Software Foundation. |
|
27 |
// However, the following notice accompanied the original version of this |
|
28 |
// file: |
|
29 |
// |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
30 |
//--------------------------------------------------------------------------------- |
2 | 31 |
// |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
32 |
// Little Color Management System |
14300 | 33 |
// Copyright (c) 1998-2012 Marti Maria Saguer |
2 | 34 |
// |
35 |
// Permission is hereby granted, free of charge, to any person obtaining |
|
36 |
// a copy of this software and associated documentation files (the "Software"), |
|
37 |
// to deal in the Software without restriction, including without limitation |
|
38 |
// the rights to use, copy, modify, merge, publish, distribute, sublicense, |
|
39 |
// and/or sell copies of the Software, and to permit persons to whom the Software |
|
40 |
// is furnished to do so, subject to the following conditions: |
|
41 |
// |
|
42 |
// The above copyright notice and this permission notice shall be included in |
|
43 |
// all copies or substantial portions of the Software. |
|
44 |
// |
|
45 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|
46 |
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO |
|
47 |
// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
48 |
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
|
49 |
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
|
50 |
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
|
51 |
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
52 |
// |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
53 |
//--------------------------------------------------------------------------------- |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
54 |
// |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
55 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
56 |
#include "lcms2_internal.h" |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
57 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
58 |
// Multilocalized unicode objects. That is an attempt to encapsulate i18n. |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
59 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
60 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
61 |
// Allocates an empty multi localizad unicode object |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
62 |
cmsMLU* CMSEXPORT cmsMLUalloc(cmsContext ContextID, cmsUInt32Number nItems) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
63 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
64 |
cmsMLU* mlu; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
65 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
66 |
// nItems should be positive if given |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
67 |
if (nItems <= 0) nItems = 2; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
68 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
69 |
// Create the container |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
70 |
mlu = (cmsMLU*) _cmsMallocZero(ContextID, sizeof(cmsMLU)); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
71 |
if (mlu == NULL) return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
72 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
73 |
mlu ->ContextID = ContextID; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
74 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
75 |
// Create entry array |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
76 |
mlu ->Entries = (_cmsMLUentry*) _cmsCalloc(ContextID, nItems, sizeof(_cmsMLUentry)); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
77 |
if (mlu ->Entries == NULL) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
78 |
_cmsFree(ContextID, mlu); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
79 |
return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
80 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
81 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
82 |
// Ok, keep indexes up to date |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
83 |
mlu ->AllocatedEntries = nItems; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
84 |
mlu ->UsedEntries = 0; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
85 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
86 |
return mlu; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
87 |
} |
2 | 88 |
|
89 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
90 |
// Grows a mempool table for a MLU. Each time this function is called, mempool size is multiplied times two. |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
91 |
static |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
92 |
cmsBool GrowMLUpool(cmsMLU* mlu) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
93 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
94 |
cmsUInt32Number size; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
95 |
void *NewPtr; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
96 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
97 |
// Sanity check |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
98 |
if (mlu == NULL) return FALSE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
99 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
100 |
if (mlu ->PoolSize == 0) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
101 |
size = 256; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
102 |
else |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
103 |
size = mlu ->PoolSize * 2; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
104 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
105 |
// Check for overflow |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
106 |
if (size < mlu ->PoolSize) return FALSE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
107 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
108 |
// Reallocate the pool |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
109 |
NewPtr = _cmsRealloc(mlu ->ContextID, mlu ->MemPool, size); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
110 |
if (NewPtr == NULL) return FALSE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
111 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
112 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
113 |
mlu ->MemPool = NewPtr; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
114 |
mlu ->PoolSize = size; |
2 | 115 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
116 |
return TRUE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
117 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
118 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
119 |
|
14300 | 120 |
// Grows a entry table for a MLU. Each time this function is called, table size is multiplied times two. |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
121 |
static |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
122 |
cmsBool GrowMLUtable(cmsMLU* mlu) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
123 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
124 |
int AllocatedEntries; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
125 |
_cmsMLUentry *NewPtr; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
126 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
127 |
// Sanity check |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
128 |
if (mlu == NULL) return FALSE; |
2 | 129 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
130 |
AllocatedEntries = mlu ->AllocatedEntries * 2; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
131 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
132 |
// Check for overflow |
14300 | 133 |
if (AllocatedEntries / 2 != mlu ->AllocatedEntries) return FALSE; |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
134 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
135 |
// Reallocate the memory |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
136 |
NewPtr = (_cmsMLUentry*)_cmsRealloc(mlu ->ContextID, mlu ->Entries, AllocatedEntries*sizeof(_cmsMLUentry)); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
137 |
if (NewPtr == NULL) return FALSE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
138 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
139 |
mlu ->Entries = NewPtr; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
140 |
mlu ->AllocatedEntries = AllocatedEntries; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
141 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
142 |
return TRUE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
143 |
} |
2 | 144 |
|
145 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
146 |
// Search for a specific entry in the structure. Language and Country are used. |
2 | 147 |
static |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
148 |
int SearchMLUEntry(cmsMLU* mlu, cmsUInt16Number LanguageCode, cmsUInt16Number CountryCode) |
2 | 149 |
{ |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
150 |
int i; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
151 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
152 |
// Sanity check |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
153 |
if (mlu == NULL) return -1; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
154 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
155 |
// Iterate whole table |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
156 |
for (i=0; i < mlu ->UsedEntries; i++) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
157 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
158 |
if (mlu ->Entries[i].Country == CountryCode && |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
159 |
mlu ->Entries[i].Language == LanguageCode) return i; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
160 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
161 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
162 |
// Not found |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
163 |
return -1; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
164 |
} |
2 | 165 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
166 |
// Add a block of characters to the intended MLU. Language and country are specified. |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
167 |
// Only one entry for Language/country pair is allowed. |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
168 |
static |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
169 |
cmsBool AddMLUBlock(cmsMLU* mlu, cmsUInt32Number size, const wchar_t *Block, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
170 |
cmsUInt16Number LanguageCode, cmsUInt16Number CountryCode) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
171 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
172 |
cmsUInt32Number Offset; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
173 |
cmsUInt8Number* Ptr; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
174 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
175 |
// Sanity check |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
176 |
if (mlu == NULL) return FALSE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
177 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
178 |
// Is there any room available? |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
179 |
if (mlu ->UsedEntries >= mlu ->AllocatedEntries) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
180 |
if (!GrowMLUtable(mlu)) return FALSE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
181 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
182 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
183 |
// Only one ASCII string |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
184 |
if (SearchMLUEntry(mlu, LanguageCode, CountryCode) >= 0) return FALSE; // Only one is allowed! |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
185 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
186 |
// Check for size |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
187 |
while ((mlu ->PoolSize - mlu ->PoolUsed) < size) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
188 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
189 |
if (!GrowMLUpool(mlu)) return FALSE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
190 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
191 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
192 |
Offset = mlu ->PoolUsed; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
193 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
194 |
Ptr = (cmsUInt8Number*) mlu ->MemPool; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
195 |
if (Ptr == NULL) return FALSE; |
2 | 196 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
197 |
// Set the entry |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
198 |
memmove(Ptr + Offset, Block, size); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
199 |
mlu ->PoolUsed += size; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
200 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
201 |
mlu ->Entries[mlu ->UsedEntries].StrW = Offset; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
202 |
mlu ->Entries[mlu ->UsedEntries].Len = size; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
203 |
mlu ->Entries[mlu ->UsedEntries].Country = CountryCode; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
204 |
mlu ->Entries[mlu ->UsedEntries].Language = LanguageCode; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
205 |
mlu ->UsedEntries++; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
206 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
207 |
return TRUE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
208 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
209 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
210 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
211 |
// Add an ASCII entry. |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
212 |
cmsBool CMSEXPORT cmsMLUsetASCII(cmsMLU* mlu, const char LanguageCode[3], const char CountryCode[3], const char* ASCIIString) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
213 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
214 |
cmsUInt32Number i, len = (cmsUInt32Number) strlen(ASCIIString)+1; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
215 |
wchar_t* WStr; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
216 |
cmsBool rc; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
217 |
cmsUInt16Number Lang = _cmsAdjustEndianess16(*(cmsUInt16Number*) LanguageCode); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
218 |
cmsUInt16Number Cntry = _cmsAdjustEndianess16(*(cmsUInt16Number*) CountryCode); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
219 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
220 |
if (mlu == NULL) return FALSE; |
2 | 221 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
222 |
WStr = (wchar_t*) _cmsCalloc(mlu ->ContextID, len, sizeof(wchar_t)); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
223 |
if (WStr == NULL) return FALSE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
224 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
225 |
for (i=0; i < len; i++) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
226 |
WStr[i] = (wchar_t) ASCIIString[i]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
227 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
228 |
rc = AddMLUBlock(mlu, len * sizeof(wchar_t), WStr, Lang, Cntry); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
229 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
230 |
_cmsFree(mlu ->ContextID, WStr); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
231 |
return rc; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
232 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
233 |
} |
2 | 234 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
235 |
// We don't need any wcs support library |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
236 |
static |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
237 |
cmsUInt32Number mywcslen(const wchar_t *s) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
238 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
239 |
const wchar_t *p; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
240 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
241 |
p = s; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
242 |
while (*p) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
243 |
p++; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
244 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
245 |
return (cmsUInt32Number)(p - s); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
246 |
} |
2 | 247 |
|
248 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
249 |
// Add a wide entry |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
250 |
cmsBool CMSEXPORT cmsMLUsetWide(cmsMLU* mlu, const char Language[3], const char Country[3], const wchar_t* WideString) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
251 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
252 |
cmsUInt16Number Lang = _cmsAdjustEndianess16(*(cmsUInt16Number*) Language); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
253 |
cmsUInt16Number Cntry = _cmsAdjustEndianess16(*(cmsUInt16Number*) Country); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
254 |
cmsUInt32Number len; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
255 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
256 |
if (mlu == NULL) return FALSE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
257 |
if (WideString == NULL) return FALSE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
258 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
259 |
len = (cmsUInt32Number) (mywcslen(WideString) + 1) * sizeof(wchar_t); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
260 |
return AddMLUBlock(mlu, len, WideString, Lang, Cntry); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
261 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
262 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
263 |
// Duplicating a MLU is as easy as copying all members |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
264 |
cmsMLU* CMSEXPORT cmsMLUdup(const cmsMLU* mlu) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
265 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
266 |
cmsMLU* NewMlu = NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
267 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
268 |
// Duplicating a NULL obtains a NULL |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
269 |
if (mlu == NULL) return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
270 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
271 |
NewMlu = cmsMLUalloc(mlu ->ContextID, mlu ->UsedEntries); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
272 |
if (NewMlu == NULL) return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
273 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
274 |
// Should never happen |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
275 |
if (NewMlu ->AllocatedEntries < mlu ->UsedEntries) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
276 |
goto Error; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
277 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
278 |
// Sanitize... |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
279 |
if (NewMlu ->Entries == NULL || mlu ->Entries == NULL) goto Error; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
280 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
281 |
memmove(NewMlu ->Entries, mlu ->Entries, mlu ->UsedEntries * sizeof(_cmsMLUentry)); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
282 |
NewMlu ->UsedEntries = mlu ->UsedEntries; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
283 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
284 |
// The MLU may be empty |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
285 |
if (mlu ->PoolUsed == 0) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
286 |
NewMlu ->MemPool = NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
287 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
288 |
else { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
289 |
// It is not empty |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
290 |
NewMlu ->MemPool = _cmsMalloc(mlu ->ContextID, mlu ->PoolUsed); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
291 |
if (NewMlu ->MemPool == NULL) goto Error; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
292 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
293 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
294 |
NewMlu ->PoolSize = mlu ->PoolUsed; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
295 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
296 |
if (NewMlu ->MemPool == NULL || mlu ->MemPool == NULL) goto Error; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
297 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
298 |
memmove(NewMlu ->MemPool, mlu->MemPool, mlu ->PoolUsed); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
299 |
NewMlu ->PoolUsed = mlu ->PoolUsed; |
2 | 300 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
301 |
return NewMlu; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
302 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
303 |
Error: |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
304 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
305 |
if (NewMlu != NULL) cmsMLUfree(NewMlu); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
306 |
return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
307 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
308 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
309 |
// Free any used memory |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
310 |
void CMSEXPORT cmsMLUfree(cmsMLU* mlu) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
311 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
312 |
if (mlu) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
313 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
314 |
if (mlu -> Entries) _cmsFree(mlu ->ContextID, mlu->Entries); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
315 |
if (mlu -> MemPool) _cmsFree(mlu ->ContextID, mlu->MemPool); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
316 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
317 |
_cmsFree(mlu ->ContextID, mlu); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
318 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
319 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
320 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
321 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
322 |
// The algorithm first searches for an exact match of country and language, if not found it uses |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
323 |
// the Language. If none is found, first entry is used instead. |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
324 |
static |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
325 |
const wchar_t* _cmsMLUgetWide(const cmsMLU* mlu, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
326 |
cmsUInt32Number *len, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
327 |
cmsUInt16Number LanguageCode, cmsUInt16Number CountryCode, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
328 |
cmsUInt16Number* UsedLanguageCode, cmsUInt16Number* UsedCountryCode) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
329 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
330 |
int i; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
331 |
int Best = -1; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
332 |
_cmsMLUentry* v; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
333 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
334 |
if (mlu == NULL) return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
335 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
336 |
if (mlu -> AllocatedEntries <= 0) return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
337 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
338 |
for (i=0; i < mlu ->UsedEntries; i++) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
339 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
340 |
v = mlu ->Entries + i; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
341 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
342 |
if (v -> Language == LanguageCode) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
343 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
344 |
if (Best == -1) Best = i; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
345 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
346 |
if (v -> Country == CountryCode) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
347 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
348 |
if (UsedLanguageCode != NULL) *UsedLanguageCode = v ->Language; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
349 |
if (UsedCountryCode != NULL) *UsedCountryCode = v ->Country; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
350 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
351 |
if (len != NULL) *len = v ->Len; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
352 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
353 |
return (wchar_t*) ((cmsUInt8Number*) mlu ->MemPool + v -> StrW); // Found exact match |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
354 |
} |
2 | 355 |
} |
356 |
} |
|
357 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
358 |
// No string found. Return First one |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
359 |
if (Best == -1) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
360 |
Best = 0; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
361 |
|
23906 | 362 |
v = mlu ->Entries + Best; |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
363 |
|
23906 | 364 |
if (UsedLanguageCode != NULL) *UsedLanguageCode = v ->Language; |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
365 |
if (UsedCountryCode != NULL) *UsedCountryCode = v ->Country; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
366 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
367 |
if (len != NULL) *len = v ->Len; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
368 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
369 |
return(wchar_t*) ((cmsUInt8Number*) mlu ->MemPool + v ->StrW); |
2 | 370 |
} |
371 |
||
372 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
373 |
// Obtain an ASCII representation of the wide string. Setting buffer to NULL returns the len |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
374 |
cmsUInt32Number CMSEXPORT cmsMLUgetASCII(const cmsMLU* mlu, |
14300 | 375 |
const char LanguageCode[3], const char CountryCode[3], |
376 |
char* Buffer, cmsUInt32Number BufferSize) |
|
2 | 377 |
{ |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
378 |
const wchar_t *Wide; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
379 |
cmsUInt32Number StrLen = 0; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
380 |
cmsUInt32Number ASCIIlen, i; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
381 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
382 |
cmsUInt16Number Lang = _cmsAdjustEndianess16(*(cmsUInt16Number*) LanguageCode); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
383 |
cmsUInt16Number Cntry = _cmsAdjustEndianess16(*(cmsUInt16Number*) CountryCode); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
384 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
385 |
// Sanitize |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
386 |
if (mlu == NULL) return 0; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
387 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
388 |
// Get WideChar |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
389 |
Wide = _cmsMLUgetWide(mlu, &StrLen, Lang, Cntry, NULL, NULL); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
390 |
if (Wide == NULL) return 0; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
391 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
392 |
ASCIIlen = StrLen / sizeof(wchar_t); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
393 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
394 |
// Maybe we want only to know the len? |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
395 |
if (Buffer == NULL) return ASCIIlen + 1; // Note the zero at the end |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
396 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
397 |
// No buffer size means no data |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
398 |
if (BufferSize <= 0) return 0; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
399 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
400 |
// Some clipping may be required |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
401 |
if (BufferSize < ASCIIlen + 1) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
402 |
ASCIIlen = BufferSize - 1; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
403 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
404 |
// Precess each character |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
405 |
for (i=0; i < ASCIIlen; i++) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
406 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
407 |
if (Wide[i] == 0) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
408 |
Buffer[i] = 0; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
409 |
else |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
410 |
Buffer[i] = (char) Wide[i]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
411 |
} |
2 | 412 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
413 |
// We put a termination "\0" |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
414 |
Buffer[ASCIIlen] = 0; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
415 |
return ASCIIlen + 1; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
416 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
417 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
418 |
// Obtain a wide representation of the MLU, on depending on current locale settings |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
419 |
cmsUInt32Number CMSEXPORT cmsMLUgetWide(const cmsMLU* mlu, |
14300 | 420 |
const char LanguageCode[3], const char CountryCode[3], |
421 |
wchar_t* Buffer, cmsUInt32Number BufferSize) |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
422 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
423 |
const wchar_t *Wide; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
424 |
cmsUInt32Number StrLen = 0; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
425 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
426 |
cmsUInt16Number Lang = _cmsAdjustEndianess16(*(cmsUInt16Number*) LanguageCode); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
427 |
cmsUInt16Number Cntry = _cmsAdjustEndianess16(*(cmsUInt16Number*) CountryCode); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
428 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
429 |
// Sanitize |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
430 |
if (mlu == NULL) return 0; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
431 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
432 |
Wide = _cmsMLUgetWide(mlu, &StrLen, Lang, Cntry, NULL, NULL); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
433 |
if (Wide == NULL) return 0; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
434 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
435 |
// Maybe we want only to know the len? |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
436 |
if (Buffer == NULL) return StrLen + sizeof(wchar_t); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
437 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
438 |
// No buffer size means no data |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
439 |
if (BufferSize <= 0) return 0; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
440 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
441 |
// Some clipping may be required |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
442 |
if (BufferSize < StrLen + sizeof(wchar_t)) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
443 |
StrLen = BufferSize - + sizeof(wchar_t); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
444 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
445 |
memmove(Buffer, Wide, StrLen); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
446 |
Buffer[StrLen / sizeof(wchar_t)] = 0; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
447 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
448 |
return StrLen + sizeof(wchar_t); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
449 |
} |
2 | 450 |
|
451 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
452 |
// Get also the language and country |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
453 |
CMSAPI cmsBool CMSEXPORT cmsMLUgetTranslation(const cmsMLU* mlu, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
454 |
const char LanguageCode[3], const char CountryCode[3], |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
455 |
char ObtainedLanguage[3], char ObtainedCountry[3]) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
456 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
457 |
const wchar_t *Wide; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
458 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
459 |
cmsUInt16Number Lang = _cmsAdjustEndianess16(*(cmsUInt16Number*) LanguageCode); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
460 |
cmsUInt16Number Cntry = _cmsAdjustEndianess16(*(cmsUInt16Number*) CountryCode); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
461 |
cmsUInt16Number ObtLang, ObtCode; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
462 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
463 |
// Sanitize |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
464 |
if (mlu == NULL) return FALSE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
465 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
466 |
Wide = _cmsMLUgetWide(mlu, NULL, Lang, Cntry, &ObtLang, &ObtCode); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
467 |
if (Wide == NULL) return FALSE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
468 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
469 |
// Get used language and code |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
470 |
*(cmsUInt16Number *)ObtainedLanguage = _cmsAdjustEndianess16(ObtLang); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
471 |
*(cmsUInt16Number *)ObtainedCountry = _cmsAdjustEndianess16(ObtCode); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
472 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
473 |
ObtainedLanguage[2] = ObtainedCountry[2] = 0; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
474 |
return TRUE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
475 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
476 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
477 |
|
23906 | 478 |
|
479 |
// Get the number of translations in the MLU object |
|
480 |
cmsUInt32Number CMSEXPORT cmsMLUtranslationsCount(const cmsMLU* mlu) |
|
481 |
{ |
|
482 |
if (mlu == NULL) return 0; |
|
483 |
return mlu->UsedEntries; |
|
484 |
} |
|
485 |
||
486 |
// Get the language and country codes for a specific MLU index |
|
487 |
cmsBool CMSEXPORT cmsMLUtranslationsCodes(const cmsMLU* mlu, |
|
488 |
cmsUInt32Number idx, |
|
489 |
char LanguageCode[3], |
|
490 |
char CountryCode[3]) |
|
491 |
{ |
|
492 |
_cmsMLUentry *entry; |
|
493 |
||
494 |
if (mlu == NULL) return FALSE; |
|
495 |
||
496 |
if (idx >= (cmsUInt32Number) mlu->UsedEntries) return FALSE; |
|
497 |
||
498 |
entry = &mlu->Entries[idx]; |
|
499 |
||
500 |
*(cmsUInt16Number *)LanguageCode = _cmsAdjustEndianess16(entry->Language); |
|
501 |
*(cmsUInt16Number *)CountryCode = _cmsAdjustEndianess16(entry->Country); |
|
502 |
||
503 |
return TRUE; |
|
504 |
} |
|
505 |
||
506 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
507 |
// Named color lists -------------------------------------------------------------------------------------------- |
2 | 508 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
509 |
// Grow the list to keep at least NumElements |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
510 |
static |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
511 |
cmsBool GrowNamedColorList(cmsNAMEDCOLORLIST* v) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
512 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
513 |
cmsUInt32Number size; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
514 |
_cmsNAMEDCOLOR * NewPtr; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
515 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
516 |
if (v == NULL) return FALSE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
517 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
518 |
if (v ->Allocated == 0) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
519 |
size = 64; // Initial guess |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
520 |
else |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
521 |
size = v ->Allocated * 2; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
522 |
|
14300 | 523 |
// Keep a maximum color lists can grow, 100K entries seems reasonable |
524 |
if (size > 1024*100) return FALSE; |
|
525 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
526 |
NewPtr = (_cmsNAMEDCOLOR*) _cmsRealloc(v ->ContextID, v ->List, size * sizeof(_cmsNAMEDCOLOR)); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
527 |
if (NewPtr == NULL) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
528 |
return FALSE; |
2 | 529 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
530 |
v ->List = NewPtr; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
531 |
v ->Allocated = size; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
532 |
return TRUE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
533 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
534 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
535 |
// Allocate a list for n elements |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
536 |
cmsNAMEDCOLORLIST* CMSEXPORT cmsAllocNamedColorList(cmsContext ContextID, cmsUInt32Number n, cmsUInt32Number ColorantCount, const char* Prefix, const char* Suffix) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
537 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
538 |
cmsNAMEDCOLORLIST* v = (cmsNAMEDCOLORLIST*) _cmsMallocZero(ContextID, sizeof(cmsNAMEDCOLORLIST)); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
539 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
540 |
if (v == NULL) return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
541 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
542 |
v ->List = NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
543 |
v ->nColors = 0; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
544 |
v ->ContextID = ContextID; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
545 |
|
30491 | 546 |
while (v -> Allocated < n){ |
547 |
if (!GrowNamedColorList(v)) return NULL; |
|
548 |
} |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
549 |
|
23906 | 550 |
strncpy(v ->Prefix, Prefix, sizeof(v ->Prefix)-1); |
551 |
strncpy(v ->Suffix, Suffix, sizeof(v ->Suffix)-1); |
|
552 |
v->Prefix[32] = v->Suffix[32] = 0; |
|
14300 | 553 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
554 |
v -> ColorantCount = ColorantCount; |
2 | 555 |
|
556 |
return v; |
|
557 |
} |
|
558 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
559 |
// Free a list |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
560 |
void CMSEXPORT cmsFreeNamedColorList(cmsNAMEDCOLORLIST* v) |
2 | 561 |
{ |
23906 | 562 |
if (v == NULL) return; |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
563 |
if (v ->List) _cmsFree(v ->ContextID, v ->List); |
23906 | 564 |
_cmsFree(v ->ContextID, v); |
2 | 565 |
} |
566 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
567 |
cmsNAMEDCOLORLIST* CMSEXPORT cmsDupNamedColorList(const cmsNAMEDCOLORLIST* v) |
2 | 568 |
{ |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
569 |
cmsNAMEDCOLORLIST* NewNC; |
2 | 570 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
571 |
if (v == NULL) return NULL; |
2 | 572 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
573 |
NewNC= cmsAllocNamedColorList(v ->ContextID, v -> nColors, v ->ColorantCount, v ->Prefix, v ->Suffix); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
574 |
if (NewNC == NULL) return NULL; |
2 | 575 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
576 |
// For really large tables we need this |
30491 | 577 |
while (NewNC ->Allocated < v ->Allocated){ |
578 |
if (!GrowNamedColorList(NewNC)) return NULL; |
|
579 |
} |
|
2 | 580 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
581 |
memmove(NewNC ->Prefix, v ->Prefix, sizeof(v ->Prefix)); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
582 |
memmove(NewNC ->Suffix, v ->Suffix, sizeof(v ->Suffix)); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
583 |
NewNC ->ColorantCount = v ->ColorantCount; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
584 |
memmove(NewNC->List, v ->List, v->nColors * sizeof(_cmsNAMEDCOLOR)); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
585 |
NewNC ->nColors = v ->nColors; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
586 |
return NewNC; |
2 | 587 |
} |
588 |
||
589 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
590 |
// Append a color to a list. List pointer may change if reallocated |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
591 |
cmsBool CMSEXPORT cmsAppendNamedColor(cmsNAMEDCOLORLIST* NamedColorList, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
592 |
const char* Name, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
593 |
cmsUInt16Number PCS[3], cmsUInt16Number Colorant[cmsMAXCHANNELS]) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
594 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
595 |
cmsUInt32Number i; |
2 | 596 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
597 |
if (NamedColorList == NULL) return FALSE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
598 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
599 |
if (NamedColorList ->nColors + 1 > NamedColorList ->Allocated) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
600 |
if (!GrowNamedColorList(NamedColorList)) return FALSE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
601 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
602 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
603 |
for (i=0; i < NamedColorList ->ColorantCount; i++) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
604 |
NamedColorList ->List[NamedColorList ->nColors].DeviceColorant[i] = Colorant == NULL? 0 : Colorant[i]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
605 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
606 |
for (i=0; i < 3; i++) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
607 |
NamedColorList ->List[NamedColorList ->nColors].PCS[i] = PCS == NULL ? 0 : PCS[i]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
608 |
|
14300 | 609 |
if (Name != NULL) { |
610 |
||
23906 | 611 |
strncpy(NamedColorList ->List[NamedColorList ->nColors].Name, Name, cmsMAX_PATH-1); |
612 |
NamedColorList ->List[NamedColorList ->nColors].Name[cmsMAX_PATH-1] = 0; |
|
14300 | 613 |
|
614 |
} |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
615 |
else |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
616 |
NamedColorList ->List[NamedColorList ->nColors].Name[0] = 0; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
617 |
|
2 | 618 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
619 |
NamedColorList ->nColors++; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
620 |
return TRUE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
621 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
622 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
623 |
// Returns number of elements |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
624 |
cmsUInt32Number CMSEXPORT cmsNamedColorCount(const cmsNAMEDCOLORLIST* NamedColorList) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
625 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
626 |
if (NamedColorList == NULL) return 0; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
627 |
return NamedColorList ->nColors; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
628 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
629 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
630 |
// Info aboout a given color |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
631 |
cmsBool CMSEXPORT cmsNamedColorInfo(const cmsNAMEDCOLORLIST* NamedColorList, cmsUInt32Number nColor, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
632 |
char* Name, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
633 |
char* Prefix, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
634 |
char* Suffix, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
635 |
cmsUInt16Number* PCS, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
636 |
cmsUInt16Number* Colorant) |
2 | 637 |
{ |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
638 |
if (NamedColorList == NULL) return FALSE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
639 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
640 |
if (nColor >= cmsNamedColorCount(NamedColorList)) return FALSE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
641 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
642 |
if (Name) strcpy(Name, NamedColorList->List[nColor].Name); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
643 |
if (Prefix) strcpy(Prefix, NamedColorList->Prefix); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
644 |
if (Suffix) strcpy(Suffix, NamedColorList->Suffix); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
645 |
if (PCS) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
646 |
memmove(PCS, NamedColorList ->List[nColor].PCS, 3*sizeof(cmsUInt16Number)); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
647 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
648 |
if (Colorant) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
649 |
memmove(Colorant, NamedColorList ->List[nColor].DeviceColorant, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
650 |
sizeof(cmsUInt16Number) * NamedColorList ->ColorantCount); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
651 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
652 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
653 |
return TRUE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
654 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
655 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
656 |
// Search for a given color name (no prefix or suffix) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
657 |
cmsInt32Number CMSEXPORT cmsNamedColorIndex(const cmsNAMEDCOLORLIST* NamedColorList, const char* Name) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
658 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
659 |
int i, n; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
660 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
661 |
if (NamedColorList == NULL) return -1; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
662 |
n = cmsNamedColorCount(NamedColorList); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
663 |
for (i=0; i < n; i++) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
664 |
if (cmsstrcasecmp(Name, NamedColorList->List[i].Name) == 0) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
665 |
return i; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
666 |
} |
2 | 667 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
668 |
return -1; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
669 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
670 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
671 |
// MPE support ----------------------------------------------------------------------------------------------------------------- |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
672 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
673 |
static |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
674 |
void FreeNamedColorList(cmsStage* mpe) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
675 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
676 |
cmsNAMEDCOLORLIST* List = (cmsNAMEDCOLORLIST*) mpe ->Data; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
677 |
cmsFreeNamedColorList(List); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
678 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
679 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
680 |
static |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
681 |
void* DupNamedColorList(cmsStage* mpe) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
682 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
683 |
cmsNAMEDCOLORLIST* List = (cmsNAMEDCOLORLIST*) mpe ->Data; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
684 |
return cmsDupNamedColorList(List); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
685 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
686 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
687 |
static |
14300 | 688 |
void EvalNamedColorPCS(const cmsFloat32Number In[], cmsFloat32Number Out[], const cmsStage *mpe) |
689 |
{ |
|
690 |
cmsNAMEDCOLORLIST* NamedColorList = (cmsNAMEDCOLORLIST*) mpe ->Data; |
|
691 |
cmsUInt16Number index = (cmsUInt16Number) _cmsQuickSaturateWord(In[0] * 65535.0); |
|
692 |
||
693 |
if (index >= NamedColorList-> nColors) { |
|
694 |
cmsSignalError(NamedColorList ->ContextID, cmsERROR_RANGE, "Color %d out of range; ignored", index); |
|
695 |
} |
|
696 |
else { |
|
697 |
||
698 |
// Named color always uses Lab |
|
699 |
Out[0] = (cmsFloat32Number) (NamedColorList->List[index].PCS[0] / 65535.0); |
|
700 |
Out[1] = (cmsFloat32Number) (NamedColorList->List[index].PCS[1] / 65535.0); |
|
701 |
Out[2] = (cmsFloat32Number) (NamedColorList->List[index].PCS[2] / 65535.0); |
|
702 |
} |
|
703 |
} |
|
704 |
||
705 |
static |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
706 |
void EvalNamedColor(const cmsFloat32Number In[], cmsFloat32Number Out[], const cmsStage *mpe) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
707 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
708 |
cmsNAMEDCOLORLIST* NamedColorList = (cmsNAMEDCOLORLIST*) mpe ->Data; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
709 |
cmsUInt16Number index = (cmsUInt16Number) _cmsQuickSaturateWord(In[0] * 65535.0); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
710 |
cmsUInt32Number j; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
711 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
712 |
if (index >= NamedColorList-> nColors) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
713 |
cmsSignalError(NamedColorList ->ContextID, cmsERROR_RANGE, "Color %d out of range; ignored", index); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
714 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
715 |
else { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
716 |
for (j=0; j < NamedColorList ->ColorantCount; j++) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
717 |
Out[j] = (cmsFloat32Number) (NamedColorList->List[index].DeviceColorant[j] / 65535.0); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
718 |
} |
2 | 719 |
} |
720 |
||
721 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
722 |
// Named color lookup element |
14300 | 723 |
cmsStage* _cmsStageAllocNamedColor(cmsNAMEDCOLORLIST* NamedColorList, cmsBool UsePCS) |
2 | 724 |
{ |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
725 |
return _cmsStageAllocPlaceholder(NamedColorList ->ContextID, |
14300 | 726 |
cmsSigNamedColorElemType, |
727 |
1, UsePCS ? 3 : NamedColorList ->ColorantCount, |
|
728 |
UsePCS ? EvalNamedColorPCS : EvalNamedColor, |
|
729 |
DupNamedColorList, |
|
730 |
FreeNamedColorList, |
|
731 |
cmsDupNamedColorList(NamedColorList)); |
|
2 | 732 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
733 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
734 |
|
2 | 735 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
736 |
// Retrieve the named color list from a transform. Should be first element in the LUT |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
737 |
cmsNAMEDCOLORLIST* CMSEXPORT cmsGetNamedColorList(cmsHTRANSFORM xform) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
738 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
739 |
_cmsTRANSFORM* v = (_cmsTRANSFORM*) xform; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
740 |
cmsStage* mpe = v ->Lut->Elements; |
2 | 741 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
742 |
if (mpe ->Type != cmsSigNamedColorElemType) return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
743 |
return (cmsNAMEDCOLORLIST*) mpe ->Data; |
2 | 744 |
} |
745 |
||
746 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
747 |
// Profile sequence description routines ------------------------------------------------------------------------------------- |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
748 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
749 |
cmsSEQ* CMSEXPORT cmsAllocProfileSequenceDescription(cmsContext ContextID, cmsUInt32Number n) |
2 | 750 |
{ |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
751 |
cmsSEQ* Seq; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
752 |
cmsUInt32Number i; |
2 | 753 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
754 |
if (n == 0) return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
755 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
756 |
// In a absolutely arbitrary way, I hereby decide to allow a maxim of 255 profiles linked |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
757 |
// in a devicelink. It makes not sense anyway and may be used for exploits, so let's close the door! |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
758 |
if (n > 255) return NULL; |
2 | 759 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
760 |
Seq = (cmsSEQ*) _cmsMallocZero(ContextID, sizeof(cmsSEQ)); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
761 |
if (Seq == NULL) return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
762 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
763 |
Seq -> ContextID = ContextID; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
764 |
Seq -> seq = (cmsPSEQDESC*) _cmsCalloc(ContextID, n, sizeof(cmsPSEQDESC)); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
765 |
Seq -> n = n; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
766 |
|
18194
3219612ef61c
8007927: Improve cmsAllocProfileSequenceDescription
jgodinez
parents:
14300
diff
changeset
|
767 |
if (Seq -> seq == NULL) { |
3219612ef61c
8007927: Improve cmsAllocProfileSequenceDescription
jgodinez
parents:
14300
diff
changeset
|
768 |
_cmsFree(ContextID, Seq); |
3219612ef61c
8007927: Improve cmsAllocProfileSequenceDescription
jgodinez
parents:
14300
diff
changeset
|
769 |
return NULL; |
3219612ef61c
8007927: Improve cmsAllocProfileSequenceDescription
jgodinez
parents:
14300
diff
changeset
|
770 |
} |
2 | 771 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
772 |
for (i=0; i < n; i++) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
773 |
Seq -> seq[i].Manufacturer = NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
774 |
Seq -> seq[i].Model = NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
775 |
Seq -> seq[i].Description = NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
776 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
777 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
778 |
return Seq; |
2 | 779 |
} |
2394 | 780 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
781 |
void CMSEXPORT cmsFreeProfileSequenceDescription(cmsSEQ* pseq) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
782 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
783 |
cmsUInt32Number i; |
2394 | 784 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
785 |
for (i=0; i < pseq ->n; i++) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
786 |
if (pseq ->seq[i].Manufacturer != NULL) cmsMLUfree(pseq ->seq[i].Manufacturer); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
787 |
if (pseq ->seq[i].Model != NULL) cmsMLUfree(pseq ->seq[i].Model); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
788 |
if (pseq ->seq[i].Description != NULL) cmsMLUfree(pseq ->seq[i].Description); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
789 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
790 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
791 |
if (pseq ->seq != NULL) _cmsFree(pseq ->ContextID, pseq ->seq); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
792 |
_cmsFree(pseq -> ContextID, pseq); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
793 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
794 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
795 |
cmsSEQ* CMSEXPORT cmsDupProfileSequenceDescription(const cmsSEQ* pseq) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
796 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
797 |
cmsSEQ *NewSeq; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
798 |
cmsUInt32Number i; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
799 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
800 |
if (pseq == NULL) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
801 |
return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
802 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
803 |
NewSeq = (cmsSEQ*) _cmsMalloc(pseq -> ContextID, sizeof(cmsSEQ)); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
804 |
if (NewSeq == NULL) return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
805 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
806 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
807 |
NewSeq -> seq = (cmsPSEQDESC*) _cmsCalloc(pseq ->ContextID, pseq ->n, sizeof(cmsPSEQDESC)); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
808 |
if (NewSeq ->seq == NULL) goto Error; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
809 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
810 |
NewSeq -> ContextID = pseq ->ContextID; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
811 |
NewSeq -> n = pseq ->n; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
812 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
813 |
for (i=0; i < pseq->n; i++) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
814 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
815 |
memmove(&NewSeq ->seq[i].attributes, &pseq ->seq[i].attributes, sizeof(cmsUInt64Number)); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
816 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
817 |
NewSeq ->seq[i].deviceMfg = pseq ->seq[i].deviceMfg; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
818 |
NewSeq ->seq[i].deviceModel = pseq ->seq[i].deviceModel; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
819 |
memmove(&NewSeq ->seq[i].ProfileID, &pseq ->seq[i].ProfileID, sizeof(cmsProfileID)); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
820 |
NewSeq ->seq[i].technology = pseq ->seq[i].technology; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
821 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
822 |
NewSeq ->seq[i].Manufacturer = cmsMLUdup(pseq ->seq[i].Manufacturer); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
823 |
NewSeq ->seq[i].Model = cmsMLUdup(pseq ->seq[i].Model); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
824 |
NewSeq ->seq[i].Description = cmsMLUdup(pseq ->seq[i].Description); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
825 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
826 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
827 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
828 |
return NewSeq; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
829 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
830 |
Error: |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
831 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
832 |
cmsFreeProfileSequenceDescription(NewSeq); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
833 |
return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
834 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
835 |
|
14300 | 836 |
// Dictionaries -------------------------------------------------------------------------------------------------------- |
837 |
||
838 |
// Dictionaries are just very simple linked lists |
|
839 |
||
840 |
||
841 |
typedef struct _cmsDICT_struct { |
|
842 |
cmsDICTentry* head; |
|
843 |
cmsContext ContextID; |
|
844 |
} _cmsDICT; |
|
845 |
||
846 |
||
847 |
// Allocate an empty dictionary |
|
848 |
cmsHANDLE CMSEXPORT cmsDictAlloc(cmsContext ContextID) |
|
849 |
{ |
|
850 |
_cmsDICT* dict = (_cmsDICT*) _cmsMallocZero(ContextID, sizeof(_cmsDICT)); |
|
851 |
if (dict == NULL) return NULL; |
|
852 |
||
853 |
dict ->ContextID = ContextID; |
|
854 |
return (cmsHANDLE) dict; |
|
855 |
||
856 |
} |
|
857 |
||
858 |
// Dispose resources |
|
859 |
void CMSEXPORT cmsDictFree(cmsHANDLE hDict) |
|
860 |
{ |
|
861 |
_cmsDICT* dict = (_cmsDICT*) hDict; |
|
862 |
cmsDICTentry *entry, *next; |
|
863 |
||
864 |
_cmsAssert(dict != NULL); |
|
865 |
||
866 |
// Walk the list freeing all nodes |
|
867 |
entry = dict ->head; |
|
868 |
while (entry != NULL) { |
|
869 |
||
870 |
if (entry ->DisplayName != NULL) cmsMLUfree(entry ->DisplayName); |
|
871 |
if (entry ->DisplayValue != NULL) cmsMLUfree(entry ->DisplayValue); |
|
872 |
if (entry ->Name != NULL) _cmsFree(dict ->ContextID, entry -> Name); |
|
873 |
if (entry ->Value != NULL) _cmsFree(dict ->ContextID, entry -> Value); |
|
874 |
||
875 |
// Don't fall in the habitual trap... |
|
876 |
next = entry ->Next; |
|
877 |
_cmsFree(dict ->ContextID, entry); |
|
878 |
||
879 |
entry = next; |
|
880 |
} |
|
881 |
||
882 |
_cmsFree(dict ->ContextID, dict); |
|
883 |
} |
|
884 |
||
885 |
||
886 |
// Duplicate a wide char string |
|
887 |
static |
|
888 |
wchar_t* DupWcs(cmsContext ContextID, const wchar_t* ptr) |
|
889 |
{ |
|
890 |
if (ptr == NULL) return NULL; |
|
891 |
return (wchar_t*) _cmsDupMem(ContextID, ptr, (mywcslen(ptr) + 1) * sizeof(wchar_t)); |
|
892 |
} |
|
893 |
||
894 |
// Add a new entry to the linked list |
|
895 |
cmsBool CMSEXPORT cmsDictAddEntry(cmsHANDLE hDict, const wchar_t* Name, const wchar_t* Value, const cmsMLU *DisplayName, const cmsMLU *DisplayValue) |
|
896 |
{ |
|
897 |
_cmsDICT* dict = (_cmsDICT*) hDict; |
|
898 |
cmsDICTentry *entry; |
|
899 |
||
900 |
_cmsAssert(dict != NULL); |
|
901 |
_cmsAssert(Name != NULL); |
|
902 |
||
903 |
entry = (cmsDICTentry*) _cmsMallocZero(dict ->ContextID, sizeof(cmsDICTentry)); |
|
904 |
if (entry == NULL) return FALSE; |
|
905 |
||
906 |
entry ->DisplayName = cmsMLUdup(DisplayName); |
|
907 |
entry ->DisplayValue = cmsMLUdup(DisplayValue); |
|
908 |
entry ->Name = DupWcs(dict ->ContextID, Name); |
|
909 |
entry ->Value = DupWcs(dict ->ContextID, Value); |
|
910 |
||
911 |
entry ->Next = dict ->head; |
|
912 |
dict ->head = entry; |
|
913 |
||
914 |
return TRUE; |
|
915 |
} |
|
916 |
||
917 |
||
918 |
// Duplicates an existing dictionary |
|
919 |
cmsHANDLE CMSEXPORT cmsDictDup(cmsHANDLE hDict) |
|
920 |
{ |
|
921 |
_cmsDICT* old_dict = (_cmsDICT*) hDict; |
|
922 |
cmsHANDLE hNew; |
|
923 |
cmsDICTentry *entry; |
|
924 |
||
925 |
_cmsAssert(old_dict != NULL); |
|
926 |
||
927 |
hNew = cmsDictAlloc(old_dict ->ContextID); |
|
928 |
if (hNew == NULL) return NULL; |
|
929 |
||
930 |
// Walk the list freeing all nodes |
|
931 |
entry = old_dict ->head; |
|
932 |
while (entry != NULL) { |
|
933 |
||
934 |
if (!cmsDictAddEntry(hNew, entry ->Name, entry ->Value, entry ->DisplayName, entry ->DisplayValue)) { |
|
935 |
||
936 |
cmsDictFree(hNew); |
|
937 |
return NULL; |
|
938 |
} |
|
939 |
||
940 |
entry = entry -> Next; |
|
941 |
} |
|
942 |
||
943 |
return hNew; |
|
944 |
} |
|
945 |
||
946 |
// Get a pointer to the linked list |
|
947 |
const cmsDICTentry* CMSEXPORT cmsDictGetEntryList(cmsHANDLE hDict) |
|
948 |
{ |
|
949 |
_cmsDICT* dict = (_cmsDICT*) hDict; |
|
950 |
||
951 |
if (dict == NULL) return NULL; |
|
952 |
return dict ->head; |
|
953 |
} |
|
954 |
||
955 |
// Helper For external languages |
|
956 |
const cmsDICTentry* CMSEXPORT cmsDictNextEntry(const cmsDICTentry* e) |
|
957 |
{ |
|
958 |
if (e == NULL) return NULL; |
|
959 |
return e ->Next; |
|
960 |
} |