Wie kann ich das Char() in Integer() umwandeln?
Spoiler anzeigen
VB.NET-Quellcode
- Private Sub ReadHeader()
- ' bring in the first three bytes. it must be ID3 or we have no tag
- ' TODO add logic to check the end of the file for "3D1" and other
- ' possible starting spots
- Dim id3start As New String(br.ReadChars(3))
- ' check for a tag
- If Not id3start.Equals("ID3") Then
- ' TODO we are fucked.
- 'throw id3v2ReaderException;
- Me.hasTag = False
- Return
- Else
- Me.hasTag = True
- ' read id3 version. 2 bytes:
- ' The first byte of ID3v2 version is it's major version,
- ' while the second byte is its revision number
- Me.MajorVersion = System.Convert.ToInt32(br.ReadByte())
- Me.MinorVersion = System.Convert.ToInt32(br.ReadByte())
- 'read next byte for flags
- Dim boolar As Boolean() = BitReader.ToBitBool(br.ReadByte())
- ' set the flags
- Me.FA_Unsynchronisation = boolar(0)
- Me.FB_ExtendedHeader = boolar(1)
- Me.FC_ExperimentalIndicator = boolar(2)
- ' read teh size
- ' this code is courtesy of Daniel E. White w/ minor modifications by me Thanx Dan
- 'Dan Code
- Dim tagSize As Char() = br.ReadChars(4)
- ' I use this to read the bytes in from the file
- Dim bytes As Integer() = New Integer(3) {}
- ' for bit shifting
- Dim newSize As ULong = 0
- ' for the final number
- ' The ID3v2 tag size is encoded with four bytes
- ' where the most significant bit (bit 7)
- ' is set to zero in every byte,
- ' making a total of 28 bits.
- ' The zeroed bits are ignored
- '
- ' Some bit grinding is necessary. Hang on.
- bytes(3) = tagSize(3) Or ((tagSize(2) And 1) << 7)
- bytes(2) = ((tagSize(2) >> 1) And 63) Or ((tagSize(1) And 3) << 6)
- bytes(1) = ((tagSize(1) >> 2) And 31) Or ((tagSize(0) And 7) << 5)
- bytes(0) = ((tagSize(0) >> 3) And 15)
- newSize = (CType(10, UInt64) + CType(bytes(3), UInt64) Or (CType(bytes(2), UInt64) << 8) Or (CType(bytes(1), UInt64) << 16) Or (CType(bytes(0), UInt64) << 24))
- 'End Dan Code
- Me.headerSize = newSize
- End If
- End Sub
Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von „Morrison“ ()