using System; namespace ScreenConnect; public class WebPDecoder : ScreenCodec { protected unsafe override void Process(byte* data, int width, int height, int stride) { fixed (byte* ptr = new byte[8]) { ReadThroughCoder(null, ptr, 8, isEndOfBlock: false); if (*ptr != 82 || ptr[1] != 73 || ptr[2] != 70 || ptr[3] != 70) { throw new Exception("Header doesn't start with RIFF"); } int num = 8 + (ptr[4] | (ptr[5] << 8) | (ptr[6] << 16) | (ptr[7] << 24)); fixed (byte* ptr2 = new byte[num]) { Extensions.CopyMemory(ptr, ptr2, 8); ReadThroughCoder(null, ptr2 + 8, num - 8, isEndOfBlock: false); NativeLibrarySingleton.Instance.WebPDecodeBGRAInto(ptr2, num, data, stride * height, stride); } } } }