public override void Read(string file) { // It's compressed pluginHost.Decompress(file); string dec_file; sFolder dec_folder = pluginHost.Get_Files(); if (dec_folder.files is List <sFile> ) { dec_file = dec_folder.files[0].path; } else { string tempFile = Path.GetTempFileName(); Byte[] compressFile = new Byte[(new FileInfo(file).Length) - 0x08]; Array.Copy(File.ReadAllBytes(file), 0x08, compressFile, 0, compressFile.Length);; File.WriteAllBytes(tempFile, compressFile); pluginHost.Decompress(tempFile); dec_file = pluginHost.Get_Files().files[0].path; } BinaryReader br = new BinaryReader(File.OpenRead(dec_file)); NTFS[] map = new NTFS[br.BaseStream.Length / 2]; for (int i = 0; i < map.Length; i++) { map[i] = Actions.MapInfo(br.ReadUInt16()); } br.Close(); Set_Map(map, false, 0x100, 0x100); pluginHost.Set_Map(this); }
public override void Read(string file) { // It's compressed pluginHost.Decompress(file); string dec_file; sFolder dec_folder = pluginHost.Get_Files(); if (dec_folder.files is List<sFile>) dec_file = dec_folder.files[0].path; else { string tempFile = Path.GetTempFileName(); Byte[] compressFile = new Byte[(new FileInfo(file).Length) - 0x08]; Array.Copy(File.ReadAllBytes(file), 0x08, compressFile, 0, compressFile.Length); ; File.WriteAllBytes(tempFile, compressFile); pluginHost.Decompress(tempFile); dec_file = pluginHost.Get_Files().files[0].path; } BinaryReader br = new BinaryReader(File.OpenRead(dec_file)); NTFS[] map = new NTFS[br.BaseStream.Length / 2]; for (int i = 0; i < map.Length; i++) map[i] = Actions.MapInfo(br.ReadUInt16()); br.Close(); Set_Map(map, false, 0x100, 0x100); pluginHost.Set_Map(this); }
public override void Read(string file) { BinaryReader br = new BinaryReader(File.OpenRead(file)); scx = new sSCx(); scx.type = br.ReadChars(4); scx.unknown1 = br.ReadUInt32(); scx.unknown2 = br.ReadUInt32(); scx.unknown3 = br.ReadUInt32(); // Usually 0x00 scx.unknown4 = br.ReadUInt32(); ushort width = br.ReadUInt16(); ushort height = br.ReadUInt16(); scx.size_mapData2 = br.ReadUInt32(); // Is alway the same? scx.size_mapData = br.ReadUInt32(); NTFS[] map = new NTFS[scx.size_mapData / 2]; for (int i = 0; i < map.Length; i++) { map[i] = Actions.MapInfo(br.ReadUInt16()); } br.Close(); Set_Map(map, false, width, height); }
public void Get_Image(string fileIn) { BinaryReader br = new BinaryReader(File.OpenRead(fileIn)); // Palette uint num_colors = br.ReadUInt32(); Color[][] colors = new Color[1][]; colors[0] = Actions.BGR555ToColor(br.ReadBytes((int)num_colors * 2)); // Image data uint num_tiles = /*(ushort)*/ br.ReadUInt32(); byte[] tiles = br.ReadBytes((int)num_tiles * 0x40); // Map Info ushort width = (ushort)(br.ReadUInt16() * 8); ushort height = (ushort)(br.ReadUInt16() * 8); NTFS[] map = new NTFS[width * height / 0x40]; for (int i = 0; i < map.Length; i++) { map[i] = Actions.MapInfo(br.ReadUInt16()); } br.Close(); palette = new RawPalette(colors, true, ColorFormat.colors256); image = new RawImage(tiles, TileForm.Horizontal, ColorFormat.colors256, width, height, true); Set_Map(map, true, width, height); }
public bool ProcessFile(string filePath) { long ms = (long)NTFS.InfoFromPath(filePath); if (ms >= 0) { TermQuery q = new TermQuery(new Term("path", filePath)); TopDocs hits = _index_searcher.Search(q, 1); if (hits.totalHits >= 1) { Document doc = _index_searcher.Doc(hits.scoreDocs.First().doc); System.String mod = doc.Get("modified"); bool bypass = (mod == DateTools.TimeToString((long)ms, DateTools.Resolution.MINUTE)); if (!bypass) { _upd_file_list.Add(new BasicFileInfo(filePath, ms)); } } else { _add_file_list.Add(new BasicFileInfo(filePath, ms)); } } return(true); }
public void Read(string fileIn, int offset, int size, bool editable) { BinaryReader br = new BinaryReader(File.OpenRead(fileIn)); prev_data = br.ReadBytes(offset); int file_size; if (size <= 0) { file_size = (int)br.BaseStream.Length; } else { file_size = size; } NTFS[] map = new NTFS[file_size / 2]; for (int i = 0; i < map.Length; i++) { map[i] = Actions.MapInfo(br.ReadUInt16()); } next_data = br.ReadBytes((int)(br.BaseStream.Length - file_size)); int width = (map.Length * 8 >= 0x100 ? 0x100 : map.Length * 8); int height = (map.Length / (width / 8)) * 8; br.Close(); Set_Map(map, editable, width, height); }
private void поискToolStripMenuItem_Click(object sender, EventArgs e) { if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) // Если выбрали катало { string fileName = folderBrowserDialog1.SelectedPath; // путь к выбранному каталогу string[] catalogs = fileName.Split(new char[] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries); //Разбиваем полный путь на имена каталогов NTFS ntfs = new NTFS(catalogs[0]); // создаем объектное представление файловой системы логического диска int nextRecord = 5; // 5 запись -- корневой каталог, поиск начинаем с него MFT root; // переменная для хранения текущего каталога for (int i = 1; i < catalogs.Length; i++) { root = ntfs.GetMftRecord(nextRecord); // читаем следующую запись МФТ со всеми аттрибутами, включая INDEX_ROOT и INDEX_ALLOCATION nextRecord = FoundSubdir(root, catalogs[i]); // Ищем номер записи МФТ следующего каталога } MFT catalog = ntfs.GetMftRecord(nextRecord); // Читаем запись найденного каталога display = new List <DisplayMFT>(); display.Add(new DisplayMFT(catalog)); // Первым отображается запись самого каталога foreach (var index in catalog.Indexes) { display.Add(new DisplayMFT(ntfs.GetMftRecord((int)index.IndexedFile))); // добавляем в отображаемые записи сведения о файле в каталоге } dataGridView1.DataSource = null; dataGridView1.DataSource = display; // выводим данные в таблицу } }
public void Test() { for (int i = 0; i < testfiles.Length; i++) { string location = Path.Combine(Consts.TestFilesRoot, "filesystems", "ntfs_gpt", testfiles[i]); IFilter filter = new LZip(); filter.Open(location); IMediaImage image = new Vdi(); Assert.AreEqual(true, image.Open(filter), testfiles[i]); Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]); Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]); List <Partition> partitions = Core.Partitions.GetAll(image); IFilesystem fs = new NTFS(); int part = -1; for (int j = 0; j < partitions.Count; j++) { if (partitions[j].Type == "Microsoft Basic data") { part = j; break; } } Assert.AreNotEqual(-1, part, $"Partition not found on {testfiles[i]}"); Assert.AreEqual(true, fs.Identify(image, partitions[part]), testfiles[i]); fs.GetInformation(image, partitions[part], out _, null); Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]); Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]); Assert.AreEqual("NTFS", fs.XmlFsType.Type, testfiles[i]); Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]); Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSerial, testfiles[i]); Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]); } }
public static NTFS GetInstance(string path, string DS_Type) { if (instance == null) { instance = new NTFS(path, DS_Type); } return instance; }
public override void Read(string fileIn) { BinaryReader br = new BinaryReader(File.OpenRead(fileIn)); br.ReadChars(4); // MAP\0 uint map_size = br.ReadUInt32(); br.BaseStream.Position = 0x10; int width = br.ReadUInt16(); int height = br.ReadUInt16(); int tile_width = br.ReadUInt16(); int tile_height = br.ReadUInt16(); if (tile_height != tile_width) { System.Windows.Forms.MessageBox.Show("Tile dimension doesn't agree!\nWidth:" + tile_width.ToString() + " Height: " + tile_height.ToString()); } width *= tile_width; height *= tile_height; br.BaseStream.Position = 0x20; NTFS[] map = new NTFS[(map_size - 0x20) / 2]; for (int i = 0; i < map.Length; i++) { map[i] = Actions.MapInfo(br.ReadUInt16()); map[i].nPalette = 0; } // Get the IMY data br.BaseStream.Position = map_size; byte[] imy = br.ReadBytes((int)(br.BaseStream.Length - map_size)); br.Close(); string imy_file = pluginHost.Get_TempFolder() + Path.DirectorySeparatorChar + Path.GetRandomFileName(); File.WriteAllBytes(imy_file, imy); // Read the file new IMY(pluginHost, imy_file, id, fileName); // Change some image parameters ImageBase img = pluginHost.Get_Image(); int tile_size = tile_width * tile_height * img.BPP / 8; // Set a zero tile in the beggining byte[] newTiles = new byte[img.Tiles.Length + tile_size]; Array.Copy(img.Tiles, 0, newTiles, tile_size, img.Tiles.Length); img.Set_Tiles(newTiles); img.TileSize = tile_width; img.FormTile = TileForm.Horizontal; pluginHost.Set_Image(img); Set_Map(map, false, width, height); pluginHost.Set_Map(this); }
public override void Read(string fileIn) { BinaryReader br = new BinaryReader(File.OpenRead(fileIn)); uint header = br.ReadUInt32(); uint pal_length = br.ReadUInt32(); uint tile_length = br.ReadUInt32(); uint map_length = br.ReadUInt32(); ColorFormat depth = (pal_length < 0x200 ? ColorFormat.colors16 : ColorFormat.colors256); isMap = true; int width, height; if (header == 0x18) { width = (ushort)br.ReadUInt32(); height = (ushort)br.ReadUInt32(); } else { width = 0x200; height = 0xc0; isMap = false; } // Palette int num_colors = (depth == ColorFormat.colors16 ? 0x10 : 0x100); Color[][] colors = new Color[pal_length / (num_colors * 2)][]; for (int i = 0; i < colors.Length; i++) { colors[i] = Actions.BGR555ToColor(br.ReadBytes((int)(num_colors * 2))); } palette = new RawPalette(colors, false, depth, fileName); // Tile data Byte[] tiles = br.ReadBytes((int)tile_length); image = new RawImage(tiles, TileForm.Horizontal, depth, width, height, false, fileName); // Map if (isMap) { NTFS[] maps = new NTFS[map_length / 2]; for (int i = 0; i < maps.Length; i++) { maps[i] = Actions.MapInfo(br.ReadUInt16()); } Set_Map(maps, false); } br.Close(); }
public override void Read(string fileIn) { BinaryReader br = new BinaryReader(File.OpenRead(fileIn)); br.ReadChars(4); // MAP\0 uint map_size = br.ReadUInt32(); br.BaseStream.Position = 0x10; int width = br.ReadUInt16(); int height = br.ReadUInt16(); int tile_width = br.ReadUInt16(); int tile_height = br.ReadUInt16(); if (tile_height != tile_width) System.Windows.Forms.MessageBox.Show("Tile dimension doesn't agree!\nWidth:" + tile_width.ToString() + " Height: " + tile_height.ToString()); width *= tile_width; height *= tile_height; br.BaseStream.Position = 0x20; NTFS[] map = new NTFS[(map_size - 0x20) / 2]; for (int i = 0; i < map.Length; i++) { map[i] = Actions.MapInfo(br.ReadUInt16()); map[i].nPalette = 0; } // Get the IMY data br.BaseStream.Position = map_size; byte[] imy = br.ReadBytes((int)(br.BaseStream.Length - map_size)); br.Close(); string imy_file = pluginHost.Get_TempFolder() + Path.DirectorySeparatorChar + Path.GetRandomFileName(); File.WriteAllBytes(imy_file, imy); // Read the file new IMY(pluginHost, imy_file, id, fileName); // Change some image parameters ImageBase img = pluginHost.Get_Image(); int tile_size = tile_width * tile_height * img.BPP / 8; // Set a zero tile in the beggining byte[] newTiles = new byte[img.Tiles.Length + tile_size]; Array.Copy(img.Tiles, 0, newTiles, tile_size, img.Tiles.Length); img.Set_Tiles(newTiles); img.TileSize = tile_width; img.FormTile = TileForm.Horizontal; pluginHost.Set_Image(img); Set_Map(map, false, width, height); pluginHost.Set_Map(this); }
public override void Read(string fileIn) { BinaryReader br = new BinaryReader(File.OpenRead(fileIn)); char[] header = br.ReadChars(4); uint size = br.ReadUInt16(); NTFS[] map = new NTFS[(size + 2) / 2]; for (int i = 0; i < map.Length; i++) map[i] = Actions.MapInfo(br.ReadUInt16()); br.Close(); Set_Map(map, false, 0x100, 0xB0); }
public override void Read(string fileIn) { BinaryReader br = new BinaryReader(File.OpenRead(fileIn)); NTFS[] maps = new NTFS[br.BaseStream.Length / 2]; for (int i = 0; i < maps.Length; i++) { ushort v = br.ReadUInt16(); maps[i].nTile = (ushort)(v & 0x1FF); maps[i].nPalette = (byte)(v >> 14); } br.Close(); Set_Map(maps, false); }
public override void Read(string file) { BinaryReader br = new BinaryReader(File.OpenRead(file)); uint file_size = (uint)br.BaseStream.Length; ushort width = br.ReadUInt16(); ushort height = br.ReadUInt16(); NTFS[] map = new NTFS[(file_size - 4) / 2]; for (int i = 0; i < map.Length; i++) map[i] = Actions.MapInfo(br.ReadUInt16()); br.Close(); Set_Map(map, true, width * 8, height * 8); pluginHost.Set_Map(this); }
public override void Read(string fileIn) { BinaryReader br = new BinaryReader(File.OpenRead(fileIn)); char[] header = br.ReadChars(4); uint size = br.ReadUInt16(); NTFS[] map = new NTFS[(size + 2) / 2]; for (int i = 0; i < map.Length; i++) { map[i] = Actions.MapInfo(br.ReadUInt16()); } br.Close(); Set_Map(map, false, 0x100, 0xB0); }
public void FileProcessor1(bool isStart, bool isFinished, string filePath) { if (isStart) { OpenIndex(true); return; } if (isFinished) { writer.Commit(); CloseIndex(); return; } UInt64 ms = NTFS.InfoFromPath(filePath); if (ms >= 0) { num_indexed_file++; PerFieldAnalyzerWrapper analyzer = new PerFieldAnalyzerWrapper(new StandardAnalyzer()); analyzer.AddAnalyzer("contents", new SourceCodeAnalyzer()); analyzer.AddAnalyzer("path2", new PathAnalyzer()); //SourceCodeAnalyzer analyzer = new SourceCodeAnalyzer(); writer.AddDocument(FileDocument.Document(filePath, ms), analyzer); if (num_indexed_file % 20 == 1) { writer.Commit(); } } /* * lock (dispatch_queue) * { * if (dispatch_queue == null) * { * dispatch_queue = new Queue<string>(); * } * dispatch_queue.Enqueue(filePath); * } * */ }
public override void Read(string file) { BinaryReader br = new BinaryReader(File.OpenRead(file)); uint file_size = (uint)br.BaseStream.Length; ushort width = br.ReadUInt16(); ushort height = br.ReadUInt16(); NTFS[] map = new NTFS[(file_size - 4) / 2]; for (int i = 0; i < map.Length; i++) { map[i] = Actions.MapInfo(br.ReadUInt16()); } br.Close(); Set_Map(map, true, width * 8, height * 8); pluginHost.Set_Map(this); }
public override void Read(string fileIn) { BinaryReader br = new BinaryReader(File.OpenRead(fileIn)); // Header uint paletaOffset = br.ReadUInt32() * 4; uint tileOffset = br.ReadUInt32() * 4; uint mapOffset = br.ReadUInt32() * 4; // Paleta br.BaseStream.Position = paletaOffset; uint pCabeceraSize = br.ReadUInt32() * 4; uint pSize = br.ReadUInt32() * 4; Color[][] colors = new Color[1][]; colors[0] = Actions.BGR555ToColor(br.ReadBytes((int)(pSize - 0x08))); palette = new RawPalette(colors, false, ColorFormat.colors256); // Image data br.BaseStream.Position = tileOffset; uint tCabeceraSize = br.ReadUInt32() * 4; uint tSize = br.ReadUInt32() * 4; byte[] tiles = br.ReadBytes((int)(tSize - 0x08)); image = new RawImage(tiles, TileForm.Horizontal, ColorFormat.colors256, 256, 192, false); // Map br.BaseStream.Position = mapOffset; uint mCabeceraSize = br.ReadUInt32() * 4; uint mSize = br.ReadUInt32() * 4; ushort width = br.ReadUInt16(); ushort height = br.ReadUInt16(); NTFS[] map = new NTFS[(mSize - 0x08) / 2]; for (int i = 0; i < map.Length; i++) { map[i] = Actions.MapInfo(br.ReadUInt16()); } br.Close(); Set_Map(map, false, width * 8, height * 8); }
public bool ProcessFile(string filePath) { long ms = (long)NTFS.InfoFromPath(filePath); if (ms >= 0) { Logger.Log.Info("Indexing " + filePath); Document doc = _doc_factory.CreateFromPath(filePath, ms); if (doc != null) { _nb_indexed++; _writer.AddDocument(doc, _default_analyzer); if (_nb_indexed % 20 == 1) { _writer.Commit(); } } } return(true); }
public void Test() { for (int i = 0; i < _testFiles.Length; i++) { string location = Path.Combine(Consts.TEST_FILES_ROOT, "Filesystems", "New Technology File System (MBR)", _testFiles[i]); IFilter filter = new ZZZNoFilter(); filter.Open(location); IMediaImage image = new AaruFormat(); Assert.AreEqual(true, image.Open(filter), _testFiles[i]); Assert.AreEqual(_sectors[i], image.Info.Sectors, _testFiles[i]); Assert.AreEqual(_sectorSize[i], image.Info.SectorSize, _testFiles[i]); List <Partition> partitions = Core.Partitions.GetAll(image); IFilesystem fs = new NTFS(); int part = -1; for (int j = 0; j < partitions.Count; j++) { if (partitions[j].Type == "0x07" || // Value incorrectly set by Haiku partitions[j].Type == "0x86") { part = j; break; } } Assert.AreNotEqual(-1, part, $"Partition not found on {_testFiles[i]}"); Assert.AreEqual(true, fs.Identify(image, partitions[part]), _testFiles[i]); fs.GetInformation(image, partitions[part], out _, null); Assert.AreEqual(_clusters[i], fs.XmlFsType.Clusters, _testFiles[i]); Assert.AreEqual(_clusterSize[i], fs.XmlFsType.ClusterSize, _testFiles[i]); Assert.AreEqual("NTFS", fs.XmlFsType.Type, _testFiles[i]); Assert.AreEqual(_volumeName[i], fs.XmlFsType.VolumeName, _testFiles[i]); Assert.AreEqual(_volumeSerial[i], fs.XmlFsType.VolumeSerial, _testFiles[i]); Assert.AreEqual(_oemId[i], fs.XmlFsType.SystemIdentifier, _testFiles[i]); } }
public override void Read(string file) { BinaryReader br = new BinaryReader(File.OpenRead(file)); scx = new sSCx(); scx.type = br.ReadChars(4); scx.unknown1 = br.ReadUInt32(); scx.unknown2 = br.ReadUInt32(); scx.unknown3 = br.ReadUInt32(); // Usually 0x00 scx.unknown4 = br.ReadUInt32(); ushort width = br.ReadUInt16(); ushort height = br.ReadUInt16(); scx.size_mapData2 = br.ReadUInt32(); // Is alway the same? scx.size_mapData = br.ReadUInt32(); NTFS[] map = new NTFS[scx.size_mapData / 2]; for (int i = 0; i < map.Length; i++) map[i] = Actions.MapInfo(br.ReadUInt16()); br.Close(); Set_Map(map, false, width, height); }
private System.Windows.Forms.Control ShowImage(sFile file) { #region Palette BinaryReader br = new BinaryReader(File.OpenRead(file.path)); br.ReadUInt32(); // 4 Bytes Stupid uint num_colors = 256; byte[] pal = br.ReadBytes((int)num_colors * 2); Color[] colors = Actions.BGR555ToColor(pal); PaletteBase palette = new RawPalette(colors, false, ColorFormat.colors256, file.name); br.ReadUInt32(); // 4 Bytes Stupid #endregion #region Map NTFS[] map_info = new NTFS[1024]; for (int i = 0; i < 1024; i++) { ushort value = br.ReadUInt16(); map_info[i] = Actions.MapInfo(value); } MapBase map = new RawMap(map_info, 256, 192, false, file.name); #endregion #region Tiles uint size_section = (uint)(br.ReadUInt32() * 64); Console.WriteLine("Size section: " + size_section.ToString("x")); byte[] readsize = br.ReadBytes((int)size_section); ImageBase image = new RawImage(readsize, TileForm.Horizontal, ColorFormat.colors256, 256, 192, false, file.name); #endregion br.Close(); pluginHost.Set_Palette(palette); pluginHost.Set_Image(image); pluginHost.Set_Map(map); return(new ImageControl(pluginHost, image, palette, map)); }
public void Read(string file) { BinaryReader br = new BinaryReader(File.OpenRead(file)); if (br.ReadUInt32() != MagicStamp) { throw new InvalidDataException(); } this.NumberImages = br.ReadUInt16(); this.images = new GameImage[this.NumberImages]; for (int i = 0; i < this.NumberImages; i++) { this.images[i] = new GameImage(); br.BaseStream.Position = 6 + i * HeaderSize; int imageOffset = br.ReadUInt16() * Padding; int imageSize = br.ReadUInt16() * Padding; int palOffset = br.ReadUInt16() * Padding; int palNumber = br.ReadUInt16(); int mapOffset = br.ReadUInt16() * Padding; int tilesX = br.ReadUInt16(); int tilesY = br.ReadUInt16(); int mapType = br.ReadUInt16(); // Set map br.BaseStream.Position = mapOffset; NTFS[] map = new NTFS[tilesX * tilesY]; bool multiPalette = false; for (int m = 0; m < map.Length; m++) { if (mapType == 0) { map[m] = Actions.MapInfo(br.ReadUInt16()); } else { ushort v1 = br.ReadUInt16(); ushort v2 = br.ReadUInt16(); map[m].nPalette = (byte)v2; map[m].nTile = v1; } if (map[m].nPalette != 0) { multiPalette = true; } } this.images[i].Map = new RawMap(map, tilesX * 8, tilesY * 8, false, this.Name); ColorFormat depth; int palSize; if (!multiPalette && palNumber == 0x10) { depth = ColorFormat.colors256; palSize = 0x200; palNumber = 1; } else { depth = ColorFormat.colors16; palSize = 0x20; } // Set palette br.BaseStream.Position = palOffset; Color[][] colors = new Color[palNumber][]; for (int p = 0; p < palNumber; p++) { colors[p] = Actions.BGR555ToColor(br.ReadBytes(palSize)); } this.images[i].Palette = new RawPalette(colors, false, depth, this.Name); // Set image br.BaseStream.Position = imageOffset; byte[] imgData = br.ReadBytes(imageSize); this.images[i].Image = new RawImage( imgData, TileForm.Horizontal, depth, 0x100, imgData.Length * (depth == ColorFormat.colors16 ? 2 : 1) / 0x100, false, this.Name); } br.Close(); br = null; }
public static NTFS[] Create_BasicMap(int num_tiles, int startTile = 0, byte palette = 0) { NTFS[] map = new NTFS[num_tiles]; for (int i = startTile; i < num_tiles; i++) { map[i] = new NTFS(); map[i].nPalette = palette; map[i].yFlip = 0; map[i].xFlip = 0; //if (i >= startFillTile) // map[i].nTile = (ushort)fillTile; //else map[i].nTile = (ushort)(i + startTile); } return map; }
public static NTFS[] Create_Map(ref byte[] data, int bpp, int tile_size, byte palette = 0) { int ppt = tile_size * tile_size; // pixels per tile int tile_length = ppt * bpp / 8; // Divide the data in tiles byte[][] tiles = new byte[data.Length / tile_length][]; for (int i = 0; i < tiles.Length; i++) { tiles[i] = new byte[tile_length]; Array.Copy(data, i * tiles[i].Length, tiles[i], 0, tiles[i].Length); } NTFS[] map = new NTFS[tiles.Length]; List<byte[]> newtiles = new List<byte[]>(); for (int i = 0; i < map.Length; i++) { map[i].nPalette = palette; map[i].xFlip = 0; map[i].yFlip = 0; int index = -1; byte flipX = 0; byte flipY = 0; for (ushort t = 0; t < newtiles.Count; t++) { if (Compare_Array(newtiles[t], tiles[i])) { index = t; break; } if (Compare_Array(newtiles[t], XFlip(tiles[i], tile_size, bpp))) { index = t; flipX = 1; break; } if (Compare_Array(newtiles[t], YFlip(tiles[i], tile_size, bpp))) { index = t; flipY = 1; break; } if (Compare_Array(newtiles[t], YFlip(XFlip(tiles[i], tile_size, bpp), tile_size, bpp))) { index = t; flipX = 1; flipY = 1; break; } } if (index > -1) map[i].nTile = (ushort)index; else { map[i].nTile = (ushort)newtiles.Count; newtiles.Add(tiles[i]); } map[i].xFlip = flipX; map[i].yFlip = flipY; } // Save the new tiles data = new byte[newtiles.Count * tile_length]; for (int i = 0; i < newtiles.Count; i++) for (int j = 0; j < newtiles[i].Length; j++) data[j + i * tile_length] = newtiles[i][j]; return map; }
public static ushort MapInfo(NTFS map) { int npalette = map.nPalette << 12; int yFlip = map.yFlip << 11; int xFlip = map.xFlip << 10; int data = npalette + yFlip + xFlip + map.nTile; return (ushort)data; }
public static Byte[] Apply_Map(NTFS[] map, Byte[] tiles, out Byte[] tile_pal, int bpp, int tile_size, int startInfo = 0) { int tile_length = tile_size * tile_size * bpp / 8; int num_tiles = tiles.Length / tile_length; List<Byte> bytes = new List<byte>(); tile_pal = new byte[(map.Length - startInfo) * tile_size * tile_size]; for (int i = startInfo; i < map.Length; i++) { if (map[i].nTile >= num_tiles) map[i].nTile = 0; Byte[] currTile = new byte[tile_length]; if (map[i].nTile * tile_length + tile_length > tiles.Length) map[i].nTile = 0; if (tile_length < tiles.Length) Array.Copy(tiles, map[i].nTile * tile_length, currTile, 0, tile_length); if (map[i].xFlip == 1) currTile = XFlip(currTile, tile_size, bpp); if (map[i].yFlip == 1) currTile = YFlip(currTile, tile_size, bpp); bytes.AddRange(currTile); for (int t = 0; t < tile_size * tile_size; t++) tile_pal[i * tile_size * tile_size + t] = map[i].nPalette; } return bytes.ToArray(); }
public static NTFS MapInfo(ushort value) { NTFS mapInfo = new NTFS(); mapInfo.nTile = (ushort)(value & 0x3FF); mapInfo.xFlip = (byte)((value >> 10) & 1); mapInfo.yFlip = (byte)((value >> 11) & 1); mapInfo.nPalette = (byte)((value >> 12) & 0xF); return mapInfo; }
public void Read12(string fileIn) { BinaryReader br = new BinaryReader(File.OpenRead(fileIn)); // Read header ushort bpp = br.ReadUInt16(); int width = br.ReadByte() * 8; int height = br.ReadByte() * 8; ushort map_offset = br.ReadUInt16(); ushort map_size = br.ReadUInt16(); ushort data_offset = br.ReadUInt16(); ushort data_size = br.ReadUInt16(); ushort pal_offset = br.ReadUInt16(); ushort pal_size = br.ReadUInt16(); // Read map br.BaseStream.Position = map_offset; NTFS[] map = new NTFS[map_size / 2]; for (int i = 0; i < map.Length; i++) { map[i] = Actions.MapInfo(br.ReadUInt16()); } Set_Map(map, false, width, height); // Read image data ColorFormat format = ColorFormat.colors256; if (bpp == 0x12 || bpp == 0x1A) { format = ColorFormat.colors16; } else if (bpp == 0x10 || bpp == 0x18) { format = ColorFormat.colors256; } br.BaseStream.Position = data_offset; byte[] data = br.ReadBytes(data_size); Encryption enc = new Encryption(data); data = enc.Decrypt(); img = new RawImage(data, TileForm.Horizontal, format, width, height, false); // Read palette if ((bpp == 0x18 || bpp == 0x1A) && pluginHost.Get_Palette().Loaded) { pal = pluginHost.Get_Palette(); } else { br.BaseStream.Position = pal_offset; Color[] colors = Actions.BGR555ToColor(br.ReadBytes(pal_size)); pal = new RawPalette(new Color[][] { colors }, false, ColorFormat.colors16); } br.Close(); ismap = true; Console.WriteLine("Image with bpp: {0}", bpp.ToString("x")); }
public override void Read(string fileIn) { BinaryReader br = new BinaryReader(File.OpenRead(fileIn)); uint header = br.ReadUInt32(); uint pal_length = br.ReadUInt32(); uint tile_length = br.ReadUInt32(); uint map_length = br.ReadUInt32(); ColorFormat depth = (pal_length < 0x200 ? ColorFormat.colors16 : ColorFormat.colors256); isMap = true; int width, height; if (header == 0x18) { width = (ushort)br.ReadUInt32(); height = (ushort)br.ReadUInt32(); } else { width = 0x200; height = 0xc0; isMap = false; } // Palette int num_colors = (depth == ColorFormat.colors16 ? 0x10 : 0x100); Color[][] colors = new Color[pal_length / (num_colors * 2)][]; for (int i = 0; i < colors.Length; i++) colors[i] = Actions.BGR555ToColor(br.ReadBytes((int)(num_colors * 2))); palette = new RawPalette(colors, false, depth, fileName); // Tile data Byte[] tiles = br.ReadBytes((int)tile_length); image = new RawImage(tiles, TileForm.Horizontal, depth, width, height, false, fileName); // Map if (isMap) { NTFS[] maps = new NTFS[map_length / 2]; for (int i = 0; i < maps.Length; i++) maps[i] = Actions.MapInfo(br.ReadUInt16()); Set_Map(maps, false); } br.Close(); }
public void Read12(string fileIn) { BinaryReader br = new BinaryReader(File.OpenRead(fileIn)); // Read header ushort bpp = br.ReadUInt16(); int width = br.ReadByte() * 8; int height = br.ReadByte() * 8; ushort map_offset = br.ReadUInt16(); ushort map_size = br.ReadUInt16(); ushort data_offset = br.ReadUInt16(); ushort data_size = br.ReadUInt16(); ushort pal_offset = br.ReadUInt16(); ushort pal_size = br.ReadUInt16(); // Read map br.BaseStream.Position = map_offset; NTFS[] map = new NTFS[map_size / 2]; for (int i = 0; i < map.Length; i++) map[i] = Actions.MapInfo(br.ReadUInt16()); Set_Map(map, false, width, height); // Read image data ColorFormat format = ColorFormat.colors256; if (bpp == 0x12 || bpp == 0x1A) format = ColorFormat.colors16; else if (bpp == 0x10 || bpp == 0x18) format = ColorFormat.colors256; br.BaseStream.Position = data_offset; byte[] data = br.ReadBytes(data_size); Encryption enc = new Encryption(data); data = enc.Decrypt(); img = new RawImage(data, TileForm.Horizontal, format, width, height, false); // Read palette if ((bpp == 0x18 || bpp == 0x1A) && pluginHost.Get_Palette().Loaded) pal = pluginHost.Get_Palette(); else { br.BaseStream.Position = pal_offset; Color[] colors = Actions.BGR555ToColor(br.ReadBytes(pal_size)); pal = new RawPalette(new Color[][] { colors }, false, ColorFormat.colors16); } br.Close(); ismap = true; Console.WriteLine("Image with bpp: {0}", bpp.ToString("x")); }
public void DoEnumerate(Object _params) { Params myparams = (_params as Params); string[] ntfs_disks = myparams.localDrives.Split(','); string[] extensions = myparams.extensions.Split(','); JobStatus status = myparams.jobStatus; if (status == null) { status = new JobStatus("NtfsEnum"); } Stopwatch watch = myparams.jobWatch; if (watch == null) { watch = new Stopwatch(); watch.Start(); } foreach (string disk_letter in ntfs_disks) { if (disk_letter.Trim().Length == 0) { continue; } if (status.Cancelled) { break; } Dictionary <UInt64, FileNameAndFrn> result = null; NTFS ntfs = new NTFS(); status.Description = string.Format("listing ntfs journal on {0}...", disk_letter); ntfs.Drive = disk_letter;// "D:"; try { ntfs.EnumerateVolume(out result, extensions); /*new string[] {".bab" }); * { ".h", "*.hpp", "*.inl", "*.c", "*.cpp", ".txt", ".cs", "*.htm*", "*.ini", * "*.xml", "*.rtf", "*.doc" * });*/ } catch (Win32Exception win32_e) { win32_e = win32_e; } catch (Exception e) { e = e; } //status.Description = string.Format("listed {0} files for processing in {1} on {2}", result.Count, watch.ElapsedMilliseconds / 1000.0, disk_letter); int num_file = 0; bool should_close; myparams.fileProcessor.Start(out should_close); if (result != null) { foreach (KeyValuePair <UInt64, FileNameAndFrn> entry in result) { if (status.Cancelled) { break; } FileNameAndFrn file = (FileNameAndFrn)entry.Value; string full_path = ntfs.DirectoryFromFrn(file.ParentFrn) + @"\" + file.Name; full_path = full_path.Substring(4); myparams.fileProcessor.ProcessFile(full_path); num_file++; if ((num_file % 101) == 1) { status.Progress = (num_file * 100) / result.Count; status.Description = string.Format("ntfs on {3} processing file {0}/{1} - {2}", num_file, result.Count, StringFu.TimeSpanToString(new TimeSpan((long)(watch.ElapsedMilliseconds) * 10000)), disk_letter); } } } myparams.fileProcessor.End(should_close); string info = string.Format("ntfs file enum: {0} files - {1}", result.Count, watch.ElapsedMilliseconds / 1000.0); Console.WriteLine(info); //status.Description = info; } if (myparams.jobStatus == null) { status.RemoveFromQueue(); status = null; } if (myparams.jobWatch == null) { watch = null; } }
public override void Read(string fileIn) { BinaryReader br = new BinaryReader(File.OpenRead(fileIn)); // Header char[] type = br.ReadChars(4); // "STD " uint unknown_header = br.ReadUInt32(); ushort clrformat = br.ReadUInt16(); ColorFormat format = ColorFormat.colors256; if (clrformat == 0) format = ColorFormat.colors16; br.BaseStream.Position = 0x10; // Unknown values // Palette ushort unknown_pal = br.ReadUInt16(); ushort num_colors = br.ReadUInt16(); Color[] colors = Actions.BGR555ToColor(br.ReadBytes(num_colors * 2)); PaletteBase palette = new RawPalette(new Color[][] { colors }, false, format); // Map int tile_width = br.ReadUInt16() * 8; int tile_height = br.ReadUInt16() * 8; int tile_size = tile_width * tile_height; if (tile_height != tile_width) System.Windows.Forms.MessageBox.Show("Different tile size; height != width"); int width = br.ReadUInt16() * tile_width; int height = br.ReadUInt16() * tile_height; uint unknown2_map = br.ReadUInt32(); // Padding ? NTFS[] map = new NTFS[width * height / tile_size]; for (int i = 0; i < map.Length; i++) { map[i] = new NTFS(); uint mapv = br.ReadUInt32(); map[i].nTile = (ushort)(mapv & 0xFFFFFF); map[i].nTile /= (ushort)(tile_size / 0x40); map[i].nPalette = (byte)(mapv >> 28); } Set_Map(map, false, width, height); // Image if (clrformat == 2) format = ColorFormat.A3I5; else if (clrformat == 3) format = ColorFormat.A5I3; else if (clrformat != 0 && clrformat != 1) System.Windows.Forms.MessageBox.Show("ClrFormat: " + clrformat.ToString()); byte[] tiles = br.ReadBytes((int)(br.BaseStream.Length - br.BaseStream.Position)); ImageBase image = new RawImage(tiles, TileForm.Horizontal, format, width, height, false); image.TileSize = tile_width; br.Close(); pluginHost.Set_Palette(palette); pluginHost.Set_Image(image); pluginHost.Set_Map(this); }
public override void Read(string fileIn) { BinaryReader br = new BinaryReader(File.OpenRead(fileIn)); // Header uint paletaOffset = br.ReadUInt32() * 4; uint tileOffset = br.ReadUInt32() * 4; uint mapOffset = br.ReadUInt32() * 4; // Paleta br.BaseStream.Position = paletaOffset; uint pCabeceraSize = br.ReadUInt32() * 4; uint pSize = br.ReadUInt32() * 4; Color[][] colors = new Color[1][]; colors[0] = Actions.BGR555ToColor(br.ReadBytes((int)(pSize - 0x08))); palette = new RawPalette(colors, false, ColorFormat.colors256); // Image data br.BaseStream.Position = tileOffset; uint tCabeceraSize = br.ReadUInt32() * 4; uint tSize = br.ReadUInt32() * 4; byte[] tiles = br.ReadBytes((int)(tSize - 0x08)); image = new RawImage(tiles, TileForm.Horizontal, ColorFormat.colors256, 256, 192, false); // Map br.BaseStream.Position = mapOffset; uint mCabeceraSize = br.ReadUInt32() * 4; uint mSize = br.ReadUInt32() * 4; ushort width = br.ReadUInt16(); ushort height = br.ReadUInt16(); NTFS[] map = new NTFS[(mSize - 0x08) / 2]; for (int i = 0; i < map.Length; i++) map[i] = Actions.MapInfo(br.ReadUInt16()); br.Close(); Set_Map(map, false, width * 8, height * 8); }
public override void Read(string file) { BinaryReader br = new BinaryReader(File.OpenRead(file)); sNCSC ncsc = new sNCSC(); // Nitro generic header ncsc.generic.id = br.ReadChars(4); ncsc.generic.endianess = br.ReadUInt16(); ncsc.generic.constant = br.ReadUInt16(); ncsc.generic.file_size = br.ReadUInt32(); ncsc.generic.header_size = br.ReadUInt16(); ncsc.generic.nSection = br.ReadUInt16(); // SCRN section ncsc.scrn.id = br.ReadChars(4); ncsc.scrn.size = br.ReadUInt32(); ncsc.scrn.width = br.ReadUInt32() * 8; ncsc.scrn.height = br.ReadUInt32() * 8; ncsc.scrn.unknown1 = br.ReadUInt32(); ncsc.scrn.unknown2 = br.ReadUInt32(); NTFS[] map = new NTFS[(ncsc.scrn.size - 0x18) / 2]; for (int i = 0; i < map.Length; i++) { map[i] = Actions.MapInfo(br.ReadUInt16()); } // Read other sections for (int n = 1; n < ncsc.generic.nSection; n++) { String type = new String(br.ReadChars(4)); switch (type) { case "ESCR": ncsc.escr.id = "ESCR".ToCharArray(); ncsc.escr.size = br.ReadUInt32(); ncsc.escr.width = br.ReadUInt32(); ncsc.escr.height = br.ReadUInt32(); ncsc.escr.unknown = br.ReadUInt32(); ncsc.escr.unknown2 = br.ReadUInt32(); ncsc.escr.unknownData = new uint[ncsc.escr.width * ncsc.escr.height]; for (int i = 0; i < ncsc.escr.unknownData.Length; i++) { ncsc.escr.unknownData[i] = br.ReadUInt32(); } break; case "CLRF": ncsc.clrf.id = "CLRF".ToCharArray(); ncsc.clrf.size = br.ReadUInt32(); ncsc.clrf.width = br.ReadUInt32(); ncsc.clrf.height = br.ReadUInt32(); ncsc.clrf.unknown = br.ReadBytes((int)ncsc.clrf.size - 0x10); break; case "CLRC": ncsc.clrc.id = "CLRC".ToCharArray(); ncsc.clrc.size = br.ReadUInt32(); ncsc.clrc.unknown = br.ReadBytes((int)ncsc.clrc.size - 0x08); break; case "GRID": ncsc.grid.id = "GRID".ToCharArray(); ncsc.grid.size = br.ReadUInt32(); ncsc.grid.unknown = br.ReadBytes((int)ncsc.grid.size - 0x08); break; case "LINK": ncsc.link.id = "LINK".ToCharArray(); ncsc.link.size = br.ReadUInt32(); ncsc.link.link = new string(br.ReadChars((int)ncsc.link.size - 0x08)); break; case "CMNT": ncsc.cmnt.id = "CMNT".ToCharArray(); ncsc.cmnt.size = br.ReadUInt32(); ncsc.cmnt.unknown = br.ReadBytes((int)ncsc.cmnt.size - 0x08); break; } } br.Close(); Set_Map(map, false, (int)ncsc.scrn.width, (int)ncsc.scrn.height); }
public void Read(string file) { BinaryReader br = new BinaryReader(File.OpenRead(file)); // Header uint paletaOffset = br.ReadUInt32() * 4; uint tileOffset = br.ReadUInt32() * 4; uint mapOffset = br.ReadUInt32() * 4; ColorFormat depth; br.BaseStream.Position = mapOffset; if (br.ReadUInt32() == 0x01) depth = ColorFormat.colors256; else depth = ColorFormat.colors16; // Palette Color[][] colors; if (paletaOffset == 0x00) // No palette { depth = ColorFormat.colors16; colors = new Color[defaultPaletteData.Length / 0x20][]; for (int i = 0; i < colors.Length; i++) { Byte[] data = new Byte[0x20]; Array.Copy(defaultPaletteData, i * 0x20, data, 0, 0x20); colors[i] = Actions.BGR555ToColor(data); } goto Tile; } br.BaseStream.Position = paletaOffset; uint pCabeceraSize = br.ReadUInt32() * 4; uint pSize = br.ReadUInt32() * 4; if (pSize - 0x08 == 0x0200) depth = ColorFormat.colors256; else if (pSize - 0x08 == 0x20) depth = ColorFormat.colors16; colors = new Color[depth == ColorFormat.colors16 ? (pSize - 0x08) / 0x20 : 1][]; uint pal_length = (depth == ColorFormat.colors16) ? 0x20 : pSize - 0x08; for (int i = 0; i < colors.Length; i++) colors[i] = Actions.BGR555ToColor(br.ReadBytes((int)pal_length)); // Tile data Tile: br.BaseStream.Position = tileOffset; uint tCabeceraSize = br.ReadUInt32() * 4; uint tSize = br.ReadUInt32() * 4; byte[] tiles = br.ReadBytes((int)(tSize - 0x08)); image = new RawImage(tiles, TileForm.Horizontal, depth, 0x40, tiles.Length / 0x40, false, fileName); // Map if (mapOffset == 0x00) { hasMap = false; goto End; } hasMap = true; br.BaseStream.Position = mapOffset; uint mCabeceraSize = br.ReadUInt32() * 4; uint[] mSize = new uint[(int)mCabeceraSize / 4]; for (int i = 0; i < mSize.Length; i++) mSize[i] = (br.ReadUInt32() * 4) - mCabeceraSize - 4; maps = new MapBase[mSize.Length]; for (int i = 0; i < maps.Length; i++) { ushort width = (ushort)(br.ReadUInt16() * 8); ushort height = (ushort)(br.ReadUInt16() * 8); NTFS[] map; if (i != 0) map = new NTFS[((mSize[i] - mSize[i - 1]) - 4) / 2]; else map = new NTFS[(mSize[i] - 4) / 2]; for (int j = 0; j < map.Length; j++) map[j] = Actions.MapInfo(br.ReadUInt16()); maps[i] = new RawMap(map, width, height, false, fileName); } End: br.Close(); palette = new RawPalette(colors, false, depth, fileName); }
public override void Read(string file) { BinaryReader br = new BinaryReader(File.OpenRead(file)); sNCSC ncsc = new sNCSC(); // Nitro generic header ncsc.generic.id = br.ReadChars(4); ncsc.generic.endianess = br.ReadUInt16(); ncsc.generic.constant = br.ReadUInt16(); ncsc.generic.file_size = br.ReadUInt32(); ncsc.generic.header_size = br.ReadUInt16(); ncsc.generic.nSection = br.ReadUInt16(); // SCRN section ncsc.scrn.id = br.ReadChars(4); ncsc.scrn.size = br.ReadUInt32(); ncsc.scrn.width = br.ReadUInt32() * 8; ncsc.scrn.height = br.ReadUInt32() * 8; ncsc.scrn.unknown1 = br.ReadUInt32(); ncsc.scrn.unknown2 = br.ReadUInt32(); NTFS[] map = new NTFS[(ncsc.scrn.size - 0x18) / 2]; for (int i = 0; i < map.Length; i++) map[i] = Actions.MapInfo(br.ReadUInt16()); // Read other sections for (int n = 1; n < ncsc.generic.nSection; n++) { String type = new String(br.ReadChars(4)); switch (type) { case "ESCR": ncsc.escr.id = "ESCR".ToCharArray(); ncsc.escr.size = br.ReadUInt32(); ncsc.escr.width = br.ReadUInt32(); ncsc.escr.height = br.ReadUInt32(); ncsc.escr.unknown = br.ReadUInt32(); ncsc.escr.unknown2 = br.ReadUInt32(); ncsc.escr.unknownData = new uint[ncsc.escr.width * ncsc.escr.height]; for (int i = 0; i < ncsc.escr.unknownData.Length; i++) ncsc.escr.unknownData[i] = br.ReadUInt32(); break; case "CLRF": ncsc.clrf.id = "CLRF".ToCharArray(); ncsc.clrf.size = br.ReadUInt32(); ncsc.clrf.width = br.ReadUInt32(); ncsc.clrf.height = br.ReadUInt32(); ncsc.clrf.unknown = br.ReadBytes((int)ncsc.clrf.size - 0x10); break; case "CLRC": ncsc.clrc.id = "CLRC".ToCharArray(); ncsc.clrc.size = br.ReadUInt32(); ncsc.clrc.unknown = br.ReadBytes((int)ncsc.clrc.size - 0x08); break; case "GRID": ncsc.grid.id = "GRID".ToCharArray(); ncsc.grid.size = br.ReadUInt32(); ncsc.grid.unknown = br.ReadBytes((int)ncsc.grid.size - 0x08); break; case "LINK": ncsc.link.id = "LINK".ToCharArray(); ncsc.link.size = br.ReadUInt32(); ncsc.link.link = new string(br.ReadChars((int)ncsc.link.size - 0x08)); break; case "CMNT": ncsc.cmnt.id = "CMNT".ToCharArray(); ncsc.cmnt.size = br.ReadUInt32(); ncsc.cmnt.unknown = br.ReadBytes((int)ncsc.cmnt.size - 0x08); break; } } br.Close(); Set_Map(map, false, (int)ncsc.scrn.width, (int)ncsc.scrn.height); }
public void Read(string file) { BinaryReader br = new BinaryReader(File.OpenRead(file)); // Header uint paletaOffset = br.ReadUInt32() * 4; uint tileOffset = br.ReadUInt32() * 4; uint mapOffset = br.ReadUInt32() * 4; ColorFormat depth; br.BaseStream.Position = mapOffset; if (br.ReadUInt32() == 0x01) { depth = ColorFormat.colors256; } else { depth = ColorFormat.colors16; } // Palette Color[][] colors; if (paletaOffset == 0x00) // No palette { depth = ColorFormat.colors16; colors = new Color[defaultPaletteData.Length / 0x20][]; for (int i = 0; i < colors.Length; i++) { Byte[] data = new Byte[0x20]; Array.Copy(defaultPaletteData, i * 0x20, data, 0, 0x20); colors[i] = Actions.BGR555ToColor(data); } goto Tile; } br.BaseStream.Position = paletaOffset; uint pCabeceraSize = br.ReadUInt32() * 4; uint pSize = br.ReadUInt32() * 4; if (pSize - 0x08 == 0x0200) { depth = ColorFormat.colors256; } else if (pSize - 0x08 == 0x20) { depth = ColorFormat.colors16; } colors = new Color[depth == ColorFormat.colors16 ? (pSize - 0x08) / 0x20 : 1][]; uint pal_length = (depth == ColorFormat.colors16) ? 0x20 : pSize - 0x08; for (int i = 0; i < colors.Length; i++) { colors[i] = Actions.BGR555ToColor(br.ReadBytes((int)pal_length)); } // Tile data Tile: br.BaseStream.Position = tileOffset; uint tCabeceraSize = br.ReadUInt32() * 4; uint tSize = br.ReadUInt32() * 4; byte[] tiles = br.ReadBytes((int)(tSize - 0x08)); image = new RawImage(tiles, TileForm.Horizontal, depth, 0x40, tiles.Length / 0x40, false, fileName); // Map if (mapOffset == 0x00) { hasMap = false; goto End; } hasMap = true; br.BaseStream.Position = mapOffset; uint mCabeceraSize = br.ReadUInt32() * 4; uint[] mSize = new uint[(int)mCabeceraSize / 4]; for (int i = 0; i < mSize.Length; i++) { mSize[i] = (br.ReadUInt32() * 4) - mCabeceraSize - 4; } maps = new MapBase[mSize.Length]; for (int i = 0; i < maps.Length; i++) { ushort width = (ushort)(br.ReadUInt16() * 8); ushort height = (ushort)(br.ReadUInt16() * 8); NTFS[] map; if (i != 0) { map = new NTFS[((mSize[i] - mSize[i - 1]) - 4) / 2]; } else { map = new NTFS[(mSize[i] - 4) / 2]; } for (int j = 0; j < map.Length; j++) { map[j] = Actions.MapInfo(br.ReadUInt16()); } maps[i] = new RawMap(map, width, height, false, fileName); } End: br.Close(); palette = new RawPalette(colors, false, depth, fileName); }
private System.Windows.Forms.Control ShowImage(sFile file) { #region Palette BinaryReader br = new BinaryReader(File.OpenRead(file.path)); br.ReadUInt32(); // 4 Bytes Stupid uint num_colors = 256; byte[] pal = br.ReadBytes((int)num_colors * 2); Color[] colors = Actions.BGR555ToColor(pal); PaletteBase palette = new RawPalette(colors, false, ColorFormat.colors256, file.name); br.ReadUInt32(); // 4 Bytes Stupid #endregion #region Map NTFS[] map_info = new NTFS[1024]; for (int i = 0; i < 1024; i++) { ushort value = br.ReadUInt16(); map_info[i] = Actions.MapInfo(value); } MapBase map = new RawMap(map_info, 256, 192, false, file.name); #endregion #region Tiles uint size_section = (uint)(br.ReadUInt32() * 64); Console.WriteLine("Size section: " + size_section.ToString("x")); byte[] readsize = br.ReadBytes((int)size_section); ImageBase image = new RawImage(readsize, TileForm.Horizontal, ColorFormat.colors256, 256, 192, false, file.name); #endregion br.Close(); pluginHost.Set_Palette(palette); pluginHost.Set_Image(image); pluginHost.Set_Map(map); return new ImageControl(pluginHost, image, palette, map); }
public override void Read(string fileIn) { BinaryReader br = new BinaryReader(File.OpenRead(fileIn)); // Header char[] type = br.ReadChars(4); // "STD " uint unknown_header = br.ReadUInt32(); ushort clrformat = br.ReadUInt16(); ColorFormat format = ColorFormat.colors256; if (clrformat == 0) { format = ColorFormat.colors16; } br.BaseStream.Position = 0x10; // Unknown values // Palette ushort unknown_pal = br.ReadUInt16(); ushort num_colors = br.ReadUInt16(); Color[] colors = Actions.BGR555ToColor(br.ReadBytes(num_colors * 2)); PaletteBase palette = new RawPalette(new Color[][] { colors }, false, format); // Map int tile_width = br.ReadUInt16() * 8; int tile_height = br.ReadUInt16() * 8; int tile_size = tile_width * tile_height; if (tile_height != tile_width) { System.Windows.Forms.MessageBox.Show("Different tile size; height != width"); } int width = br.ReadUInt16() * tile_width; int height = br.ReadUInt16() * tile_height; uint unknown2_map = br.ReadUInt32(); // Padding ? NTFS[] map = new NTFS[width * height / tile_size]; for (int i = 0; i < map.Length; i++) { map[i] = new NTFS(); uint mapv = br.ReadUInt32(); map[i].nTile = (ushort)(mapv & 0xFFFFFF); map[i].nTile /= (ushort)(tile_size / 0x40); map[i].nPalette = (byte)(mapv >> 28); } Set_Map(map, false, width, height); // Image if (clrformat == 2) { format = ColorFormat.A3I5; } else if (clrformat == 3) { format = ColorFormat.A5I3; } else if (clrformat != 0 && clrformat != 1) { System.Windows.Forms.MessageBox.Show("ClrFormat: " + clrformat.ToString()); } byte[] tiles = br.ReadBytes((int)(br.BaseStream.Length - br.BaseStream.Position)); ImageBase image = new RawImage(tiles, TileForm.Horizontal, format, width, height, false); image.TileSize = tile_width; br.Close(); pluginHost.Set_Palette(palette); pluginHost.Set_Image(image); pluginHost.Set_Map(this); }
public void Get_Image(string fileIn) { BinaryReader br = new BinaryReader(File.OpenRead(fileIn)); // Palette uint num_colors = br.ReadUInt32(); Color[][] colors = new Color[1][]; colors[0] = Actions.BGR555ToColor(br.ReadBytes((int)num_colors * 2)); // Image data uint num_tiles = (ushort)br.ReadUInt32(); byte[] tiles = br.ReadBytes((int)num_tiles * 0x40); // Map Info ushort width = (ushort)(br.ReadUInt16() * 8); ushort height = (ushort)(br.ReadUInt16() * 8); NTFS[] map = new NTFS[width * height / 0x40]; for (int i = 0; i < map.Length; i++) map[i] = Actions.MapInfo(br.ReadUInt16()); br.Close(); palette = new RawPalette(colors, false, ColorFormat.colors256); image = new RawImage(tiles, TileForm.Horizontal, ColorFormat.colors256, width, height, false); Set_Map(map, false, width, height); }