public static extern int TranscodeImageLevel( IntPtr transcoder, void *pData, UInt32 dataSize, UInt32 imageIndex, UInt32 levelIndex, void *pOutput, UInt32 outputSizeInBlocks, TranscoderTextureFormats format, DecodeFlags decodeFlags, UInt32 outputRowPitch, UInt32 outputHeightInPixels );
public void GetFormatInfo(TranscoderTextureFormats format, out uint bytesPerBlockOrPixel, out bool isBlockTextureFormat) { lock (File) { bytesPerBlockOrPixel = Transcoder.GetBytesPerBlockOrPixel(format); isBlockTextureFormat = Transcoder.IsBlockTextureFormat(format); } }
public static bool IsBlockTextureFormat(TranscoderTextureFormats format) { switch (format) { case TranscoderTextureFormats.RGBA32: case TranscoderTextureFormats.RGB565: case TranscoderTextureFormats.BGR565: case TranscoderTextureFormats.RGBA4444: return(false); default: return(true); } }
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); }
public uint GetTranscodedSizeInBytes(TranscoderTextureFormats format) { uint origWidth, origHeight, totalBlocks; lock (File) { var blockSize = Transcoder.GetBytesPerBlockOrPixel(format); if (Transcoder.GetImageLevelDesc( File.pTranscoder, File.pData, File.DataSize, Image.Index, Index, out origWidth, out origHeight, out totalBlocks ) == 0) { return(0); } if (Transcoder.IsBlockTextureFormat(format)) { return(totalBlocks * blockSize); } else { return(origWidth * origHeight * blockSize); } } }
public static extern UInt32 GetBytesPerBlockOrPixel(TranscoderTextureFormats format);