Ejemplo n.º 1
0
    private void ReadPixelsAsyncCallback(IAsyncResult result)
    {
        if (RenderingStream != null && RenderingStream.IsConnected)
        {
            var amountRead = RenderingStream.EndRead(result);

            if (amountRead != Constants.SCREEN_BYTE_COUNT)
            {
                throw new Exception("Amount read mismatch!");
            }

            lock (Lock)
            {
                ProcessFrame();

                var data = Frame.LockBits(new Rectangle(0, 0, Constants.SCREEN_WIDTH, Constants.SCREEN_HEIGHT),
                                          ImageLockMode.WriteOnly, Frame.PixelFormat);
                Marshal.Copy(Pixels, 0, data.Scan0, Constants.SCREEN_BYTE_COUNT);
                Frame.UnlockBits(data);
            }

            if (Form.IsHandleCreated)
            {
                Form.BeginInvoke(new Action(() =>
                {
                    lock (Lock)
                    {
                        Form.SetBitmap(Frame);
                    }
                }));
            }
        }

        BeginReadPixels();
    }
Ejemplo n.º 2
0
 private void BeginReadPixels()
 {
     if (RenderingStream != null && RenderingStream.IsConnected)
     {
         RenderingStream.BeginRead(Pixels, 0, Constants.SCREEN_BYTE_COUNT, ReadPixelsAsyncCallback, null);
     }
 }
Ejemplo n.º 3
0
    private void ClosePipes()
    {
        RenderingStream.Close();
        RenderingStream.Dispose();
        RenderingStream = null;

        CommandStream.Close();
        CommandStream.Dispose();
        CommandStream = null;
    }
Ejemplo n.º 4
0
    private void RenderingPipelineConnectedAsyncCallback(IAsyncResult result)
    {
        RenderingStream.EndWaitForConnection(result);
        RenderingPipelineConnectedAsyncCallbackFinished = true;

        if (RenderingPipelineConnectedAsyncCallbackFinished && CommandPipelineConnectedAsyncCallbackFinished)
        {
            BeginReadPixels();
        }
    }