diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-03-01 01:30:14 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-03-01 01:30:14 +0200 |
| commit | fcbfe9a519b9d9d9850e57e08c6033d56ed98e17 (patch) | |
| tree | a6de78ad2819f748b020e7de0549bb64abb3aef3 /Software/Visual_Studio/Tango.ScreenCapture/DirectBitmap.cs | |
| parent | eb5e79f5dc4983612b1716cf6e52323dc0da0ba6 (diff) | |
| download | Tango-fcbfe9a519b9d9d9850e57e08c6033d56ed98e17.tar.gz Tango-fcbfe9a519b9d9d9850e57e08c6033d56ed98e17.zip | |
Working on Tango.ScreenCapture/RemoteDesktop.
Diffstat (limited to 'Software/Visual_Studio/Tango.ScreenCapture/DirectBitmap.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.ScreenCapture/DirectBitmap.cs | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.ScreenCapture/DirectBitmap.cs b/Software/Visual_Studio/Tango.ScreenCapture/DirectBitmap.cs new file mode 100644 index 000000000..fac39cc04 --- /dev/null +++ b/Software/Visual_Studio/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(); + } + } +} |
