public static Dictionary <int, string> GetValuesHex(byte[] bytes, bool bigEndian) { Dictionary <int, string> dict = new Dictionary <int, string>(); int length = bytes.Length; int index = 0; for (int i = 0; i < length; i = i + 2) { byte[] intByte = { bytes[i], bytes[i + 1] }; string value = ConverterFactory.ByteToHex(intByte, bigEndian); dict.Add(index, value); index++; } return(dict); }
//1 = BYTE An 8-bit unsigned integer., //2 = ASCII An 8-bit byte containing one 7-bit ASCII code. The final byte is terminated with NULL., //3 = SHORT A 16-bit (2-byte) unsigned integer, //4 = LONG A 32-bit (4-byte) unsigned integer, //5 = RATIONAL Two LONGs. The first LONG is the numerator and the second LONG expresses the //denominator., //7 = UNDEFINED An 8-bit byte that can take any value depending on the field definition, //9 = SLONG A 32-bit (4-byte) signed integer (2's complement notation), //10 = SRATIONAL Two SLONGs. The first SLONG is the numerator and the second SLONG is the #region GetMakernotes public static List <Makernote> GetMakernotes(Byte[] allBytes) { List <Makernote> listMakernotes = new List <Makernote>(); byte[] makernotes = allBytes; Makernote makernote = new Makernote(); //bool bigEndian = false; int lengthByte = 2; int numberBadBytes = 2; int endMakernotes = 542; int beginningDataBytes = 992; string message = ""; //for (int i = 2; i < 35 * 12; i++) for (int i = 2; i < 47 * 12; i++) { makernote = new Makernote(); byte[] bytesMakernote = new byte[12]; for (int n = 0; n < 12; n++) { bytesMakernote[n] = makernotes[i + n]; } // ID byte[] bytesID = { bytesMakernote[0], bytesMakernote[1] }; string id = ConverterFactory.ByteToHex(bytesID, false); makernote.Id = id; // Type byte[] bytesType = { bytesMakernote[2], bytesMakernote[3] }; Int16 type = ConverterFactory.ByteToInt16(bytesType, true); makernote.Type = type; // isHex / Name bool isHex = false; bool bigEndian = false; string name = GetNameMakernote(id, out isHex, out bigEndian); // Length byte[] bytesLength = { bytesMakernote[4], bytesMakernote[5], bytesMakernote[6], bytesMakernote[7] }; Int16 length = ConverterFactory.ByteToInt16(bytesLength, true); makernote.Length = length; // Offest byte[] bytesOffset = { bytesMakernote[8], bytesMakernote[9], bytesMakernote[10], bytesMakernote[11] }; Int16 offset = ConverterFactory.ByteToInt16(bytesOffset, true); makernote.Offset = offset; if (id == "0027") { int l = 0; } Dictionary <int, string> dictValues = new Dictionary <int, string>(); if (offset == 0) { dictValues = ConverterFactory.GetValues(allBytes, bytesMakernote, bigEndian, type, isHex, length, offset); } else { dictValues = ConverterFactory.GetValues(allBytes, bytesMakernote, bigEndian, type, isHex, length, offset); } makernote.Values = dictValues; listMakernotes.Add(makernote); i = i + 11; } File.WriteAllText(@"c:\temp\tags.txt", message); return(listMakernotes); }