Skip to content
This repository has been archived by the owner on Jul 13, 2024. It is now read-only.

Is it meant to be this slow? #161

Open
MichaelEpicA opened this issue May 7, 2022 · 0 comments
Open

Is it meant to be this slow? #161

MichaelEpicA opened this issue May 7, 2022 · 0 comments

Comments

@MichaelEpicA
Copy link

When connecting via RealVNC viewer, it stays on the same frame for so long, and its very confusing. If this is a code issue, here's my code for the VNC Server.
`using RemoteViewing.Vnc;
using RemoteViewing.Vnc.Server;
using RemoteViewing.Windows.Forms;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace VM_Battle_Royale
{
public delegate Rectangle VncScreenFramebufferSourceGetBoundsCallback();
///
public class VncScreenFramebufferSource : IVncFramebufferSource, IVncRemoteKeyboard, IVncRemoteController
{
VncMouse mouse = new VncMouse();
private Bitmap bitmap;
private VncFramebuffer framebuffer;
private string name;
private VncScreenFramebufferSourceGetBoundsCallback getScreenBounds;

    /// <summary>
    /// Initializes a new instance of the <see cref="VncScreenFramebufferSource"/> class.
    /// </summary>
    /// <param name="name">The framebuffer name. Many VNC clients set their titlebar to this name.</param>
    /// <param name="screen">The bounds of the screen region.</param>
    public VncScreenFramebufferSource(string name, Screen screen)
    {
        if (screen == null)
        {
            throw new ArgumentNullException(nameof(screen));
        }

        this.name = name ?? throw new ArgumentNullException(nameof(name));
        this.getScreenBounds = () => screen.Bounds;
    }

    /// <summary>
    /// Initializes a new instance of the <see cref="VncScreenFramebufferSource"/> class.
    /// Screen region bounds are determined by a callback.
    /// </summary>
    /// <param name="name">The framebuffer name. Many VNC clients set their titlebar to this name.</param>
    /// <param name="getBoundsCallback">A callback supplying the bounds of the screen region to copy.</param>
    public VncScreenFramebufferSource(string name, VncScreenFramebufferSourceGetBoundsCallback getBoundsCallback)
    {
        this.name = name ?? throw new ArgumentNullException(nameof(name));
        this.getScreenBounds = getBoundsCallback ?? throw new ArgumentNullException(nameof(getBoundsCallback));
    }

    /// <inheritdoc/>
    public bool SupportsResizing => false;

    /// <inheritdoc/>
    public ExtendedDesktopSizeStatus SetDesktopSize(int width, int height)
    {
        return ExtendedDesktopSizeStatus.Prohibited;
    }

    /// <summary>
    /// Captures the screen.
    /// </summary>
    /// <returns>A framebuffer corresponding to the screen.</returns>
    public VncFramebuffer Capture()
    {
        var bounds = this.getScreenBounds();
        int w = bounds.Width, h = bounds.Height;

        if (this.bitmap == null || this.bitmap.Width != w || this.bitmap.Height != h)
        {
            this.bitmap = new Bitmap(w, h);
            this.framebuffer = new VncFramebuffer(this.name, w, h, new VncPixelFormat());
        }

        using (var g = Graphics.FromImage(this.bitmap))
        {
            g.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size);

            lock (this.framebuffer.SyncRoot)
            {
                VncBitmap.CopyToFramebuffer(
                    this.bitmap,
                    new VncRectangle(0, 0, w, h),
                    this.framebuffer,
                    0,
                    0);
            }
        }

        return this.framebuffer;
    }

    public void HandleKeyEvent(object sender, KeyChangedEventArgs e)
    {
       
    }

    public void HandleTouchEvent(object sender, PointerChangedEventArgs e)
    {
        mouse.OnMouseUpdate(sender, e);  
    }
}

}
`

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant