aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Experiments/Tango.RemoteDesktop/Tango.ScreenCapture/DirectBitmap.cs
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-03-02 00:10:25 +0200
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-03-02 00:10:25 +0200
commit6488158b9fd003d690eb015cf9a644112a363f71 (patch)
tree135b4a9b0bd1fb1a977ee2f3e97403f5086b1fb6 /Software/Experiments/Tango.RemoteDesktop/Tango.ScreenCapture/DirectBitmap.cs
parent7e09a1b9f4227e536031a751619869c824a7af35 (diff)
downloadTango-6488158b9fd003d690eb015cf9a644112a363f71.tar.gz
Tango-6488158b9fd003d690eb015cf9a644112a363f71.zip
Implemented Tango.RemoteDesktop using generic Diff Frame.
Diffstat (limited to 'Software/Experiments/Tango.RemoteDesktop/Tango.ScreenCapture/DirectBitmap.cs')
-rw-r--r--Software/Experiments/Tango.RemoteDesktop/Tango.ScreenCapture/DirectBitmap.cs55
1 files changed, 55 insertions, 0 deletions
diff --git a/Software/Experiments/Tango.RemoteDesktop/Tango.ScreenCapture/DirectBitmap.cs b/Software/Experiments/Tango.RemoteDesktop/Tango.ScreenCapture/DirectBitmap.cs
new file mode 100644
index 000000000..fac39cc04
--- /dev/null
+++ b/Software/Experiments/Tango.RemoteDesktop/Tango.ScreenCapture/DirectBitmap.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.ScreenCapture
+{
+ public class DirectBitmap : IDisposable
+ {
+ public Bitmap Bitmap { get; private set; }
+ public Int32[] Bits { get; private set; }
+ public bool Disposed { get; private set; }
+ public int Height { get; private set; }
+ public int Width { get; private set; }
+
+ protected GCHandle BitsHandle { get; private set; }
+
+ public DirectBitmap(int width, int height)
+ {
+ Width = width;
+ Height = height;
+ Bits = new Int32[width * height];
+ BitsHandle = GCHandle.Alloc(Bits, GCHandleType.Pinned);
+ Bitmap = new Bitmap(width, height, width * 4, PixelFormat.Format32bppPArgb, BitsHandle.AddrOfPinnedObject());
+ }
+
+ public void SetPixel(int x, int y, Color colour)
+ {
+ int index = x + (y * Width);
+ int col = colour.ToArgb();
+
+ Bits[index] = col;
+ }
+
+ public Color GetPixel(int x, int y)
+ {
+ int index = x + (y * Width);
+ int col = Bits[index];
+ Color result = Color.FromArgb(col);
+
+ return result;
+ }
+
+ public void Dispose()
+ {
+ if (Disposed) return;
+ Disposed = true;
+ BitsHandle.Free();
+ }
+ }
+}