diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2020-03-03 18:56:58 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2020-03-03 18:56:58 +0200 |
| commit | c38f1c80f1fbdfdb758c5a0b93d045a9a5b526ad (patch) | |
| tree | 20cc57b06f4260b6f86fdaca04129e1a8ace53cd /Software/Experiments | |
| parent | 1b0bdf6f8148e9cc4e7e07e41e9e2d75039c1349 (diff) | |
| download | Tango-c38f1c80f1fbdfdb758c5a0b93d045a9a5b526ad.tar.gz Tango-c38f1c80f1fbdfdb758c5a0b93d045a9a5b526ad.zip | |
Machine Studio v4.1.2
PPC v1.1.5
Added BYPASS_ROCKERS to SQLExaminer config.
Started integrating FSE Remote/Console To PPC.
Added support for generic continuous request.
Diffstat (limited to 'Software/Experiments')
3 files changed, 77 insertions, 16 deletions
diff --git a/Software/Experiments/Tango.RemoteDesktop/Tango.RemoteDesktop/Clipping/BitmapCliper.cs b/Software/Experiments/Tango.RemoteDesktop/Tango.RemoteDesktop/Clipping/BitmapCliper.cs index 4f93eeb66..5bd8beaa3 100644 --- a/Software/Experiments/Tango.RemoteDesktop/Tango.RemoteDesktop/Clipping/BitmapCliper.cs +++ b/Software/Experiments/Tango.RemoteDesktop/Tango.RemoteDesktop/Clipping/BitmapCliper.cs @@ -30,8 +30,8 @@ namespace Tango.RemoteDesktop.Clipping //determine top for (int i = 0; i < rgbValues.Length; i++) { - int color = rgbValues[i] & 0x00ffffff; - if (color != 0x00ffffff) + int color = rgbValues[i] & 0xffffff; + if (color != 0x0) { int r = i / bd.Width; int c = i % bd.Width; @@ -53,8 +53,8 @@ namespace Tango.RemoteDesktop.Clipping //determine bottom for (int i = rgbValues.Length - 1; i >= 0; i--) { - int color = rgbValues[i] & 0x00ffffff; - if (color != 0x00ffffff) + int color = rgbValues[i] & 0xffffff; + if (color != 0x0) { int r = i / bd.Width; int c = i % bd.Width; @@ -79,8 +79,8 @@ namespace Tango.RemoteDesktop.Clipping //determine left for (int c = 0; c < left; c++) { - int color = rgbValues[r * bd.Width + c] & 0x00ffffff; - if (color != 0x00ffffff) + int color = rgbValues[r * bd.Width + c] & 0xffffff; + if (color != 0x0) { if (left > c) { @@ -93,8 +93,8 @@ namespace Tango.RemoteDesktop.Clipping //determine right for (int c = bd.Width - 1; c > right; c--) { - int color = rgbValues[r * bd.Width + c] & 0x00ffffff; - if (color != 0x00ffffff) + int color = rgbValues[r * bd.Width + c] & 0xffffff; + if (color != 0x0) { if (right < c) { @@ -128,9 +128,7 @@ namespace Tango.RemoteDesktop.Clipping //create new image Bitmap newImage = new Bitmap(width, height, PixelFormat.Format32bppArgb); - BitmapData nbd - = newImage.LockBits(new Rectangle(0, 0, width, height), - ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); + BitmapData nbd = newImage.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); Marshal.Copy(imgData, 0, nbd.Scan0, imgData.Length); newImage.UnlockBits(nbd); @@ -140,5 +138,67 @@ namespace Tango.RemoteDesktop.Clipping Bounds = new Rectangle(left, top, width, height) }; } + + public static ClipResult ClipBitmap2(Bitmap bmp) + { + // Initialize variables + //var cropColor = Color.White; + + var bottom = 0; + var left = bmp.Width; // Set the left crop point to the width so that the logic below will set the left value to the first non crop color pixel it comes across. + var right = 0; + var top = bmp.Height; // Set the top crop point to the height so that the logic below will set the top value to the first non crop color pixel it comes across. + + var bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, bmp.PixelFormat); + + unsafe + { + var dataPtr = (byte*)bmpData.Scan0; + + for (var y = 0; y < bmp.Height; y++) + { + for (var x = 0; x < bmp.Width; x++) + { + var rgbPtr = dataPtr + (x * 4); + + //var b = rgbPtr[0]; + //var g = rgbPtr[1]; + //var r = rgbPtr[2]; + var a = rgbPtr[3]; + + // If any of the pixel RGBA values don't match and the crop color is not transparent, or if the crop color is transparent and the pixel A value is not transparent + if (a > 0) + { + if (x < left) + left = x; + + if (x >= right) + right = x + 1; + + if (y < top) + top = y; + + if (y >= bottom) + bottom = y + 1; + } + } + + dataPtr += bmpData.Stride; + } + } + + bmp.UnlockBits(bmpData); + + if (left < right && top < bottom) + { + return new ClipResult() + { + Bitmap = bmp.Clone(new Rectangle(left, top, right - left, bottom - top), bmp.PixelFormat), + Bounds = new Rectangle(left, top, right - left, bottom - top), + }; + } + + return null; // Entire image should be cropped, so just return null + } } } diff --git a/Software/Experiments/Tango.RemoteDesktop/Tango.RemoteDesktop/Tango.RemoteDesktop.csproj b/Software/Experiments/Tango.RemoteDesktop/Tango.RemoteDesktop/Tango.RemoteDesktop.csproj index f760b43dc..de790ca10 100644 --- a/Software/Experiments/Tango.RemoteDesktop/Tango.RemoteDesktop/Tango.RemoteDesktop.csproj +++ b/Software/Experiments/Tango.RemoteDesktop/Tango.RemoteDesktop/Tango.RemoteDesktop.csproj @@ -35,16 +35,16 @@ <Reference Include="PresentationCore" /> <Reference Include="PresentationFramework" /> <Reference Include="SharpDX"> - <HintPath>..\..\..\..\..\..\DATA\Development\WpfVideoTools\WpfVideoTools\Resources\Referenced Assemblies\SharpDX.dll</HintPath> + <HintPath>..\..\..\Visual_Studio\Referenced Assemblies\SharpDX\SharpDX.dll</HintPath> </Reference> <Reference Include="SharpDX.Direct3D11"> - <HintPath>..\..\..\..\..\..\DATA\Development\WpfVideoTools\WpfVideoTools\Resources\Referenced Assemblies\SharpDX.Direct3D11.dll</HintPath> + <HintPath>..\..\..\Visual_Studio\Referenced Assemblies\SharpDX\SharpDX.Direct3D11.dll</HintPath> </Reference> <Reference Include="SharpDX.DXGI"> - <HintPath>..\..\..\..\..\..\DATA\Development\WpfVideoTools\WpfVideoTools\Resources\Referenced Assemblies\SharpDX.DXGI.dll</HintPath> + <HintPath>..\..\..\Visual_Studio\Referenced Assemblies\SharpDX\SharpDX.DXGI.dll</HintPath> </Reference> <Reference Include="SharpDX.Mathematics"> - <HintPath>..\..\..\..\..\..\DATA\Development\WpfVideoTools\WpfVideoTools\Resources\Referenced Assemblies\SharpDX.Mathematics.dll</HintPath> + <HintPath>..\..\..\Visual_Studio\Referenced Assemblies\SharpDX\SharpDX.Mathematics.dll</HintPath> </Reference> <Reference Include="System" /> <Reference Include="System.Core" /> diff --git a/Software/Experiments/Tango.RemoteDesktop/WpfApp1/MainWindow.xaml.cs b/Software/Experiments/Tango.RemoteDesktop/WpfApp1/MainWindow.xaml.cs index 6bd0b7a23..7953e9666 100644 --- a/Software/Experiments/Tango.RemoteDesktop/WpfApp1/MainWindow.xaml.cs +++ b/Software/Experiments/Tango.RemoteDesktop/WpfApp1/MainWindow.xaml.cs @@ -40,8 +40,9 @@ namespace WpfApp1 _engine = new RasterScreenCaptureEngine() { - CaptureRegion = new CaptureRegion(0, 0, 1280, 800) + CaptureRegion = new CaptureRegion(1920 + 1920, 0, 1280, 800) }; + _engine.CaptureMethod = new GdiScreenCapture(); _engine.FrameRate = 5; //Per second _engine.CaptureCursor = true; _engine.FrameReceived += _engine_FrameReceived; |
