CameraServer.VideoSender.EncodeBGRb C# (CSharp) Method

EncodeBGRb() private method

private EncodeBGRb ( PixelAccessor accessor, int x, int y ) : BufferChunk
accessor PixelAccessor
x int
y int
return NewTOAPIA.BufferChunk
        BufferChunk EncodeBGRb(PixelAccessor<BGRb> accessor, int x, int y)
        {
            fImageStream.SetLength(0);

            // 2. Run length encode the image to a memory stream
            NewTOAPIA.Imaging.TargaRunLengthCodec rlc = new NewTOAPIA.Imaging.TargaRunLengthCodec();
            rlc.Encode(accessor, fImageStream);

            // 3. Get the bytes from the stream
            byte[] imageBytes = fImageStream.GetBuffer();
            int dataLength = (int)imageBytes.Length;

            // 4. Allocate a buffer chunk to accomodate the bytes, plus some more
            BufferChunk chunk = new BufferChunk(dataLength + 128);

            // 5. Put the command, destination, and data size into the buffer first
            chunk += (int)UICommands.PixBltRLE;
            chunk += (int)x;
            chunk += (int)y;
            chunk += (int)accessor.Width;
            chunk += (int)accessor.Height;
            chunk += dataLength;

            // 6. Put the image bytes into the chunk
            chunk += imageBytes;


            // 7. Finally, return the packet
            return chunk;
        }
    }