Код | using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Drawing.Imaging; using System.IO; namespace ScreenCapturre { public partial class Form1 : Form { private Bitmap captured;
public Form1() { InitializeComponent(); }
private void button1_Click(object sender, EventArgs e) { Rectangle bounds = Screen.PrimaryScreen.Bounds; int colourDepth = Screen.PrimaryScreen.BitsPerPixel; PixelFormat format; switch (colourDepth) { case 8: case 16: format = PixelFormat.Format16bppRgb565; break;
case 24: format = PixelFormat.Format24bppRgb; break;
case 32: format = PixelFormat.Format32bppArgb; break;
default: format = PixelFormat.Format32bppArgb; break; }
captured = new Bitmap(bounds.Width, bounds.Height, format); Graphics gdi = Graphics.FromImage(captured); gdi.CopyFromScreen(bounds.Left, bounds.Top, 0, 0, bounds.Size); MemoryStream buf = new MemoryStream(); captured.Save(buf, ImageFormat.Bmp); byte [] currentImage = buf.GetBuffer();
MessageBox.Show("Succesful"); } } }
|
Добрый день хочу написать примитивную программу которая сможет найти координаты пикселя по параметрам RGB например красный (R=1,G=0,B=0) и тд. Вычитал рекомендацию что это нужно реализовать через byte[] что бы обеспечить нормальную скорость работы, но как найти там нужный цвет и тем более его координаты? Спасибо. |