// Token: 0x06000034 RID: 52 RVA: 0x000037C8 File Offset: 0x000023C8 public static TextureBlock Read(StreamHelper streamHelper) { TextureBlock textureBlock = new TextureBlock(); textureBlock.Length = streamHelper.ReadInt32(ByteEncoding.None); textureBlock.TypeBinary = streamHelper.ReadInt32(ByteEncoding.None); textureBlock.Dummy = streamHelper.ReadInt32(ByteEncoding.None); textureBlock.Width = streamHelper.ReadInt16(ByteEncoding.None); textureBlock.Height = streamHelper.ReadInt16(ByteEncoding.None); textureBlock.Data = streamHelper.ReadByteArray(textureBlock.Length - 16); return(textureBlock); }
// Token: 0x06000041 RID: 65 RVA: 0x00003D64 File Offset: 0x00002964 public void SetImage(Bitmap bitmap) { TextureBlock textureBlock = this.TextureBlocks.FirstOrDefault <TextureBlock>(); PaletteBlock paletteBlock = this.PaletteBlocks.FirstOrDefault <PaletteBlock>(); Bitmap bitmap2 = MedianCut.Quantize(bitmap, paletteBlock.Colors.Count); List <Color> allColors = MedianCut.GetAllColors(bitmap2); Dictionary <Color, int> dictionary = new Dictionary <Color, int>(); foreach (Color key in allColors) { if (!dictionary.ContainsKey(key)) { dictionary.Add(key, dictionary.Count); } } paletteBlock.Colors = dictionary.Keys.ToList <Color>(); textureBlock.ApplyBitmapData(bitmap2, dictionary); }
// Token: 0x06000040 RID: 64 RVA: 0x00003CE8 File Offset: 0x000028E8 public Bitmap GetImage(TextureBlock textureBlock = null, PaletteBlock paletteBlock = null) { if (textureBlock == null) { textureBlock = this.TextureBlocks.FirstOrDefault <TextureBlock>(); } if (paletteBlock == null) { paletteBlock = this.PaletteBlocks.FirstOrDefault <PaletteBlock>(); } Bitmap bitmap = new Bitmap((int)textureBlock.Width, (int)textureBlock.Height, PixelFormat.Format32bppArgb); Dictionary <int, Color> dictionary = new Dictionary <int, Color>(); for (int i = 0; i < paletteBlock.Colors.Count; i++) { dictionary.Add(i, paletteBlock.Colors[i]); } textureBlock.ApplyTextureData(bitmap, dictionary); return(bitmap); }
// Token: 0x0600003E RID: 62 RVA: 0x00003B2C File Offset: 0x0000272C public static TM2 ReadBinary(string fileName) { TM2 tm = new TM2(); using (StreamHelper streamHelper = new StreamHelper(fileName, ByteEncoding.Little, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read)) { tm.Header = Header.Read(streamHelper); tm.PaletteBlocks = new List <PaletteBlock>(); tm.TextureBlocks = new List <TextureBlock>(); for (int i = 0; i < (int)tm.Header.CountPalette; i++) { tm.PaletteBlocks.Add(PaletteBlock.Read(streamHelper)); } for (int j = 0; j < (int)tm.Header.CountTextures; j++) { tm.TextureBlocks.Add(TextureBlock.Read(streamHelper)); } } return(tm); }