public List <Bitmap> GetBitmaps() { List <Bitmap> list = new List <Bitmap>(); for (uint depth = 0; depth < TXM.Depth; ++depth) { Data.Position = 0; Stream plane = TXM.GetSinglePlane(Data, depth); switch (TXM.Format) { case TextureFormat.DXT1a: case TextureFormat.DXT1b: case TextureFormat.DXT5a: case TextureFormat.DXT5b: { plane.Position = 0; DDSHeader header = DDSHeader.Generate(TXM.Width, TXM.Height, TXM.Mipmaps, (TXM.Format == TextureFormat.DXT1a || TXM.Format == TextureFormat.DXT1b) ? Textures.TextureFormat.DXT1a : Textures.TextureFormat.DXT5); list.Add(new DDS(header, plane).ConvertToBitmap()); } break; default: for (uint mip = 0; mip < TXM.Mipmaps; ++mip) { (uint width, uint height, IPixelOrderIterator pxit, IColorFetchingIterator colit) = GenerateIterators(plane, mip); var bmp = colit.ConvertToBitmap(pxit, width, height); list.Add(bmp); } break; } } return(list); }
// TODO: Duplicated code between GetBitmaps() and GetDiskWritableStreams().. public List <Bitmap> GetBitmaps() { List <Bitmap> list = new List <Bitmap>(); for (uint depth = 0; depth < TXM.Depth; ++depth) { Data.Position = 0; Stream plane = TXM.GetSinglePlane(Data, depth); switch (TXM.Format) { case TextureFormat.DXT1a: case TextureFormat.DXT1b: case TextureFormat.DXT5a: case TextureFormat.DXT5b: { plane.Position = 0; DDSHeader header = DDSHeader.Generate(TXM.Width, TXM.Height, TXM.Mipmaps, (TXM.Format == TextureFormat.DXT1a || TXM.Format == TextureFormat.DXT1b) ? Textures.TextureFormat.DXT1 : Textures.TextureFormat.DXT5); list.Add(new DDS(header, plane).ConvertToBitmap()); } break; case TextureFormat.ARGBa: case TextureFormat.ARGBb: for (uint mip = 0; mip < TXM.Mipmaps; ++mip) { var dims = TXM.GetDimensions((int)mip); IPixelOrderIterator pxit; if (TXM.Format == TextureFormat.ARGBa) { pxit = new ARGBaPixelOrderIterator((int)dims.width, (int)dims.height); } else { pxit = new LinearPixelOrderIterator((int)dims.width, (int)dims.height); } var bmp = new ColorFetcherARGB8888(plane, dims.width, dims.height).ConvertToBitmap(pxit, dims.width, dims.height); list.Add(bmp); } break; default: throw new Exception("Unhandled texture format " + TXM.Format); } } return(list); }