Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- namespace PinkbrainSilverlightApplication.Id3Reader.Util
- {
- public class Id3BinaryReader: BinaryReader
- {
- public Id3BinaryReader(Stream stream): base(stream)
- {
- }
- public UInt32 ReadUInt32FromUnsafeBigEndian()
- {
- byte[] unsafeUIntBytes = this.ReadBytes(4);
- byte[] correctedBytes = new byte[4];
- correctedBytes[3] = (byte)(((unsafeUIntBytes[3] >> 0) & 0x7f) | ((unsafeUIntBytes[2] & 0x01) << 7));
- correctedBytes[2] = (byte)(((unsafeUIntBytes[2] >> 1) & 0x3f) | ((unsafeUIntBytes[1] & 0x03) << 6));
- correctedBytes[1] = (byte)(((unsafeUIntBytes[1] >> 2) & 0x1f) | ((unsafeUIntBytes[0] & 0x07) << 5));
- correctedBytes[0] = (byte)(((unsafeUIntBytes[0] >> 3) & 0x0f));
- return (UInt32) ((correctedBytes[0] << 24) | (correctedBytes[1] << 16) | (correctedBytes[2] << 8) | correctedBytes[3]);
- }
- }
- }
Add Comment
Please, Sign In to add comment