public void WriteToDataStream(IDataStream s) { s.WriteByte((byte)Command.GetDesktopInfo); if (screens.Length > 255) { throw new Exception("Number of screens may not be greater than 255"); } s.WriteByte((byte)screens.Length); foreach (DesktopScreen screen in screens) { screen.WriteToDataStream(s); } }
internal void WriteToDataStream(IDataStream s) { s.WriteByte(adapterIndex); s.WriteByte(outputIndex); byte[] strData = Encoding.UTF8.GetBytes(adapterName); s.WriteUInt16((ushort)strData.Length); s.Write(strData, 0, strData.Length); strData = Encoding.UTF8.GetBytes(outputName); s.WriteUInt16((ushort)strData.Length); s.Write(strData, 0, strData.Length); s.WriteInt16(X); s.WriteInt16(Y); s.WriteUInt16(Width); s.WriteUInt16(Height); }
public void WriteToDataStream(IDataStream s, ref byte[] compressToBuffer, int jpegQuality = 80, turbojpegCLI.SubsamplingOption subsamp = turbojpegCLI.SubsamplingOption.SAMP_420) { if (movedFragments.Length > 65535) { throw new Exception("FragmentedImage has too many movedFragments: " + movedFragments.Length); } if (dirtyFragments.Length > 65535) { throw new Exception("FragmentedImage has too many dirtyFragments: " + dirtyFragments.Length); } s.WriteByte((byte)Command.GetScreenCapture); // Write command code s.WriteByte(streamId); // Write stream ID // Calculate buffer sizes s.WriteUInt16((ushort)movedFragments.Length); // Write number of fragments s.WriteUInt16((ushort)dirtyFragments.Length); // Write number of fragments if (movedFragments.Length == 0 && dirtyFragments.Length == 0) { return; } foreach (MovedImageFragment moveFrag in movedFragments) { moveFrag.WriteToDataStream(s); } if (dirtyFragments.Length > 0) { if (dirtyFragments[0].screenshot.BufferIsCompressed) { foreach (DirtyImageFragment dirtyFrag in dirtyFragments) { dirtyFrag.WriteToDataStream(s, null, ref compressToBuffer); } } else { using (turbojpegCLI.TJCompressor compressor = new turbojpegCLI.TJCompressor()) { compressor.setSubsamp(subsamp); compressor.setJPEGQuality(jpegQuality); int requiredBufferSize = 0; foreach (DirtyImageFragment dirtyFrag in dirtyFragments) { int thisBufferSize = turbojpegCLI.TJ.bufSize(dirtyFrag.screenshot.Width, dirtyFrag.screenshot.Height, subsamp); requiredBufferSize = Math.Max(requiredBufferSize, thisBufferSize); } if (compressToBuffer == null || compressToBuffer.Length < requiredBufferSize) { compressToBuffer = new byte[requiredBufferSize]; } foreach (DirtyImageFragment dirtyFrag in dirtyFragments) { dirtyFrag.WriteToDataStream(s, compressor, ref compressToBuffer); } } } } }