Example #1
0
 /// <summary>
 /// Writes the MovedImageFragment to the data stream.
 /// </summary>
 /// <param name="s"></param>
 public void WriteToDataStream(IDataStream s)
 {
     s.WriteInt16((short)bounds.X);
     s.WriteInt16((short)bounds.Y);
     s.WriteUInt16((ushort)bounds.Width);
     s.WriteUInt16((ushort)bounds.Height);
     s.WriteInt16((short)source.X);
     s.WriteInt16((short)source.Y);
 }
Example #2
0
        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);
        }
Example #3
0
        /// <summary>
        /// Writes the DirtyImageFragment to the data stream in compressed format.
        /// </summary>
        /// <param name="s">The stream to write the frame to.</param>
        /// <param name="compressor">A TJCompressor instance that is preconfigured with quality and subsampling options.  Can be null if the image is already compressed.</param>
        /// <param name="compressToBuffer">The buffer to compress to, not used if the image is already compressed.</param>
        public void WriteToDataStream(IDataStream s, TJCompressor compressor, ref byte[] compressToBuffer)
        {
            s.WriteInt16((short)bounds.X);
            s.WriteInt16((short)bounds.Y);
            s.WriteUInt16((ushort)bounds.Width);
            s.WriteUInt16((ushort)bounds.Height);

            if (screenshot.BufferIsCompressed)
            {
                s.WriteInt32(screenshot.Buffer.Length);                  // Write length of image
                s.Write(screenshot.Buffer, 0, screenshot.Buffer.Length); // Write image
            }
            else
            {
                turbojpegCLI.PixelFormat pixelFormat = screenshot.BitsPerPixel == 24 ? turbojpegCLI.PixelFormat.BGR : turbojpegCLI.PixelFormat.BGRX;
                compressor.setSourceImage(screenshot.Buffer, 0, 0, screenshot.Width, screenshot.Stride, screenshot.Height, pixelFormat);
                compressor.compress(ref compressToBuffer, turbojpegCLI.Flag.NONE);
                int compressedSize = compressor.getCompressedSize();
                s.WriteInt32(compressedSize);                 // Write length of image
                s.Write(compressToBuffer, 0, compressedSize); // Write image
            }
        }