public ImageLevel this [uint index] { get { ImageLevelInfo info; lock (File) { if (Transcoder.GetImageLevelInfo(File.pTranscoder, File.pData, File.DataSize, Image.Index, index, out info) == 0) { throw new Exception("Failed to get image level info"); } return(new ImageLevel(Image, index, ref info)); } } }
public bool TryTranscode( TranscoderTextureFormats format, ArraySegment <byte> output, DecodeFlags decodeFlags, out ImageLevelInfo levelInfo, uint outputRowPitch = 0, uint outputHeightInPixels = 0 ) { lock (File) { if (!File.IsStarted) { if (Transcoder.Start(File.pTranscoder, File.pData, File.DataSize) == 0) { levelInfo = default; return(false); } File.IsStarted = true; } if (Transcoder.GetImageLevelInfo(File.pTranscoder, File.pData, File.DataSize, Image.Index, Index, out levelInfo) == 0) { return(false); } var blockSize = Transcoder.GetBytesPerBlockOrPixel(format); var numBlocks = (uint)(output.Count / blockSize); fixed(byte *pBuffer = output.Array) { var pOutput = pBuffer + output.Offset; if (Transcoder.TranscodeImageLevel( File.pTranscoder, File.pData, File.DataSize, Image.Index, Index, pOutput, numBlocks, format, decodeFlags, outputRowPitch, outputHeightInPixels ) == 0) { return(false); } } } return(true); }