diff --git a/src/ImageSharp/MetaData/Profiles/ICC/IccDataReader.cs b/src/ImageSharp/MetaData/Profiles/ICC/IccDataReader.cs index 2ebbf9bae8..30e31d3584 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/IccDataReader.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/IccDataReader.cs @@ -202,33 +202,6 @@ namespace ImageSharp return this.ReadUInt16() / 256f; } - /// - /// Reads a 16bit value ignoring endianness - /// - /// the value - public short ReadDirect16() - { - return BitConverter.ToInt16(this.data, this.AddIndex(2)); - } - - /// - /// Reads a 32bit value ignoring endianness - /// - /// the value - public int ReadDirect32() - { - return BitConverter.ToInt32(this.data, this.AddIndex(4)); - } - - /// - /// Reads a 64bit value ignoring endianness - /// - /// the value - public long ReadDirect64() - { - return BitConverter.ToInt64(this.data, this.AddIndex(8)); - } - /// /// Reads a number of bytes and advances the index /// @@ -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 /// The read entry public IccNamedColor2TagDataEntry ReadNamedColor2TagDataEntry() { - int vendorFlag = this.ReadDirect32(); + int vendorFlag = this.ReadInt32(); uint colorCount = this.ReadUInt32(); uint coordCount = this.ReadUInt32(); string prefix = this.ReadAsciiString(32); diff --git a/src/ImageSharp/MetaData/Profiles/ICC/IccDataWriter.cs b/src/ImageSharp/MetaData/Profiles/ICC/IccDataWriter.cs index 2d0be1d4b0..f2a048fbce 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/IccDataWriter.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/IccDataWriter.cs @@ -261,37 +261,7 @@ namespace ImageSharp this.dataStream.Write(data, 0, data.Length); return data.Length; } - - /// - /// Writes a short ignoring endianness - /// - /// The value to write - /// the number of bytes written - public unsafe int WriteDirect16(short value) - { - return this.WriteBytesDirect((byte*)&value, 2); - } - - /// - /// Writes an int ignoring endianness - /// - /// The value to write - /// the number of bytes written - public unsafe int WriteDirect32(int value) - { - return this.WriteBytesDirect((byte*)&value, 4); - } - - /// - /// Writes a long ignoring endianness - /// - /// The value to write - /// the number of bytes written - 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 /// The number of bytes written 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') diff --git a/src/ImageSharp/MetaData/Profiles/ICC/IccReader.cs b/src/ImageSharp/MetaData/Profiles/ICC/IccReader.cs index 75d37bb9b0..f84b75c6db 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/IccReader.cs +++ b/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), diff --git a/src/ImageSharp/MetaData/Profiles/ICC/IccWriter.cs b/src/ImageSharp/MetaData/Profiles/ICC/IccWriter.cs index 4c9fbc9405..cd1d1f74df 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/IccWriter.cs +++ b/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, ' ');