public RSImage(SubArchive archive, DataBuffer image_data, int sprite_index = 0) { try { DataBuffer index_data = archive.ExtractFile("index.dat"); if (index_data == null || image_data == null) { return; } image_data.Location = 0; index_data.Location = image_data.ReadShort(); WholeWidth = index_data.ReadShort(); WholeHeight = index_data.ReadShort(); Palette = new Color[index_data.ReadByte()]; for (int i = 0; i < Palette.Length - 1; i++) { Palette[i + 1] = Color.FromArgb(index_data.ReadByte(), index_data.ReadByte(), index_data.ReadByte()); } for (int i = 0; i < sprite_index; i++) { index_data.Location += 2; //x/y offset image_data.Location += index_data.ReadShort() * index_data.ReadShort(); //width * height index_data.Location++; //type } XOffset = index_data.ReadByte(); YOffset = index_data.ReadByte(); Width = index_data.ReadShort(); Height = index_data.ReadShort(); byte type = index_data.ReadByte(); Pixels = new Color[Width * Height]; PaletteIndexes = new byte[Width * Height]; if (type == 0) { for (int i = 0; i < Pixels.Length; i++) { PaletteIndexes[i] = image_data.ReadByte(); Pixels[i] = Palette[PaletteIndexes[i]]; } } else if (type == 1) { for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { PaletteIndexes[x + y * Width] = image_data.ReadByte(); Pixels[x + y * Width] = Palette[PaletteIndexes[x + y * Width]]; } } } } catch (Exception) { Pixels = null; } }
public static Point GetCoordinates(SubArchive archive, int index) { if (map_indices1 == null) { DataBuffer data = archive.ExtractFile("map_index"); if (data == null) { return(new Point(-1, -1)); } map_indices1 = new int[data.Buffer.Length / 7]; map_indices2 = new int[data.Buffer.Length / 7]; map_indices3 = new int[data.Buffer.Length / 7]; map_indices4 = new int[data.Buffer.Length / 7]; for (int i = 0; i < data.Buffer.Length / 7; i++) { map_indices1[i] = data.ReadShort(); map_indices2[i] = data.ReadShort(); map_indices3[i] = data.ReadShort(); map_indices4[i] = data.ReadByte(); } } if (index < map_indices1.Length) { int value = map_indices1[index]; return(new Point((value >> 8) & 0xFF, value & 0xFF)); } return(new Point(-1, -1)); }
public RSImage(SubArchive archive, string file, int sprite_index = 0) : this(archive, archive.ExtractFile(file), sprite_index) { }
public RSFont(bool flag, String s, SubArchive streamLoader) { aByteArrayArray1491 = new byte[256][]; anIntArray1492 = new int[256]; anIntArray1493 = new int[256]; anIntArray1494 = new int[256]; anIntArray1495 = new int[256]; anIntArray1496 = new int[256]; aRandom1498 = new Random(); aBoolean1499 = false; DataBuffer stream = streamLoader.ExtractFile(s + ".dat"); DataBuffer stream_1 = streamLoader.ExtractFile("index.dat"); stream_1.Location = stream.ReadShort() + 4; int k = stream_1.ReadByte(); if (k > 0) { stream_1.Location += 3 * (k - 1); } for (int l = 0; l < 256; l++) { anIntArray1494[l] = stream_1.ReadByte(); anIntArray1495[l] = stream_1.ReadByte(); int i1 = anIntArray1492[l] = stream_1.ReadShort(); int j1 = anIntArray1493[l] = stream_1.ReadShort(); int k1 = stream_1.ReadByte(); int l1 = i1 * j1; aByteArrayArray1491[l] = new byte[l1]; if (k1 == 0) { for (int i2 = 0; i2 < l1; i2++) { aByteArrayArray1491[l][i2] = stream.ReadByte(); } } else if (k1 == 1) { for (int j2 = 0; j2 < i1; j2++) { for (int l2 = 0; l2 < j1; l2++) { aByteArrayArray1491[l][j2 + l2 * i1] = stream.ReadByte(); } } } if (j1 > anInt1497 && l < 128) { anInt1497 = j1; } anIntArray1494[l] = 1; anIntArray1496[l] = i1 + 2; int k2 = 0; for (int i3 = j1 / 7; i3 < j1; i3++) { k2 += aByteArrayArray1491[l][i3 * i1]; } if (k2 <= j1 / 7) { anIntArray1496[l]--; anIntArray1494[l] = 0; } k2 = 0; for (int j3 = j1 / 7; j3 < j1; j3++) { k2 += aByteArrayArray1491[l][(i1 - 1) + j3 * i1]; } if (k2 <= j1 / 7) { anIntArray1496[l]--; } } if (flag) { anIntArray1496[32] = anIntArray1496[73]; } else { anIntArray1496[32] = anIntArray1496[105]; } }