Exemplo n.º 1
0
 internal ImageLevel(Image image, uint index, ref ImageLevelInfo info)
 {
     File  = image.File;
     Image = image;
     Index = index;
     Info  = info;
 }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 public static extern int GetImageLevelInfo(
     IntPtr transcoder, void *pData, UInt32 dataSize,
     UInt32 imageIndex, UInt32 levelIndex, out ImageLevelInfo result
     );