public void Read(BinaryReaderWriter br) { blocks.Clear(); // 0x0 Used = br.ReadByte() == 0x01; // 0x01 Name = br.ReadString(8); // 0x09 Typ = br.ReadString(3); // 0x0c Filesize = br.Read4UInt(); // 0x10 Flag = br.ReadByte(); // 0x11 Part = br.ReadByte(); // 0x12 Unknown = br.ReadBytes(14); // 0x20 for (int i = 0; i < MaxBlockNumberCount; i++) { UInt16 no = br.Read2AsUShort(); if (no != 0xffff) { blocks.Add(no); } } }
public override void ReadHeader(BinaryReaderWriter br) { base.ReadCommonHeader(br, Type); Nod1Nodes.Read(br); Flags = br.Read2AsUShort(); br.ReadBytes(Unknown_0x1F); Align = br.ReadByte(); Mult1 = br.ReadByte(); TableARecordLen = br.Read2AsUShort(); Nod2RoadData.Read(br); br.ReadBytes(Unknown_0x2D); Nod3BoundaryNodes.Read(br); br.ReadBytes(Unknown_0x3B); if (Headerlength > 0x3F) { Nod4HighClassBoundary.Read(br); // 0x3F, 8Byte for (int i = 0; i < ClassBoundaries.Length; i++) // 0x47, 5*4 Bytes { ClassBoundaries[i] = br.Read4Int(); if (i > 0) { ClassBoundaries[i] += ClassBoundaries[i - 1]; } } br.ReadBytes(Unknown_0x5B); Nod5.Read(br); br.ReadBytes(Unknown_0x6F); Nod6.Read(br); br.ReadBytes(Unknown_0x7B); } }
public void Read(BinaryReaderWriter br, UInt16 recordlen) { if (recordlen >= 0x3C) { SpecType = br.ReadByte(); No = br.ReadByte(); PointsHoriz = br.Read4Int(); PointsVert = br.Read4Int(); LastRowHeight = br.Read4Int(); LastColWidth = br.Read4Int(); Unknown12 = br.Read2AsShort(); MaxIdxHoriz = br.Read4Int(); MaxIdxVert = br.Read4Int(); Structure = br.Read2AsShort(); short tmp = br.Read2AsShort(); // SubtileTableitemSize: ergibt sich schon aus Structure PtrSubtileTable = br.Read4UInt(); PtrHeightdata = br.Read4UInt(); west = br.Read4Int(); north = br.Read4Int(); pointDistanceVert = br.Read4Int(); pointDistanceHoriz = br.Read4Int(); MinHeight = br.Read2AsShort(); MaxHeight = br.Read2AsUShort(); } }
/// <summary> /// liest die Blockdaten ein /// </summary> /// <param name="br"></param> public void ReadData(BinaryReaderWriter br) { Unknown1 = br.Read2AsUShort(); A = br.ReadByte(); Unknown2 = br.Read4UInt(); Unknown3 = br.Read2AsUShort(); B = br.ReadByte(); Unknown4 = br.Read2AsUShort(); C = br.ReadByte(); Unknown5 = br.Read4UInt(); D = br.ReadByte(); Unknown6 = br.Read2AsUShort(); }
/// <summary> /// liest einen Draworder-Eintrag ein (Typ 0 steht für das Ende eines Levels) /// </summary> /// <param name="br"></param> /// <param name="length"></param> /// <param name="level"></param> public PolygonDraworderTableItem(BinaryReaderWriter br, int length, uint level) : this() { if (length > 9) { throw new Exception("Ein PolygonDraworderTableItem darf max. 9 Byte lang sein."); } Level = level; Type = br.ReadByte(); length--; // insgesamt 32 Bit für 31 Sublevel // 1. Byte: Bit 0 für Sublevel 0 // Bit 1 für Sublevel 1 // ... // Bit 7 für Sublevel 7 // 2. Byte: Bit 0 für Sublevel 8 // Bit 1 für Sublevel 9 // ... // Bit 7 für Sublevel F // 3. Byte: Bit 0 für Sublevel 10 // Bit 1 für Sublevel 11 // ... // Bit 7 für Sublevel 17 // 4. Byte: Bit 0 für Sublevel 18 // Bit 1 für Sublevel 19 // ... // Bit 7 für Sublevel 1F for (uint b = 0; b < length; b++) // alle (4) Bytes für Subtypes 0x00 ... 0x1F einlesen { byte bv = br.ReadByte(); byte mask = 0x01; for (uint bit = 0; bit < 8; bit++) { if ((bv & mask) != 0x0) { SetSubtype(bit + 8 * b); } mask <<= 1; } } if (Subtypes.Count == 0) { Subtypes.Add(0); } else { Type += 0x100; } }
public void Read(BinaryReaderWriter br) { Typ = (char)br.ReadByte(); UInt16 len = br.Read2AsUShort(); // Anzahl der noch folgenden Bytes long end = br.BaseStream.Position + len; switch (Typ) { case 'L': // MapBlock ProductID = br.Read2AsUShort(); FamilyID = br.Read2AsUShort(); MapNumber = br.Read4UInt(); while (br.BaseStream.Position < end - 9) // seriesName, mapDescription, areaName { Name.Add(br.ReadString()); } Unknown0 = br.Read4UInt(); Unknown1 = br.Read4UInt(); break; case 'P': // ProductBlock ProductID = br.Read2AsUShort(); FamilyID = br.Read2AsUShort(); Unknown2 = br.Read2AsUShort(); Unknown3 = br.Read2AsUShort(); Unknown4 = br.Read2AsUShort(); break; case 'F': // vereinfachter MapBlock ? ProductID = br.Read2AsUShort(); FamilyID = br.Read2AsUShort(); while (br.BaseStream.Position < end) // description (nur 1x?) { Name.Add(br.ReadString()); } break; case 'V': while (br.BaseStream.Position < end - 1) { Name.Add(br.ReadString()); } Unknown5 = br.ReadByte(); break; default: break; } }
/// <summary> /// liest einen Tabelleneintrag ein /// </summary> /// <param name="br"></param> /// <param name="offset_len">Länge des Speicherbereichs für den Offset in Byte</param> /// <param name="baseheight_len">Länge des Speicherbereichs für die Basishöhe in Byte</param> /// <param name="diff_len">Länge des Speicherbereichs in Byte</param> /// <param name="extraBytes">wenn größer 0, dann 1 zusätzliches Byte</param> public void Read(BinaryReaderWriter br, int offset_len = 3, int baseheight_len = 2, int diff_len = 2, int type_len = 1) { switch (offset_len) { case 1: Offset = br.ReadByte(); break; case 2: Offset = br.Read2AsUShort(); break; case 3: Offset = br.Read3AsUInt(); break; case 4: Offset = br.Read4UInt(); break; } switch (baseheight_len) { case 1: Baseheight = br.ReadByte(); break; case 2: Baseheight = br.Read2AsShort(); break; } switch (diff_len) { case 1: Diff = br.ReadByte(); break; case 2: Diff = br.Read2AsUShort(); break; } if (type_len > 0) { Type = br.ReadByte(); } }
/// <summary> /// liest den allgemeinen Header ab <see cref="HeaderOffset"/> ein /// <para>Ist der eingelesene Typ nicht der erwartete Typ, wird eine Exception ausgelöst.</para> /// </summary> /// <param name="br"></param> /// <param name="expectedtyp">Extension des erwarteten Typs z.B. 'LBL', sonst null</param> protected void ReadCommonHeader(BinaryReaderWriter br, string expectedtyp = null) { br.Seek(HeaderOffset); Headerlength = br.Read2AsUShort(); GarminTyp = br.ReadString(10); // z.B. "GARMIN RGN" if (GarminTyp.Length != 10 || GarminTyp.Substring(0, 7) != "GARMIN ") { throw new Exception("Das ist kein Garmin-SUB-File."); } if (!string.IsNullOrEmpty(expectedtyp) && GarminTyp.Substring(7) != expectedtyp) { throw new Exception("Das ist nicht der erwartete Dateityp (" + expectedtyp + ")."); } Unknown_0x0C = br.ReadByte(); Locked = br.ReadByte(); try { CreationDate = new DateTime(br.Read2AsShort(), br.ReadByte(), // "echter" Monat br.ReadByte(), br.ReadByte(), br.ReadByte(), br.ReadByte()); } catch { // Datum/Uhrzeit nicht erkannt } }
/// <summary> /// liest die Blockdaten ein /// </summary> /// <param name="br"></param> public new void ReadData(BinaryReaderWriter br) { base.ReadData(br); int readlen = 6 * 4 + Description.Length + 1; // in der Basisklasse gelesen Unknown1 = br.Read2AsUShort(); SubCount = br.Read2AsUShort(); readlen += 4; DataSize.Clear(); for (int i = 0; i < SubCount; i++) { DataSize.Add(br.Read4UInt()); readlen += 4; } if (blh.Length - readlen < 7) { return; } HasCopyright = br.ReadByte(); Unknown2 = br.ReadByte(); Unknown3 = br.ReadByte(); Unknown4 = br.ReadByte(); Unknown5 = br.ReadByte(); Unknown6 = br.ReadByte(); Unknown7 = br.ReadByte(); readlen += 7; Name.Clear(); for (int i = 0; i < SubCount; i++) { Name.Add(br.ReadString()); readlen += Name[Name.Count - 1].Length + 1; } if (blh.Length - readlen < 2) { return; } Unknown8 = br.ReadByte(); Unknown9 = br.ReadByte(); }
public void Read(BinaryReaderWriter br) { byte b = br.ReadByte(); CopyrightCode = CopyrightCodes.Unknown; try { CopyrightCode = (CopyrightCodes)b; } catch { } b = br.ReadByte(); WhereCode = WhereCodes.Unknown; try { WhereCode = (WhereCodes)b; } catch { } ExtraProperties = br.Read2AsUShort(); Copyright = br.ReadString(); }
public override void ReadHeader(BinaryReaderWriter br) { base.ReadCommonHeader(br, Type); Filesections.ClearSections(); Codepage = br.Read2AsUShort(); br.SetEncoding(Codepage); SortId1 = br.Read2AsUShort(); SortId2 = br.Read2AsUShort(); br.ReadBytes(Unknown_x1B); Mdr1 = new DataBlockWithRecordsize(br); br.ReadBytes(Unknown_x27); Mdr2 = new DataBlockWithRecordsize(br); br.ReadBytes(Unknown_x35); Mdr3 = new DataBlockWithRecordsize(br); br.ReadBytes(Unknown_x43); Mdr4 = new DataBlockWithRecordsize(br); br.ReadBytes(Unknown_x51); Mdr5 = new DataBlockWithRecordsize(br); br.ReadBytes(Unknown_x5F); Mdr6 = new DataBlockWithRecordsize(br); br.ReadBytes(Unknown_x6D); Mdr7 = new DataBlockWithRecordsize(br); br.ReadBytes(Unknown_x7B); Mdr8 = new DataBlockWithRecordsize(br); br.ReadBytes(Unknown_x89); Mdr9 = new DataBlockWithRecordsize(br); br.ReadBytes(Unknown_x97); Mdr10 = new DataBlock(br); br.ReadBytes(Unknown_xA3); Mdr11 = new DataBlockWithRecordsize(br); br.ReadBytes(Unknown_xB1); Mdr12 = new DataBlockWithRecordsize(br); br.ReadBytes(Unknown_xBF); Mdr13 = new DataBlockWithRecordsize(br); br.ReadBytes(Unknown_xCD); Mdr14 = new DataBlockWithRecordsize(br); br.ReadBytes(Unknown_xDB); Mdr15 = new DataBlock(br); Unknown_xE7 = br.ReadByte(); Mdr16 = new DataBlockWithRecordsize(br); br.ReadBytes(Unknown_xF2); Mdr17 = new DataBlock(br); br.ReadBytes(Unknown_xFE); Mdr18 = new DataBlockWithRecordsize(br); br.ReadBytes(Unknown_x10C); if (Headerlength > 0x110) { Unknown_x110 = new byte[Headerlength - 0x110]; br.ReadBytes(Unknown_x110); } }
protected override void Encode_Header(BinaryReaderWriter bw) { if (bw != null) { base.Encode_Header(bw); bw.Write(Codepage); bw.Write(SortId1); bw.Write(SortId2); bw.Write(Unknown_x1B); Mdr1.Write(bw); bw.Write(Unknown_x27); Mdr2.Write(bw); bw.Write(Unknown_x35); Mdr3.Write(bw); bw.Write(Unknown_x43); Mdr4.Write(bw); bw.Write(Unknown_x51); Mdr5.Write(bw); bw.Write(Unknown_x5F); Mdr6.Write(bw); bw.Write(Unknown_x6D); Mdr7.Write(bw); bw.Write(Unknown_x7B); Mdr8.Write(bw); bw.Write(Unknown_x89); Mdr9.Write(bw); bw.Write(Unknown_x97); Mdr10.Write(bw); bw.Write(Unknown_xA3); Mdr11.Write(bw); bw.Write(Unknown_xB1); Mdr12.Write(bw); bw.Write(Unknown_xBF); Mdr13.Write(bw); bw.Write(Unknown_xCD); Mdr14.Write(bw); bw.Write(Unknown_xDB); Mdr15.Write(bw); Unknown_xE7 = bw.ReadByte(); Mdr16.Write(bw); bw.Write(Unknown_xF2); Mdr17.Write(bw); bw.Write(Unknown_xFE); Mdr18.Write(bw); bw.Write(Unknown_x10C); if (Headerlength > 0x110) { Unknown_x110 = new byte[Headerlength - 0x110]; bw.Write(Unknown_x110); } } }
/// <summary> /// liest eine Farbtabelle ein /// </summary> /// <param name="br"></param> /// <param name="iCols">Anzahl der Farben in der Tabelle</param> /// <param name="bWithAlpha">Farben mit oder ohne Alphaanteil</param> /// <returns>Farbtabelle</returns> public static Color[] ReadColorTable(BinaryReaderWriter br, int iCols = 1, bool bWithAlpha = false) { Color[] col = new Color[iCols]; if (!bWithAlpha) { for (int i = 0; i < iCols; i++) { byte blue = br.ReadByte(); byte green = br.ReadByte(); byte red = br.ReadByte(); col[i] = Color.FromArgb(red, green, blue); } } else { // Länge der Farbtabelle ermitteln int len = iCols * 3 + iCols / 2; if (iCols % 2 == 1) { len++; } // Farbtabelle einlesen byte[] colortable = br.ReadBytes(len); byte[] halfbytetable = new byte[2 * len]; for (int i = 0; i < len; i++) { halfbytetable[2 * i] = (byte)(colortable[i] & 0xf); halfbytetable[2 * i + 1] = (byte)(colortable[i] >> 4); } for (int i = 0; i < iCols; i++) { byte blue = (byte)(halfbytetable[7 * i] | (halfbytetable[7 * i + 1] << 4)); byte green = (byte)(halfbytetable[7 * i + 2] | (halfbytetable[7 * i + 3] << 4)); byte red = (byte)(halfbytetable[7 * i + 4] | (halfbytetable[7 * i + 5] << 4)); byte alpha = halfbytetable[7 * i + 6]; alpha = (byte)((255 * alpha) / 15); // 0x0..0xf --> 0x0..0xff col[i] = Color.FromArgb(~alpha & 0xff, red, green, blue); } } return(col); }
public MultiText(BinaryReaderWriter br) : this() { int len = br.ReadByte(); if ((len & 0x1) == 0x1) // ungerade --> nur 1 Byte für Längekennung { len >>= 1; } else // gerade --> 2 Byte für Längekennung { len += br.ReadByte() << 8; len >>= 2; } while (len > 0) { Text t = new Text(br); Set(t); len -= t.Txt.Length + 2; // einschließlich jeweils 1 Byte Ländercode und 1 0-Byte } }
public void Read(BinaryReaderWriter br) { try { Options = br.ReadByte(); uint iWidth = br.ReadByte(); uint iHeight = br.ReadByte(); colsday = br.ReadByte(); ColormodeDay = (BitmapColorMode)br.ReadByte(); this.XBitmapDay = new PixMap(iWidth, iHeight, colsday, ColormodeDay, br); if (WithNightXpm) { colsnight = br.ReadByte(); ColormodeNight = (BitmapColorMode)br.ReadByte(); if (!NightXpmHasData) { Color[] col = BinaryColor.ReadColorTable(br, colsnight); XBitmapNight = new PixMap(XBitmapDay); XBitmapNight.SetNewColors(col); } else { XBitmapNight = new PixMap(Width, Height, colsnight, ColormodeNight, br); } } if (WithString) { Text = new MultiText(br); } if (WithExtendedOptions) { ExtOptions = br.ReadByte(); switch (FontColType) { case FontColours.Day: colFontColour[0] = BinaryColor.ReadColor(br); break; case FontColours.Night: colFontColour[1] = BinaryColor.ReadColor(br); break; case FontColours.DayAndNight: colFontColour = BinaryColor.ReadColorTable(br, 2); break; } } } catch (Exception ex) { throw new Exception(string.Format("Fehler beim Lesen des Punktes 0x{0:x} 0x{1:x}: {2}", Type, Subtype, ex.Message)); } }
public void Read(BinaryReaderWriter br) { byte b = 0; try { b = br.ReadByte(); ID = (Typ)b; } catch { throw new Exception("Unbekannter Block-Typ: 0x" + b.ToString("X")); } Length = br.Read2AsUShort(); }
public TableItem(BinaryReaderWriter br, int iItemlength) : this() { rawtype = br.Read2AsUShort(); switch (iItemlength) { case 3: Offset = br.ReadByte(); break; case 4: Offset = br.Read2AsUShort(); break; case 5: Offset = (int)br.Read3AsUInt(); break; } }
public Text(BinaryReaderWriter br) : this() { Language = (LanguageCode)br.ReadByte(); Txt = br.ReadString(0, Encoding.Default); //List<char> chars = new List<char>(); //char c; //do { // c = br.ReadChar(); // if (c != 0x0) // chars.Add(c); //} while (c != 0x0); //Txt = new string(chars.ToArray()); }
public void Read(BinaryReaderWriter br) { // 0x0 /* Before you can look at an IMG file, you must XOR it with the XOR byte (the first byte in the file). Some maps are not XOR’d (the first byte is 0x00). */ br.XOR = XOR = br.ReadByte(); // 0x01 br.ReadBytes(Unknown_x01); // 0x0a UpdateMonth = br.ReadByte(); // 0x0b _UpdateYear = br.ReadByte(); // 0x0c br.ReadBytes(Unknown_x0c); // 0x0e // Mapsource flag, 1 - file created by Mapsource, 0 - Garmin map visible in Basecamp and Homeport MapsourceFlag = br.ReadByte(); /* 0x0f sum % 256 * The checksum at 0xF is calculated by summing all bytes, save for the checksum byte itself, in the * map file and then multiplying by -1. The lowest byte in this product becomes the checksum byte * at 0xF. Note that this checksum is apparently not validated by MapSource, since you can modify * the contents of IMG files directly with a hex editor and they will still work even if the checksum * is not updated. */ Checksum = br.ReadByte(); // 0x10 string tmp = Encoding.ASCII.GetString(br.ReadBytes(SIGNATURE.Length)); if (tmp != SIGNATURE) { throw new Exception("Das ist keine Garmin-IMG-Datei."); } // 0x16 br.ReadBytes(Unknown_x16); // (Size of each FAT, in sectors, for FAT12/16; 0 for FAT32 ) // 0x18 SectorsPerTrack = br.Read2AsUShort(); // 0x1a HeadsPerCylinder = br.Read2AsUShort(); // 0x1c Cylinders = br.Read2AsUShort(); // 0x1e br.ReadBytes(Unknown_x1e); // 0x39 CreationDate = new DateTime(br.Read2AsUShort(), br.ReadByte(), br.ReadByte(), br.ReadByte(), br.ReadByte(), br.ReadByte()); // 0x40 _HeadSectors = br.ReadByte(); // 0x41 tmp = Encoding.ASCII.GetString(br.ReadBytes(MAPFILEIDENTIFIER.Length)); if (tmp != MAPFILEIDENTIFIER) { throw new Exception("Das ist keine Garmin-IMG-Datei."); } // 0x47 br.ReadBytes(Unknown_x47); // 0x49 Description1 = Encoding.ASCII.GetString(br.ReadBytes(20)); // 0x5d HeadsPerCylinder2 = br.Read2AsUShort(); // 0x5f SectorsPerTrack2 = br.Read2AsUShort(); // 0x61 /* Most notable are the two byte values (at 0x61 and 0x62, here named as E1 and E2) which are * used to set the block size for the file. They represent powers of two, and the block size is set via * the formula 2E1+E2 . E1 appears to always be 0x09, setting the minimum block size to 512 bytes. */ BlocksizeExp1 = br.ReadByte(); // 0x62 BlocksizeExp2 = br.ReadByte(); // 0x63 Blocks4Img = br.Read2AsUShort(); // 0x65 Description2 = Encoding.ASCII.GetString(br.ReadBytes(30)); // 0x83 br.ReadBytes(Unknown_x83); // "partition table" // 0x1bf StartHeadNumber4Partition = br.ReadByte(); // 0x1c0 StartSectorNumber4Partition = br.ReadByte(); // 0x1c1 StartCylinderNumber4Partition = br.ReadByte(); // 0x1c2 Systemtyp = br.ReadByte(); // 0x1c3 LastHeadNumber4Partition = br.ReadByte(); // 0x1c4 LastSectorNumber4Partition = br.ReadByte(); // 0x1c5 LastCylinderNumber4Partition = br.ReadByte(); // 0x1c6 RelativeSectors = br.Read4UInt(); // 0x1ca LastSectorNumber4IMG = br.Read4UInt(); // 0x1ce br.ReadBytes(Unknown_x1ce); // 0x1fe if (br.Read2AsUShort() != BOOTSIGNATURE) { throw new Exception("Das ist keine Garmin-IMG-Datei."); } // 0x200 Unknown_x200 = new byte[(_HeadSectors - 1) * SECTOR_BLOCKSIZE]; br.ReadBytes(Unknown_x200); }
/// <summary> /// liest die Blockdaten ein /// </summary> /// <param name="br"></param> public void ReadData(BinaryReaderWriter br) { Unknown1 = br.ReadByte(); Text = br.ReadString(); }
public void Read(BinaryReaderWriter br) { long startpos = br.BaseStream.Position; try { Options = br.ReadByte(); Options2 = br.ReadByte(); // Farben einlesen (1 bis max. 4) switch (Polylinetype) { case PolylineType.Day2: colDayColor = BinaryColor.ReadColorTable(br, 2); break; case PolylineType.Day2_Night2: colDayColor = BinaryColor.ReadColorTable(br, 2); colNightColor = BinaryColor.ReadColorTable(br, 2); break; case PolylineType.Day1_Night2: colDayColor[0] = BinaryColor.ReadColor(br); colNightColor = BinaryColor.ReadColorTable(br, 2); break; case PolylineType.NoBorder_Day2_Night1: colDayColor = BinaryColor.ReadColorTable(br, 2); colNightColor[0] = BinaryColor.ReadColor(br); break; case PolylineType.NoBorder_Day1: colDayColor[0] = BinaryColor.ReadColor(br); break; case PolylineType.NoBorder_Day1_Night1: colDayColor[0] = BinaryColor.ReadColor(br); colNightColor[0] = BinaryColor.ReadColor(br); break; } if (BitmapHeight == 0) // Linien- und Randbreite ermitteln { switch (Polylinetype) { case PolylineType.Day2: case PolylineType.Day2_Night2: case PolylineType.Day1_Night2: InnerWidth = br.ReadByte(); if (InnerWidth > 0) // sonst Bitmap, also KEINE BorderWidth { BorderWidth = (br.ReadByte() - InnerWidth) / 2; } break; case PolylineType.NoBorder_Day2_Night1: case PolylineType.NoBorder_Day1: case PolylineType.NoBorder_Day1_Night1: InnerWidth = br.ReadByte(); // es folgt KEINE BorderWidth break; } } else // Bitmap einlesen (Höhe ist Thickness Pixel, Breite 32 Pixel, Dummyfarbe!) { XBitmapDay = new PixMap(32, BitmapHeight, new Color[1] { Color.White }, BitmapColorMode.POLY1TR, br); } if (WithString) { Text = new MultiText(br); } if (WithExtendedOptions) { ExtOptions = br.ReadByte(); switch (FontColType) { case FontColours.Day: colFontColour[0] = BinaryColor.ReadColor(br); break; case FontColours.Night: colFontColour[1] = BinaryColor.ReadColor(br); break; case FontColours.DayAndNight: colFontColour = BinaryColor.ReadColorTable(br, 2); break; } } } catch (Exception ex) { throw new Exception(string.Format("Fehler beim Lesen der Linie 0x{0:x} 0x{1:x}: {2}", Type, Subtype, ex.Message)); } }
/// <summary> /// liest die Blockdaten (Segmente) ein /// </summary> /// <param name="br"></param> public void ReadData(BinaryReaderWriter br) { ProductID = br.Read2AsUShort(); FamilyID = br.Read2AsUShort(); TDBVersion = br.Read2AsUShort(); MapSeriesName = br.ReadString(); ProductVersion = br.Read2AsUShort(); MapFamilyName = br.ReadString(); if (TDBVersion >= 407) { Unknown1 = br.ReadByte(); MaxCoordbits4Overview = br.ReadByte(); Unknown2 = br.ReadByte(); Unknown3 = br.ReadByte(); Unknown4 = br.ReadByte(); Unknown5 = br.ReadByte(); Unknown6 = br.ReadByte(); Unknown7 = br.ReadByte(); Unknown8 = br.ReadByte(); Unknown9 = br.ReadByte(); HighestRoutable = br.ReadByte(); Unknown10 = br.ReadByte(); Unknown11 = br.ReadByte(); Unknown12 = br.ReadByte(); Unknown13 = br.ReadByte(); Unknown14 = br.ReadByte(); Unknown15 = br.ReadByte(); Unknown16 = br.ReadByte(); Unknown17 = br.ReadByte(); Unknown18 = br.ReadByte(); Unknown19 = br.ReadByte(); Unknown20 = br.ReadByte(); Unknown21 = br.ReadByte(); Unknown22 = br.ReadByte(); Unknown23 = br.ReadByte(); Unknown24 = br.ReadByte(); Unknown25 = br.ReadByte(); Unknown26 = br.ReadByte(); Unknown27 = br.ReadByte(); Unknown28 = br.ReadByte(); CodePage = br.Read4UInt(); Unknown29 = br.Read4UInt(); Routable = br.ReadByte(); HasProfileInformation = br.ReadByte(); HasDEM = br.ReadByte(); if (TDBVersion >= 411) { Unknown30 = br.ReadByte(); Unknown31 = br.ReadByte(); Unknown32 = br.ReadByte(); Unknown33 = br.ReadByte(); Unknown34 = br.ReadByte(); Unknown35 = br.ReadByte(); Unknown36 = br.ReadByte(); Unknown37 = br.ReadByte(); Unknown38 = br.ReadByte(); Unknown39 = br.ReadByte(); Unknown40 = br.ReadByte(); Unknown41 = br.ReadByte(); Unknown42 = br.ReadByte(); Unknown43 = br.ReadByte(); Unknown44 = br.ReadByte(); Unknown45 = br.ReadByte(); Unknown46 = br.ReadByte(); Unknown47 = br.ReadByte(); Unknown48 = br.ReadByte(); Unknown49 = br.ReadByte(); } } }
public void Read(BinaryReaderWriter br) { try { Options = br.ReadByte(); // es folgen 1 bis max. 4 Farben und ev. 1 Bitmap switch (Colortype) // hier muss sicher noch überprüft werden, ob die Typen wirklich richtig interpretiert werden { case ColorType.Day1: colDayColor[0] = BinaryColor.ReadColor(br); break; case ColorType.Day1_Night1: colDayColor[0] = BinaryColor.ReadColor(br); colNightColor[0] = BinaryColor.ReadColor(br); break; case ColorType.BM_Day2: // 2 Farben + 1x Pixeldaten colDayColor = BinaryColor.ReadColorTable(br, 2); XBitmapDay = new PixMap(32, 32, colDayColor, BitmapColorMode.POLY2, br); break; case ColorType.BM_Day2_Night2: // 4 Farben + 1x Pixeldaten colDayColor = BinaryColor.ReadColorTable(br, 2); colNightColor = BinaryColor.ReadColorTable(br, 2); XBitmapDay = new PixMap(32, 32, colDayColor, BitmapColorMode.POLY2, br); XBitmapNight = new PixMap(XBitmapDay); XBitmapNight.SetNewColors(colNightColor); break; case ColorType.BM_Day1_Night2: // 3 Farben + 1x Pixeldaten colDayColor[0] = BinaryColor.ReadColor(br); colDayColor[1] = PixMap.TransparentColor; colNightColor = BinaryColor.ReadColorTable(br, 2); XBitmapDay = new PixMap(32, 32, colDayColor, BitmapColorMode.POLY2, br); XBitmapNight = new PixMap(XBitmapDay); XBitmapNight.ChangeColorMode(BitmapColorMode.POLY2); XBitmapNight.SetNewColors(colNightColor); break; case ColorType.BM_Day2_Night1: // 3 Farben + 1x Pixeldaten colDayColor = BinaryColor.ReadColorTable(br, 2); colNightColor[0] = BinaryColor.ReadColor(br); colNightColor[1] = PixMap.TransparentColor; XBitmapDay = new PixMap(32, 32, colDayColor, BitmapColorMode.POLY2, br); XBitmapNight = new PixMap(XBitmapDay); XBitmapNight.ChangeColorMode(BitmapColorMode.POLY1TR); XBitmapNight.SetNewColors(colNightColor); break; case ColorType.BM_Day1: // 1 Farbe + 1x Pixeldaten colDayColor[0] = colNightColor[0] = BinaryColor.ReadColor(br); colDayColor[1] = colNightColor[1] = PixMap.TransparentColor; XBitmapDay = new PixMap(32, 32, colDayColor, BitmapColorMode.POLY1TR, br); break; case ColorType.BM_Day1_Night1: // 2 Farben + 1x Pixeldaten colDayColor[0] = BinaryColor.ReadColor(br); colDayColor[1] = PixMap.TransparentColor; colNightColor[0] = BinaryColor.ReadColor(br); colNightColor[1] = PixMap.TransparentColor; XBitmapDay = new PixMap(32, 32, colDayColor, BitmapColorMode.POLY1TR, br); XBitmapNight = new PixMap(XBitmapDay); XBitmapNight.SetNewColors(colNightColor); break; } if (WithDayBitmap) { // sicherheitshalber nochmal die Bitmapfarben übernehmen DayColor1 = XBitmapDay.GetColor(0); if (XBitmapDay.Colors > 1) { DayColor2 = XBitmapDay.GetColor(1); } if (XBitmapNight != null) { NightColor1 = XBitmapNight.GetColor(0); if (XBitmapNight.Colors > 1) { NightColor2 = XBitmapNight.GetColor(1); } } } if (WithString) { Text = new MultiText(br); } if (WithExtendedOptions) // es folgen weitere (max. 2) Farben { ExtOptions = br.ReadByte(); switch (FontColType) { case FontColours.Day: colFontColour[0] = BinaryColor.ReadColor(br); break; case FontColours.Night: colFontColour[1] = BinaryColor.ReadColor(br); break; case FontColours.DayAndNight: colFontColour = BinaryColor.ReadColorTable(br, 2); break; } } } catch (Exception ex) { throw new Exception(string.Format("Fehler beim Lesen des Polygons 0x{0:x} 0x{1:x}: {2}", Type, Subtype, ex.Message)); } }
public override void ReadHeader(BinaryReaderWriter br) { base.ReadCommonHeader(br, Type); if (Unknown_0x0C != 0x01) // Bedeutung unklar { throw new Exception("Das ist keine Garmin-TYP-Datei."); } Headertyp htyp = Headertyp.Unknown; Codepage = br.Read2AsUShort(); // Infos zu den Datenblöcken für POI, Polyline und Polygon einlesen (Offset, Länge) // (eigentlich uninteressant, da auf die Daten über die entsprechenden Tabellen zugegriffen wird) PointDatablock.Read(br); PolylineDatablock.Read(br); PolygoneDatablock.Read(br); FamilyID = br.Read2AsUShort(); ProductID = br.Read2AsUShort(); // Infos zu den Tabellen für POI, Polyline und Polygon einlesen (Offset, Länge, Länge der Tabelleneinträge) PointTableBlock = new TypDataBlockWithRecordsize(br); PolylineTableBlock = new TypDataBlockWithRecordsize(br); PolygoneTableBlock = new TypDataBlockWithRecordsize(br); PolygoneDraworderTableBlock = new TypDataBlockWithRecordsize(br); htyp = Headertyp.Standard; // ev. kommt noch NT-Zeugs if (Headerlength > 0x5b) // Extra icons { htyp = Headertyp.Type_6E; // spez. Daten für NT1-Punkte NT_PointTableBlock = new TypDataBlockWithRecordsize(br); nt_unknown_0x65 = br.ReadByte(); // sollte wohl immer 0x1F sein (?), auch 0x0D NT_PointDatablock.Read(br); if (Headerlength > 0x6e) // Extra POI Labels { htyp = Headertyp.Type_9C; nt_unknown_0x6E = br.Read4UInt(); // 0 NT_PointLabelblock.Read(br); // Block-Offset und -Länge nt_unknown_0x7A = br.Read4UInt(); // 6 Datensatzlänge? nt_unknown_0x7E = br.Read4UInt(); // 0x1B NT_LabelblockTable1.Read(br); nt_unknown_0x8A = br.Read4UInt(); // 6 nt_unknown_0x8E = br.Read4UInt(); // 0x1B NT_LabelblockTable2.Read(br); nt_unknown_0x9A = br.Read2AsUShort(); // 0x12 if (Headerlength > 0x9C) // Indexing a selection of POIs { htyp = Headertyp.Type_A4; br.ReadBytes(nt_unknown_0x9C); // scheint nochmal der gleiche Datenblock wie LabelblockTable2 zu sein if (Headerlength > 0xA4) // Active Routing { htyp = Headertyp.Type_AE; br.ReadBytes(nt_unknown_0xA4); if (Headerlength > 0xAE) { htyp = Headertyp.Unknown; nt_unknown_0xA4 = br.ReadBytes(Headerlength - (int)br.Position); // Rest einlesen } } } } } _HeaderTyp = htyp; }