I have two project Windows Forms 1. RDPClientApplication and 2. RDPServerApplication.
for now these two project works with sql cloud by which they connect globally, and screensharing also take place, I capture the image at evry time interval the imag is encoded to base64string and send it to db.
server fetch the image from db and process it.
Which is slow and not optimzed.
Can you help me how do i make my screensharing better and even some ideas to build my project optimized/
public void CaptureScreen()
{
// autoReset.WaitOne();
// Thread.Sleep(1000);
while (doInsertImage)
{
if (StartUp.isKeyboardLocked == false)
{
int screenLeft = SystemInformation.VirtualScreen.Left;
int screenTop = SystemInformation.VirtualScreen.Top;
int screenWidth = SystemInformation.VirtualScreen.Width;
int screenHeight = SystemInformation.VirtualScreen.Height;
// Create a bitmap of the appropriate size to receive the full-screen screenshot.
using (Bitmap bitmap = new Bitmap(screenWidth, screenHeight))
{
// Draw the screenshot into our bitmap.
try
{
using (Graphics g = Graphics.FromImage(bitmap))
{
g.CopyFromScreen(screenLeft, screenTop, 0, 0, bitmap.Size);
}
//Save the screenshot as a Jpg image
var uniqueFileName = "test.jpeg";
bitmap.Save(uniqueFileName, ImageFormat.Jpeg);
frameCount++;
using (Image image = Image.FromFile(uniqueFileName))
{
using (MemoryStream m = new MemoryStream())
{
image.Save(m, image.RawFormat);
byte[] imageBytes = m.ToArray();
// Convert byte[] to Base64 String
string base64String = Convert.ToBase64String(imageBytes);
DatabaseConnection.SaveScreenToDatabase(base64String, clientprocessorid);
}
}
}
catch (Exception ex)
{
}
Thread.Sleep(300);
}
//click on screen according to coordinates
//ClickUsingMouseCoordinates();
if (serverprocessorid != null)
{
ReadMouseHover();
}
if (serverprocessorid != null)
{
ReadInputDevicesEvents();
}
}
Thread.Sleep(300);
}
}
Mukul Sah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.