private BitmapGraphics GetTile(TR2Level level, int index) { TRTexImage16 tex = level.Images16[index]; Bitmap bmp = new Bitmap(256, 256, PixelFormat.Format32bppArgb); BitmapData bitmapData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); List <byte> pixelCollection = new List <byte>(); foreach (Textile16Pixel px in tex.To32BPPFormat()) { pixelCollection.AddRange(px.RGB32); } Marshal.Copy(pixelCollection.ToArray(), 0, bitmapData.Scan0, pixelCollection.Count); bmp.UnlockBits(bitmapData); return(new BitmapGraphics(bmp)); }
private BitmapGraphics GetBitmapGraphics(int tile) { if (!_tileMap.ContainsKey(tile)) { TRTexImage16 tex = _level.Images16[tile]; Bitmap bmp = new Bitmap(_tileWidth, _tileHeight, PixelFormat.Format32bppArgb); BitmapData bitmapData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); List <byte> pixelCollection = new List <byte>(); foreach (Textile16Pixel px in tex.To32BPPFormat()) { pixelCollection.AddRange(px.RGB32); } Marshal.Copy(pixelCollection.ToArray(), 0, bitmapData.Scan0, pixelCollection.Count); bmp.UnlockBits(bitmapData); _tileMap.Add(tile, new BitmapGraphics(bmp)); } return(_tileMap[tile]); }