public static void PrintMakernotes(List <Makernote> makernotes, string filename, string outputfile) { int index = -1; string tagName = null; string values = null; bool isHex; bool bigEndian; string seperator = "----------------------------------------------------------------------"; string output = "Makernotes für Bild: " + Path.GetFileName(outputfile) + Environment.NewLine + Environment.NewLine; foreach (Makernote makernote in makernotes) { index = index + 1; tagName = MakernoteFactory.GetNameMakernote(makernote.Id, out isHex, out bigEndian); string firstPart = "ID: " + makernote.Id + Environment.NewLine + "Tagname: " + tagName + Environment.NewLine + "Wert(e): "; values = MakernoteFactory.GetValuesString(makernote, "Wert(e): ".Length); output = output + seperator + Environment.NewLine + firstPart + values + Environment.NewLine + Environment.NewLine; } File.WriteAllText(outputfile, output); }
public static Dictionary <int, string> GetValues(byte[] allBytes, byte[] makernoteBytes, bool bigEndian, int type, bool isHex, int length, int offset) { Dictionary <int, string> dic = new Dictionary <int, string>(); //byte[] bytes = new byte[]; if (offset == 0 || length == 1) { if (type == 2) { int z = 0; } else if (type == 3) { byte[] valueBytes = { makernoteBytes[8], makernoteBytes[9], makernoteBytes[10], makernoteBytes[11] }; Int64 value16 = ByteToInt16(valueBytes, true); dic.Add(0, value16.ToString()); } else if (type == 4) { byte[] valueBytes = { makernoteBytes[8], makernoteBytes[9], makernoteBytes[10], makernoteBytes[11] }; Int64 value64 = ByteToInt64(valueBytes, true); dic.Add(0, value64.ToString()); } } else { // ascii = bit byte if (type == 1) { int count = length; byte[] valueBytes = new byte[count]; int index = offset - s_beginningDataBytes; for (int i = 0; i < count; i++) { valueBytes[i] = allBytes[index + i]; } dic = MakernoteFactory.GetValuesInt8(valueBytes); } // ascii = bit byte else if (type == 2) { int count = length; byte[] valueBytes = new byte[count]; int index = offset - s_beginningDataBytes; for (int i = 0; i < count; i++) { valueBytes[i] = allBytes[index + i]; } dic = MakernoteFactory.GetValuesString(valueBytes, false); } // short = 2 byte else if (type == 3) { int count = length * 2; byte[] valueBytes = new byte[count]; int index = offset - s_beginningDataBytes; for (int i = 0; i < count; i = i + 2) { valueBytes[i] = allBytes[index + i]; valueBytes[i + 1] = allBytes[index + (i + 1)]; } if (isHex) { dic = MakernoteFactory.GetValuesHex(valueBytes, false); } else { dic = MakernoteFactory.GetValuesInt16(valueBytes, true); } } // long = 4 byte else if (type == 4) { int count = length * 4; byte[] valueBytes = new byte[count]; int index = offset - s_beginningDataBytes; for (int i = 0; i < count; i = i + 4) { valueBytes[i] = allBytes[index + i]; valueBytes[i + 1] = allBytes[index + (i + 1)]; valueBytes[i + 2] = allBytes[index + (i + 2)]; valueBytes[i + 3] = allBytes[index + (i + 3)]; } dic = MakernoteFactory.GetValuesInt32(valueBytes, bigEndian); } } return(dic); }