public byte[] GenerateMips(int SurfaceLevel = 0) { Bitmap Image = BitmapExtension.GetBitmap(DecompressedData[SurfaceLevel], (int)TexWidth, (int)TexHeight); List <byte[]> mipmaps = new List <byte[]>(); mipmaps.Add(FTEX.CompressBlock(DecompressedData[SurfaceLevel], (int)TexWidth, (int)TexHeight, Format)); //while (Image.Width / 2 > 0 && Image.Height / 2 > 0) // for (int mipLevel = 0; mipLevel < MipCount; mipLevel++) int width = Image.Width; int height = Image.Height; for (int mipLevel = 0; mipLevel < MipCount; mipLevel++) { if (Image.Width != 1) { width = Image.Width / 2; } if (Image.Height != 1) { height = Image.Height / 2; } Image = BitmapExtension.Resize(Image, width, height); mipmaps.Add(FTEX.CompressBlock(BitmapExtension.ImageToByte(Image), Image.Width, Image.Height, Format)); } Image.Dispose(); return(Utils.CombineByteArray(mipmaps.ToArray())); }