ImageData Unpack() { byte[] pixels; switch (m_texture.m_TextureFormat) { case TextureFormat.DXT5: { var decoder = new DxtDecoder(m_texture.m_Data, Info); pixels = decoder.UnpackDXT5(); break; } case TextureFormat.Alpha8: case TextureFormat.R16: case TextureFormat.RGB24: case TextureFormat.BGRA32: case TextureFormat.RGB565: pixels = m_texture.m_Data; break; default: throw new NotImplementedException("Not supported Unity Texture2D format."); } return(ImageData.CreateFlipped(Info, Format, null, pixels, (int)Info.Width * ((Format.BitsPerPixel + 7) / 8))); }
ImageData Unpack() { if (null == m_texture.m_Data || 0 == m_texture.m_Data.Length) { m_texture.LoadData(m_reader); } byte[] pixels; switch (m_texture.m_TextureFormat) { case TextureFormat.DXT1: { var decoder = new DxtDecoder(m_texture.m_Data, Info); pixels = decoder.UnpackDXT1(); break; } case TextureFormat.DXT5: { var decoder = new DxtDecoder(m_texture.m_Data, Info); pixels = decoder.UnpackDXT5(); break; } case TextureFormat.Alpha8: case TextureFormat.R16: case TextureFormat.RGB24: case TextureFormat.BGRA32: case TextureFormat.RGB565: pixels = m_texture.m_Data; break; case TextureFormat.ARGB32: pixels = ConvertArgb(m_texture.m_Data); break; case TextureFormat.RGBA32: pixels = ConvertRgba(m_texture.m_Data); break; case TextureFormat.ARGB4444: pixels = ConvertArgb16(m_texture.m_Data); break; case TextureFormat.BC7: { var decoder = new Bc7Decoder(m_texture.m_Data, Info); pixels = decoder.Unpack(); break; } default: throw new NotImplementedException(string.Format("Not supported Unity Texture2D format '{0}'.", m_texture.m_TextureFormat)); } return(ImageData.CreateFlipped(Info, Format, null, pixels, (int)Info.Width * ((Format.BitsPerPixel + 7) / 8))); }