diff --git a/Remotely_ScreenCast/Capture/ImageUtils.cs b/Remotely_ScreenCast/Capture/ImageUtils.cs index 407dda81..a91b36ba 100644 --- a/Remotely_ScreenCast/Capture/ImageUtils.cs +++ b/Remotely_ScreenCast/Capture/ImageUtils.cs @@ -14,13 +14,11 @@ namespace Remotely_ScreenCast.Capture { public class ImageUtils { - private static ImageCodecInfo CodecInfo { get; } = ImageCodecInfo.GetImageEncoders().FirstOrDefault(x => x.FormatID == ImageFormat.Jpeg.Guid); - - public static byte[] EncodeBitmap(Bitmap bitmap, EncoderParameters encoderParams) + public static byte[] EncodeBitmap(Bitmap bitmap) { using (var ms = new MemoryStream()) { - bitmap.Save(ms, CodecInfo, encoderParams); + bitmap.Save(ms, ImageFormat.Jpeg); return ms.ToArray(); } } diff --git a/Remotely_ScreenCast/Capture/ScreenCaster.cs b/Remotely_ScreenCast/Capture/ScreenCaster.cs index 95d9a018..30a6b45b 100644 --- a/Remotely_ScreenCast/Capture/ScreenCaster.cs +++ b/Remotely_ScreenCast/Capture/ScreenCaster.cs @@ -59,7 +59,7 @@ namespace Remotely_ScreenCast.Capture Name = requesterName, ViewerConnectionID = viewerID, HasControl = Program.Mode == Enums.AppMode.Unattended, - ImageQuality = 100 + ImageQuality = 1 }; while (!success) @@ -99,7 +99,7 @@ namespace Remotely_ScreenCast.Capture // continue; //} - while (viewer.PendingFrames > 10) + while (viewer.PendingFrames > 30) { await Task.Delay(1); } @@ -123,11 +123,11 @@ namespace Remotely_ScreenCast.Capture //long newQuality; //if (viewer.PendingFrames < 8) //{ - // newQuality = Math.Min(100, viewer.ImageQuality + 10); + // newQuality = Math.Min(1, viewer.ImageQuality + .1); //} //else //{ - // newQuality = Math.Max(0, viewer.ImageQuality - 10); + // newQuality = Math.Max(0, viewer.ImageQuality - .1); //} //if (newQuality != viewer.ImageQuality) @@ -143,7 +143,7 @@ namespace Remotely_ScreenCast.Capture // viewer.FullScreenRefreshNeeded = false; //} - var img = ImageUtils.EncodeBitmap(newImage, viewer.EncoderParams); + var img = ImageUtils.EncodeBitmap(newImage); if (img?.Length > 0) { diff --git a/Remotely_ScreenCast/Models/Viewer.cs b/Remotely_ScreenCast/Models/Viewer.cs index e1a73f86..7be0b7cd 100644 --- a/Remotely_ScreenCast/Models/Viewer.cs +++ b/Remotely_ScreenCast/Models/Viewer.cs @@ -19,8 +19,8 @@ namespace Remotely_ScreenCast.Models public double Latency { get; set; } = 1; public int PendingFrames { get; set; } - private long imageQuality = 1; - public long ImageQuality + private double imageQuality = 1; + public double ImageQuality { get { @@ -28,29 +28,14 @@ namespace Remotely_ScreenCast.Models } set { - if (imageQuality > 100 || imageQuality < 0) + if (imageQuality > 1 || imageQuality < 0) { return; } imageQuality = value; - EncoderParams = new EncoderParameters() - { - Param = new EncoderParameter[] - { - new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, value) - } - }; } } public bool FullScreenRefreshNeeded { get; internal set; } - public EncoderParameters EncoderParams { get; private set; } = new EncoderParameters() - { - Param = new EncoderParameter[] - { - new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 100L) - } - }; - } }