@ -21,7 +21,7 @@ namespace ImageSharp
/// <returns>the tag data entry</returns>
/// <returns>the tag data entry</returns>
public IccTagDataEntry ReadTagDataEntry ( IccTagTableEntry info )
public IccTagDataEntry ReadTagDataEntry ( IccTagTableEntry info )
{
{
this . i ndex = ( int ) info . Offset ;
this . currentI ndex = ( int ) info . Offset ;
IccTypeSignature type = this . ReadTagDataEntryHeader ( ) ;
IccTypeSignature type = this . ReadTagDataEntryHeader ( ) ;
switch ( type )
switch ( type )
@ -43,9 +43,9 @@ namespace ImageSharp
case IccTypeSignature . Lut8 :
case IccTypeSignature . Lut8 :
return this . ReadLut8TagDataEntry ( ) ;
return this . ReadLut8TagDataEntry ( ) ;
case IccTypeSignature . LutAToB :
case IccTypeSignature . LutAToB :
return this . ReadLutAT oBTagDataEntry ( ) ;
return this . ReadLutAt oBTagDataEntry ( ) ;
case IccTypeSignature . LutBToA :
case IccTypeSignature . LutBToA :
return this . ReadLutBT oATagDataEntry ( ) ;
return this . ReadLutBt oATagDataEntry ( ) ;
case IccTypeSignature . Measurement :
case IccTypeSignature . Measurement :
return this . ReadMeasurementTagDataEntry ( ) ;
return this . ReadMeasurementTagDataEntry ( ) ;
case IccTypeSignature . MultiLocalizedUnicode :
case IccTypeSignature . MultiLocalizedUnicode :
@ -108,7 +108,7 @@ namespace ImageSharp
/// <returns>The read signature</returns>
/// <returns>The read signature</returns>
public IccTypeSignature ReadTagDataEntryHeader ( )
public IccTypeSignature ReadTagDataEntryHeader ( )
{
{
IccTypeSignature type = ( IccTypeSignature ) this . ReadUInt32 ( ) ;
var type = ( IccTypeSignature ) this . ReadUInt32 ( ) ;
this . AddIndex ( 4 ) ; // 4 bytes are not used
this . AddIndex ( 4 ) ; // 4 bytes are not used
return type ;
return type ;
}
}
@ -144,7 +144,7 @@ namespace ImageSharp
public IccChromaticityTagDataEntry ReadChromaticityTagDataEntry ( )
public IccChromaticityTagDataEntry ReadChromaticityTagDataEntry ( )
{
{
ushort channelCount = this . ReadUInt16 ( ) ;
ushort channelCount = this . ReadUInt16 ( ) ;
IccColorantEncoding colorant = ( IccColorantEncoding ) this . ReadUInt16 ( ) ;
var colorant = ( IccColorantEncoding ) this . ReadUInt16 ( ) ;
if ( Enum . IsDefined ( typeof ( IccColorantEncoding ) , colorant ) & & colorant ! = IccColorantEncoding . Unknown )
if ( Enum . IsDefined ( typeof ( IccColorantEncoding ) , colorant ) & & colorant ! = IccColorantEncoding . Unknown )
{
{
@ -206,21 +206,20 @@ namespace ImageSharp
{
{
return new IccCurveTagDataEntry ( ) ;
return new IccCurveTagDataEntry ( ) ;
}
}
else if ( pointCount = = 1 )
if ( pointCount = = 1 )
{
{
return new IccCurveTagDataEntry ( this . ReadUFix8 ( ) ) ;
return new IccCurveTagDataEntry ( this . ReadUFix8 ( ) ) ;
}
}
else
{
float [ ] cdata = new float [ pointCount ] ;
for ( int i = 0 ; i < pointCount ; i + + )
{
cdata [ i ] = this . ReadUInt16 ( ) / 6 5 5 3 5f ;
}
return new IccCurveTagDataEntry ( cdata ) ;
float [ ] cdata = new float [ pointCount ] ;
for ( int i = 0 ; i < pointCount ; i + + )
{
cdata [ i ] = this . ReadUInt16 ( ) / 6 5 5 3 5f ;
}
}
return new IccCurveTagDataEntry ( cdata ) ;
// TODO: If the input is PCSXYZ, 1+(32 767/32 768) shall be mapped to the value 1,0. If the output is PCSXYZ, the value 1,0 shall be mapped to 1+(32 767/32 768).
// TODO: If the input is PCSXYZ, 1+(32 767/32 768) shall be mapped to the value 1,0. If the output is PCSXYZ, the value 1,0 shall be mapped to 1+(32 767/32 768).
}
}
@ -328,9 +327,9 @@ namespace ImageSharp
/// Reads a <see cref="IccLutAToBTagDataEntry"/>
/// Reads a <see cref="IccLutAToBTagDataEntry"/>
/// </summary>
/// </summary>
/// <returns>The read entry</returns>
/// <returns>The read entry</returns>
public IccLutAToBTagDataEntry ReadLutAT oBTagDataEntry ( )
public IccLutAToBTagDataEntry ReadLutAt oBTagDataEntry ( )
{
{
int start = this . i ndex - 8 ; // 8 is the tag header size
int start = this . currentI ndex - 8 ; // 8 is the tag header size
byte inChCount = this . data [ this . AddIndex ( 1 ) ] ;
byte inChCount = this . data [ this . AddIndex ( 1 ) ] ;
byte outChCount = this . data [ this . AddIndex ( 1 ) ] ;
byte outChCount = this . data [ this . AddIndex ( 1 ) ] ;
@ -351,31 +350,31 @@ namespace ImageSharp
if ( bCurveOffset ! = 0 )
if ( bCurveOffset ! = 0 )
{
{
this . i ndex = ( int ) bCurveOffset + start ;
this . currentI ndex = ( int ) bCurveOffset + start ;
bCurve = this . ReadCurves ( outChCount ) ;
bCurve = this . ReadCurves ( outChCount ) ;
}
}
if ( mCurveOffset ! = 0 )
if ( mCurveOffset ! = 0 )
{
{
this . i ndex = ( int ) mCurveOffset + start ;
this . currentI ndex = ( int ) mCurveOffset + start ;
mCurve = this . ReadCurves ( outChCount ) ;
mCurve = this . ReadCurves ( outChCount ) ;
}
}
if ( aCurveOffset ! = 0 )
if ( aCurveOffset ! = 0 )
{
{
this . i ndex = ( int ) aCurveOffset + start ;
this . currentI ndex = ( int ) aCurveOffset + start ;
aCurve = this . ReadCurves ( inChCount ) ;
aCurve = this . ReadCurves ( inChCount ) ;
}
}
if ( clutOffset ! = 0 )
if ( clutOffset ! = 0 )
{
{
this . i ndex = ( int ) clutOffset + start ;
this . currentI ndex = ( int ) clutOffset + start ;
clut = this . ReadClut ( inChCount , outChCount , false ) ;
clut = this . ReadClut ( inChCount , outChCount , false ) ;
}
}
if ( matrixOffset ! = 0 )
if ( matrixOffset ! = 0 )
{
{
this . i ndex = ( int ) matrixOffset + start ;
this . currentI ndex = ( int ) matrixOffset + start ;
matrix3x3 = this . ReadMatrix ( 3 , 3 , false ) ;
matrix3x3 = this . ReadMatrix ( 3 , 3 , false ) ;
matrix3x1 = this . ReadMatrix ( 3 , false ) ;
matrix3x1 = this . ReadMatrix ( 3 , false ) ;
}
}
@ -387,9 +386,9 @@ namespace ImageSharp
/// Reads a <see cref="IccLutBToATagDataEntry"/>
/// Reads a <see cref="IccLutBToATagDataEntry"/>
/// </summary>
/// </summary>
/// <returns>The read entry</returns>
/// <returns>The read entry</returns>
public IccLutBToATagDataEntry ReadLutBT oATagDataEntry ( )
public IccLutBToATagDataEntry ReadLutBt oATagDataEntry ( )
{
{
int start = this . i ndex - 8 ; // 8 is the tag header size
int start = this . currentI ndex - 8 ; // 8 is the tag header size
byte inChCount = this . data [ this . AddIndex ( 1 ) ] ;
byte inChCount = this . data [ this . AddIndex ( 1 ) ] ;
byte outChCount = this . data [ this . AddIndex ( 1 ) ] ;
byte outChCount = this . data [ this . AddIndex ( 1 ) ] ;
@ -410,31 +409,31 @@ namespace ImageSharp
if ( bCurveOffset ! = 0 )
if ( bCurveOffset ! = 0 )
{
{
this . i ndex = ( int ) bCurveOffset + start ;
this . currentI ndex = ( int ) bCurveOffset + start ;
bCurve = this . ReadCurves ( inChCount ) ;
bCurve = this . ReadCurves ( inChCount ) ;
}
}
if ( mCurveOffset ! = 0 )
if ( mCurveOffset ! = 0 )
{
{
this . i ndex = ( int ) mCurveOffset + start ;
this . currentI ndex = ( int ) mCurveOffset + start ;
mCurve = this . ReadCurves ( inChCount ) ;
mCurve = this . ReadCurves ( inChCount ) ;
}
}
if ( aCurveOffset ! = 0 )
if ( aCurveOffset ! = 0 )
{
{
this . i ndex = ( int ) aCurveOffset + start ;
this . currentI ndex = ( int ) aCurveOffset + start ;
aCurve = this . ReadCurves ( outChCount ) ;
aCurve = this . ReadCurves ( outChCount ) ;
}
}
if ( clutOffset ! = 0 )
if ( clutOffset ! = 0 )
{
{
this . i ndex = ( int ) clutOffset + start ;
this . currentI ndex = ( int ) clutOffset + start ;
clut = this . ReadClut ( inChCount , outChCount , false ) ;
clut = this . ReadClut ( inChCount , outChCount , false ) ;
}
}
if ( matrixOffset ! = 0 )
if ( matrixOffset ! = 0 )
{
{
this . i ndex = ( int ) matrixOffset + start ;
this . currentI ndex = ( int ) matrixOffset + start ;
matrix3x3 = this . ReadMatrix ( 3 , 3 , false ) ;
matrix3x3 = this . ReadMatrix ( 3 , 3 , false ) ;
matrix3x1 = this . ReadMatrix ( 3 , false ) ;
matrix3x1 = this . ReadMatrix ( 3 , false ) ;
}
}
@ -462,8 +461,10 @@ namespace ImageSharp
/// <returns>The read entry</returns>
/// <returns>The read entry</returns>
public IccMultiLocalizedUnicodeTagDataEntry ReadMultiLocalizedUnicodeTagDataEntry ( )
public IccMultiLocalizedUnicodeTagDataEntry ReadMultiLocalizedUnicodeTagDataEntry ( )
{
{
int start = this . i ndex - 8 ; // 8 is the tag header size
int start = this . currentI ndex - 8 ; // 8 is the tag header size
uint recordCount = this . ReadUInt32 ( ) ;
uint recordCount = this . ReadUInt32 ( ) ;
// TODO: Why are we storing variable
uint recordSize = this . ReadUInt32 ( ) ;
uint recordSize = this . ReadUInt32 ( ) ;
IccLocalizedString [ ] text = new IccLocalizedString [ recordCount ] ;
IccLocalizedString [ ] text = new IccLocalizedString [ recordCount ] ;
@ -480,7 +481,7 @@ namespace ImageSharp
for ( int i = 0 ; i < recordCount ; i + + )
for ( int i = 0 ; i < recordCount ; i + + )
{
{
this . i ndex = ( int ) ( start + offset [ i ] ) ;
this . currentI ndex = ( int ) ( start + offset [ i ] ) ;
text [ i ] = new IccLocalizedString ( new CultureInfo ( culture [ i ] ) , this . ReadUnicodeString ( ( int ) length [ i ] ) ) ;
text [ i ] = new IccLocalizedString ( new CultureInfo ( culture [ i ] ) , this . ReadUnicodeString ( ( int ) length [ i ] ) ) ;
}
}
@ -493,8 +494,9 @@ namespace ImageSharp
/// <returns>The read entry</returns>
/// <returns>The read entry</returns>
public IccMultiProcessElementsTagDataEntry ReadMultiProcessElementsTagDataEntry ( )
public IccMultiProcessElementsTagDataEntry ReadMultiProcessElementsTagDataEntry ( )
{
{
int start = this . i ndex - 8 ;
int start = this . currentI ndex - 8 ;
// TODO: Why are we storing variable
ushort inChannelCount = this . ReadUInt16 ( ) ;
ushort inChannelCount = this . ReadUInt16 ( ) ;
ushort outChannelCount = this . ReadUInt16 ( ) ;
ushort outChannelCount = this . ReadUInt16 ( ) ;
uint elementCount = this . ReadUInt32 ( ) ;
uint elementCount = this . ReadUInt32 ( ) ;
@ -508,7 +510,7 @@ namespace ImageSharp
IccMultiProcessElement [ ] elements = new IccMultiProcessElement [ elementCount ] ;
IccMultiProcessElement [ ] elements = new IccMultiProcessElement [ elementCount ] ;
for ( int i = 0 ; i < elementCount ; i + + )
for ( int i = 0 ; i < elementCount ; i + + )
{
{
this . i ndex = ( int ) positionTable [ i ] . Offset + start ;
this . currentI ndex = ( int ) positionTable [ i ] . Offset + start ;
elements [ i ] = this . ReadMultiProcessElement ( ) ;
elements [ i ] = this . ReadMultiProcessElement ( ) ;
}
}
@ -567,7 +569,7 @@ namespace ImageSharp
/// <returns>The read entry</returns>
/// <returns>The read entry</returns>
public IccProfileSequenceIdentifierTagDataEntry ReadProfileSequenceIdentifierTagDataEntry ( )
public IccProfileSequenceIdentifierTagDataEntry ReadProfileSequenceIdentifierTagDataEntry ( )
{
{
int start = this . i ndex - 8 ; // 8 is the tag header size
int start = this . currentI ndex - 8 ; // 8 is the tag header size
uint count = this . ReadUInt32 ( ) ;
uint count = this . ReadUInt32 ( ) ;
IccPositionNumber [ ] table = new IccPositionNumber [ count ] ;
IccPositionNumber [ ] table = new IccPositionNumber [ count ] ;
for ( int i = 0 ; i < count ; i + + )
for ( int i = 0 ; i < count ; i + + )
@ -578,7 +580,7 @@ namespace ImageSharp
IccProfileSequenceIdentifier [ ] entries = new IccProfileSequenceIdentifier [ count ] ;
IccProfileSequenceIdentifier [ ] entries = new IccProfileSequenceIdentifier [ count ] ;
for ( int i = 0 ; i < count ; i + + )
for ( int i = 0 ; i < count ; i + + )
{
{
this . i ndex = ( int ) ( start + table [ i ] . Offset ) ;
this . currentI ndex = ( int ) ( start + table [ i ] . Offset ) ;
IccProfileId id = this . ReadProfileId ( ) ;
IccProfileId id = this . ReadProfileId ( ) ;
this . ReadCheckTagDataEntryHeader ( IccTypeSignature . MultiLocalizedUnicode ) ;
this . ReadCheckTagDataEntryHeader ( IccTypeSignature . MultiLocalizedUnicode ) ;
IccMultiLocalizedUnicodeTagDataEntry description = this . ReadMultiLocalizedUnicodeTagDataEntry ( ) ;
IccMultiLocalizedUnicodeTagDataEntry description = this . ReadMultiLocalizedUnicodeTagDataEntry ( ) ;
@ -594,7 +596,7 @@ namespace ImageSharp
/// <returns>The read entry</returns>
/// <returns>The read entry</returns>
public IccResponseCurveSet16TagDataEntry ReadResponseCurveSet16TagDataEntry ( )
public IccResponseCurveSet16TagDataEntry ReadResponseCurveSet16TagDataEntry ( )
{
{
int start = this . i ndex - 8 ; // 8 is the tag header size
int start = this . currentI ndex - 8 ; // 8 is the tag header size
ushort channelCount = this . ReadUInt16 ( ) ;
ushort channelCount = this . ReadUInt16 ( ) ;
ushort measurmentCount = this . ReadUInt16 ( ) ;
ushort measurmentCount = this . ReadUInt16 ( ) ;
@ -607,7 +609,7 @@ namespace ImageSharp
IccResponseCurve [ ] curves = new IccResponseCurve [ measurmentCount ] ;
IccResponseCurve [ ] curves = new IccResponseCurve [ measurmentCount ] ;
for ( int i = 0 ; i < measurmentCount ; i + + )
for ( int i = 0 ; i < measurmentCount ; i + + )
{
{
this . i ndex = ( int ) ( start + offset [ i ] ) ;
this . currentI ndex = ( int ) ( start + offset [ i ] ) ;
curves [ i ] = this . ReadResponseCurve ( channelCount ) ;
curves [ i ] = this . ReadResponseCurve ( channelCount ) ;
}
}
@ -766,8 +768,8 @@ namespace ImageSharp
/// <returns>The read entry</returns>
/// <returns>The read entry</returns>
public IccTextDescriptionTagDataEntry ReadTextDescriptionTagDataEntry ( )
public IccTextDescriptionTagDataEntry ReadTextDescriptionTagDataEntry ( )
{
{
string asciiValue , unicodeValue , scriptcodeValue ;
string unicodeValue , scriptcodeValue ;
asciiValue = unicodeValue = scriptcodeValue = null ;
string asciiValue = unicodeValue = scriptcodeValue = null ;
int asciiCount = ( int ) this . ReadUInt32 ( ) ;
int asciiCount = ( int ) this . ReadUInt32 ( ) ;
if ( asciiCount > 0 )
if ( asciiCount > 0 )
@ -830,7 +832,7 @@ namespace ImageSharp
/// <returns>The read entry</returns>
/// <returns>The read entry</returns>
public IccScreeningTagDataEntry ReadScreeningTagDataEntry ( )
public IccScreeningTagDataEntry ReadScreeningTagDataEntry ( )
{
{
IccScreeningFlag flags = ( IccScreeningFlag ) this . ReadInt32 ( ) ;
var flags = ( IccScreeningFlag ) this . ReadInt32 ( ) ;
uint channelCount = this . ReadUInt32 ( ) ;
uint channelCount = this . ReadUInt32 ( ) ;
IccScreeningChannel [ ] channels = new IccScreeningChannel [ channelCount ] ;
IccScreeningChannel [ ] channels = new IccScreeningChannel [ channelCount ] ;
for ( int i = 0 ; i < channels . Length ; i + + )
for ( int i = 0 ; i < channels . Length ; i + + )