Browse Source

remove direct read/write, wrong thinking

pull/181/head
Johannes Bildstein 9 years ago
parent
commit
b4589e903d
  1. 31
      src/ImageSharp/MetaData/Profiles/ICC/IccDataReader.cs
  2. 36
      src/ImageSharp/MetaData/Profiles/ICC/IccDataWriter.cs
  3. 4
      src/ImageSharp/MetaData/Profiles/ICC/IccReader.cs
  4. 4
      src/ImageSharp/MetaData/Profiles/ICC/IccWriter.cs

31
src/ImageSharp/MetaData/Profiles/ICC/IccDataReader.cs

@ -202,33 +202,6 @@ namespace ImageSharp
return this.ReadUInt16() / 256f;
}
/// <summary>
/// Reads a 16bit value ignoring endianness
/// </summary>
/// <returns>the value</returns>
public short ReadDirect16()
{
return BitConverter.ToInt16(this.data, this.AddIndex(2));
}
/// <summary>
/// Reads a 32bit value ignoring endianness
/// </summary>
/// <returns>the value</returns>
public int ReadDirect32()
{
return BitConverter.ToInt32(this.data, this.AddIndex(4));
}
/// <summary>
/// Reads a 64bit value ignoring endianness
/// </summary>
/// <returns>the value</returns>
public long ReadDirect64()
{
return BitConverter.ToInt64(this.data, this.AddIndex(8));
}
/// <summary>
/// Reads a number of bytes and advances the index
/// </summary>
@ -357,7 +330,7 @@ namespace ImageSharp
{
uint manufacturer = this.ReadUInt32();
uint model = this.ReadUInt32();
IccDeviceAttribute attributes = (IccDeviceAttribute)this.ReadDirect64();
IccDeviceAttribute attributes = (IccDeviceAttribute)this.ReadInt64();
IccProfileTag technologyInfo = (IccProfileTag)this.ReadUInt32();
this.ReadCheckTagDataEntryHeader(IccTypeSignature.MultiLocalizedUnicode);
IccMultiLocalizedUnicodeTagDataEntry manufacturerInfo = this.ReadMultiLocalizedUnicodeTagDataEntry();
@ -888,7 +861,7 @@ namespace ImageSharp
/// <returns>The read entry</returns>
public IccNamedColor2TagDataEntry ReadNamedColor2TagDataEntry()
{
int vendorFlag = this.ReadDirect32();
int vendorFlag = this.ReadInt32();
uint colorCount = this.ReadUInt32();
uint coordCount = this.ReadUInt32();
string prefix = this.ReadAsciiString(32);

36
src/ImageSharp/MetaData/Profiles/ICC/IccDataWriter.cs

@ -261,37 +261,7 @@ namespace ImageSharp
this.dataStream.Write(data, 0, data.Length);
return data.Length;
}
/// <summary>
/// Writes a short ignoring endianness
/// </summary>
/// <param name="value">The value to write</param>
/// <returns>the number of bytes written</returns>
public unsafe int WriteDirect16(short value)
{
return this.WriteBytesDirect((byte*)&value, 2);
}
/// <summary>
/// Writes an int ignoring endianness
/// </summary>
/// <param name="value">The value to write</param>
/// <returns>the number of bytes written</returns>
public unsafe int WriteDirect32(int value)
{
return this.WriteBytesDirect((byte*)&value, 4);
}
/// <summary>
/// Writes a long ignoring endianness
/// </summary>
/// <param name="value">The value to write</param>
/// <returns>the number of bytes written</returns>
public unsafe int WriteDirect64(long value)
{
return this.WriteBytesDirect((byte*)&value, 8);
}
#endregion
#region Write Non-Primitives
@ -395,7 +365,7 @@ namespace ImageSharp
{
return this.WriteUInt32(value.DeviceManufacturer)
+ this.WriteUInt32(value.DeviceModel)
+ this.WriteDirect64((long)value.DeviceAttributes)
+ this.WriteInt64((long)value.DeviceAttributes)
+ this.WriteUInt32((uint)value.TechnologyInformation)
+ this.WriteTagDataEntryHeader(IccTypeSignature.MultiLocalizedUnicode)
+ this.WriteMultiLocalizedUnicodeTagDataEntry(new IccMultiLocalizedUnicodeTagDataEntry(value.DeviceManufacturerInfo))
@ -1018,7 +988,7 @@ namespace ImageSharp
/// <returns>The number of bytes written</returns>
public int WriteNamedColor2TagDataEntry(IccNamedColor2TagDataEntry value)
{
int count = this.WriteDirect32(value.VendorFlags)
int count = this.WriteInt32(value.VendorFlags)
+ this.WriteUInt32((uint)value.Colors.Length)
+ this.WriteUInt32((uint)value.CoordinateCount)
+ this.WriteASCIIString(value.Prefix, 32, '\0')

4
src/ImageSharp/MetaData/Profiles/ICC/IccReader.cs

@ -70,10 +70,10 @@ namespace ImageSharp
CreationDate = reader.ReadDateTime(),
FileSignature = reader.ReadAsciiString(4),
PrimaryPlatformSignature = (IccPrimaryPlatformType)reader.ReadUInt32(),
Flags = (IccProfileFlag)reader.ReadDirect32(),
Flags = (IccProfileFlag)reader.ReadInt32(),
DeviceManufacturer = reader.ReadUInt32(),
DeviceModel = reader.ReadUInt32(),
DeviceAttributes = (IccDeviceAttribute)reader.ReadDirect64(),
DeviceAttributes = (IccDeviceAttribute)reader.ReadInt64(),
RenderingIntent = (IccRenderingIntent)reader.ReadUInt32(),
PcsIlluminant = reader.ReadXyzNumber(),
CreatorSignature = reader.ReadAsciiString(4),

4
src/ImageSharp/MetaData/Profiles/ICC/IccWriter.cs

@ -42,10 +42,10 @@ namespace ImageSharp
writer.WriteDateTime(header.CreationDate);
writer.WriteASCIIString("acsp");
writer.WriteUInt32((uint)header.PrimaryPlatformSignature);
writer.WriteDirect32((int)header.Flags);
writer.WriteInt32((int)header.Flags);
writer.WriteUInt32(header.DeviceManufacturer);
writer.WriteUInt32(header.DeviceModel);
writer.WriteDirect64((long)header.DeviceAttributes);
writer.WriteInt64((long)header.DeviceAttributes);
writer.WriteUInt32((uint)header.RenderingIntent);
writer.WriteXYZNumber(header.PcsIlluminant);
writer.WriteASCIIString(header.CreatorSignature, 4, ' ');

Loading…
Cancel
Save