@@ -5754,8 +5754,7 @@ cmsBool Type_MHC2_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io,
57545754 cmsUInt32Number TablesOffsetPos ;
57555755 cmsUInt32Number MatrixOffset ;
57565756 cmsUInt32Number OffsetRedTable , OffsetGreenTable , OffsetBlueTable ;
5757-
5758- if (!_cmsWriteUInt32Number (io , 0 )) return FALSE;
5757+
57595758 if (!_cmsWriteUInt32Number (io , mhc2 -> CurveEntries )) return FALSE;
57605759
57615760 if (!_cmsWrite15Fixed16Number (io , mhc2 -> MinLuminance )) return FALSE;
@@ -5780,10 +5779,20 @@ cmsBool Type_MHC2_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io,
57805779 }
57815780
57825781 OffsetRedTable = io -> Tell (io ) - BaseOffset ;
5782+
5783+ if (!_cmsWriteUInt32Number (io , cmsSigS15Fixed16ArrayType )) return FALSE;
5784+ if (!_cmsWriteUInt32Number (io , 0 )) return FALSE;
5785+
57835786 if (!WriteDoubles (io , mhc2 -> CurveEntries , mhc2 -> RedCurve )) return FALSE;
5787+
57845788 OffsetGreenTable = io -> Tell (io ) - BaseOffset ;
5789+ if (!_cmsWriteUInt32Number (io , cmsSigS15Fixed16ArrayType )) return FALSE;
5790+ if (!_cmsWriteUInt32Number (io , 0 )) return FALSE;
57855791 if (!WriteDoubles (io , mhc2 -> CurveEntries , mhc2 -> GreenCurve )) return FALSE;
5792+
57865793 OffsetBlueTable = io -> Tell (io ) - BaseOffset ;
5794+ if (!_cmsWriteUInt32Number (io , cmsSigS15Fixed16ArrayType )) return FALSE;
5795+ if (!_cmsWriteUInt32Number (io , 0 )) return FALSE;
57875796 if (!WriteDoubles (io , mhc2 -> CurveEntries , mhc2 -> BlueCurve )) return FALSE;
57885797
57895798 if (!io -> Seek (io , TablesOffsetPos )) return FALSE;
@@ -5826,9 +5835,7 @@ void* Type_MHC2_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cms
58265835 cmsUInt32Number BaseOffset = io -> Tell (io ) - sizeof (_cmsTagBase );
58275836 cmsUInt32Number MatrixOffset ;
58285837 cmsUInt32Number OffsetRedTable , OffsetGreenTable , OffsetBlueTable ;
5829-
5830- if (!_cmsReadUInt32Number (io , NULL )) return NULL ;
5831-
5838+
58325839 mhc2 = (cmsMHC2Type * )_cmsCalloc (self -> ContextID , 1 , sizeof (cmsMHC2Type ));
58335840 if (mhc2 == NULL ) return NULL ;
58345841
@@ -5859,9 +5866,10 @@ void* Type_MHC2_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cms
58595866 if (!ReadDoublesAt (io , BaseOffset + MatrixOffset , 3 * 4 , & mhc2 -> XYZ2XYZmatrix [0 ][0 ])) goto Error ;
58605867 }
58615868
5862- if (!ReadDoublesAt (io , BaseOffset + OffsetRedTable , mhc2 -> CurveEntries , mhc2 -> RedCurve )) goto Error ;
5863- if (!ReadDoublesAt (io , BaseOffset + OffsetGreenTable , mhc2 -> CurveEntries , mhc2 -> GreenCurve )) goto Error ;
5864- if (!ReadDoublesAt (io , BaseOffset + OffsetBlueTable , mhc2 -> CurveEntries , mhc2 -> BlueCurve )) goto Error ;
5869+ // Skip sf32 tag and filler (8bytes)
5870+ if (!ReadDoublesAt (io , BaseOffset + OffsetRedTable + 8 , mhc2 -> CurveEntries , mhc2 -> RedCurve )) goto Error ;
5871+ if (!ReadDoublesAt (io , BaseOffset + OffsetGreenTable + 8 , mhc2 -> CurveEntries , mhc2 -> GreenCurve )) goto Error ;
5872+ if (!ReadDoublesAt (io , BaseOffset + OffsetBlueTable + 8 , mhc2 -> CurveEntries , mhc2 -> BlueCurve )) goto Error ;
58655873
58665874 // Success
58675875 * nItems = 1 ;
0 commit comments