OLD | NEW |
1 //------------------------------------------------------------------------------
--- | 1 //------------------------------------------------------------------------------
--- |
2 // | 2 // |
3 // Little Color Management System | 3 // Little Color Management System |
4 // Copyright (c) 1998-2014 Marti Maria Saguer | 4 // Copyright (c) 1998-2014 Marti Maria Saguer |
5 // | 5 // |
6 // Permission is hereby granted, free of charge, to any person obtaining | 6 // Permission is hereby granted, free of charge, to any person obtaining |
7 // a copy of this software and associated documentation files (the "Software"), | 7 // a copy of this software and associated documentation files (the "Software"), |
8 // to deal in the Software without restriction, including without limitation | 8 // to deal in the Software without restriction, including without limitation |
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense, | 9 // the rights to use, copy, modify, merge, publish, distribute, sublicense, |
10 // and/or sell copies of the Software, and to permit persons to whom the Softwar
e | 10 // and/or sell copies of the Software, and to permit persons to whom the Softwar
e |
(...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1105 } | 1105 } |
1106 | 1106 |
1107 default: // Curve | 1107 default: // Curve |
1108 | 1108 |
1109 if (Count > 0x7FFF) | 1109 if (Count > 0x7FFF) |
1110 return NULL; // This is to prevent bad guys for doing bad thi
ngs | 1110 return NULL; // This is to prevent bad guys for doing bad thi
ngs |
1111 | 1111 |
1112 NewGamma = cmsBuildTabulatedToneCurve16(self ->ContextID, Count,
NULL); | 1112 NewGamma = cmsBuildTabulatedToneCurve16(self ->ContextID, Count,
NULL); |
1113 if (!NewGamma) return NULL; | 1113 if (!NewGamma) return NULL; |
1114 | 1114 |
1115 if (!_cmsReadUInt16Array(io, Count, NewGamma -> Table16)) return
NULL; | 1115 if (!_cmsReadUInt16Array(io, Count, NewGamma -> Table16)) { |
| 1116 cmsFreeToneCurve(NewGamma); |
| 1117 return NULL; |
| 1118 } |
1116 | 1119 |
1117 *nItems = 1; | 1120 *nItems = 1; |
1118 return NewGamma; | 1121 return NewGamma; |
1119 } | 1122 } |
1120 | 1123 |
1121 cmsUNUSED_PARAMETER(SizeOfTag); | 1124 cmsUNUSED_PARAMETER(SizeOfTag); |
1122 } | 1125 } |
1123 | 1126 |
1124 | 1127 |
1125 static | 1128 static |
(...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2343 | 2346 |
2344 Data = (_cmsStageCLutData*) CLUT ->Data; | 2347 Data = (_cmsStageCLutData*) CLUT ->Data; |
2345 | 2348 |
2346 // Precision can be 1 or 2 bytes | 2349 // Precision can be 1 or 2 bytes |
2347 if (Precision == 1) { | 2350 if (Precision == 1) { |
2348 | 2351 |
2349 cmsUInt8Number v; | 2352 cmsUInt8Number v; |
2350 | 2353 |
2351 for (i=0; i < Data ->nEntries; i++) { | 2354 for (i=0; i < Data ->nEntries; i++) { |
2352 | 2355 |
2353 if (io ->Read(io, &v, sizeof(cmsUInt8Number), 1) != 1) return NULL; | 2356 if (io ->Read(io, &v, sizeof(cmsUInt8Number), 1) != 1) { |
| 2357 cmsStageFree(CLUT); |
| 2358 return NULL; |
| 2359 } |
2354 Data ->Tab.T[i] = FROM_8_TO_16(v); | 2360 Data ->Tab.T[i] = FROM_8_TO_16(v); |
2355 } | 2361 } |
2356 | 2362 |
2357 } | 2363 } |
2358 else | 2364 else |
2359 if (Precision == 2) { | 2365 if (Precision == 2) { |
2360 | 2366 |
2361 if (!_cmsReadUInt16Array(io, Data->nEntries, Data ->Tab.T)) { | 2367 if (!_cmsReadUInt16Array(io, Data->nEntries, Data ->Tab.T)) { |
2362 cmsStageFree(CLUT); | 2368 cmsStageFree(CLUT); |
2363 return NULL; | 2369 return NULL; |
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3089 prefix[31] = suffix[31] = 0; | 3095 prefix[31] = suffix[31] = 0; |
3090 | 3096 |
3091 v = cmsAllocNamedColorList(self ->ContextID, count, nDeviceCoords, prefix, s
uffix); | 3097 v = cmsAllocNamedColorList(self ->ContextID, count, nDeviceCoords, prefix, s
uffix); |
3092 if (v == NULL) { | 3098 if (v == NULL) { |
3093 cmsSignalError(self->ContextID, cmsERROR_RANGE, "Too many named colors '
%d'", count); | 3099 cmsSignalError(self->ContextID, cmsERROR_RANGE, "Too many named colors '
%d'", count); |
3094 return NULL; | 3100 return NULL; |
3095 } | 3101 } |
3096 | 3102 |
3097 if (nDeviceCoords > cmsMAXCHANNELS) { | 3103 if (nDeviceCoords > cmsMAXCHANNELS) { |
3098 cmsSignalError(self->ContextID, cmsERROR_RANGE, "Too many device coordin
ates '%d'", nDeviceCoords); | 3104 cmsSignalError(self->ContextID, cmsERROR_RANGE, "Too many device coordin
ates '%d'", nDeviceCoords); |
3099 return 0; | 3105 goto Error; |
3100 } | 3106 } |
3101 for (i=0; i < count; i++) { | 3107 for (i=0; i < count; i++) { |
3102 | 3108 |
3103 cmsUInt16Number PCS[3]; | 3109 cmsUInt16Number PCS[3]; |
3104 cmsUInt16Number Colorant[cmsMAXCHANNELS]; | 3110 cmsUInt16Number Colorant[cmsMAXCHANNELS]; |
3105 char Root[33]; | 3111 char Root[33]; |
3106 | 3112 |
3107 memset(Colorant, 0, sizeof(Colorant)); | 3113 memset(Colorant, 0, sizeof(Colorant)); |
3108 if (io -> Read(io, Root, 32, 1) != 1) return NULL; | 3114 if (io -> Read(io, Root, 32, 1) != 1) goto Error; |
3109 Root[32] = 0; | 3115 Root[32] = 0; |
3110 if (!_cmsReadUInt16Array(io, 3, PCS)) goto Error; | 3116 if (!_cmsReadUInt16Array(io, 3, PCS)) goto Error; |
3111 if (!_cmsReadUInt16Array(io, nDeviceCoords, Colorant)) goto Error; | 3117 if (!_cmsReadUInt16Array(io, nDeviceCoords, Colorant)) goto Error; |
3112 | 3118 |
3113 if (!cmsAppendNamedColor(v, Root, PCS, Colorant)) goto Error; | 3119 if (!cmsAppendNamedColor(v, Root, PCS, Colorant)) goto Error; |
3114 } | 3120 } |
3115 | 3121 |
3116 *nItems = 1; | 3122 *nItems = 1; |
3117 return (void*) v ; | 3123 return (void*) v ; |
3118 | 3124 |
(...skipping 2437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5556 | 5562 |
5557 for (pt = SupportedTags; | 5563 for (pt = SupportedTags; |
5558 pt != NULL; | 5564 pt != NULL; |
5559 pt = pt ->Next) { | 5565 pt = pt ->Next) { |
5560 | 5566 |
5561 if (sig == pt -> Signature) return &pt ->Descriptor; | 5567 if (sig == pt -> Signature) return &pt ->Descriptor; |
5562 } | 5568 } |
5563 | 5569 |
5564 return NULL; | 5570 return NULL; |
5565 } | 5571 } |
OLD | NEW |