I am building an application that is able to get the pixels of pixels of a part of your screen. I am trying to do this by making the background of a form transparent, so that you can see through the form. The problem is, is that when I use the PanelToBitmap function I am getting the transparent color, instead of the pixels which are actually visible to the user.
Currently I'm using this.
Point point = new Point();
if (point.X > this.Location.X && point.X < this.Location.X + this.Width && point.Y > this.Location.Y + RectangleToScreen(this.ClientRectangle).Top - this.Top && point.Y < this.Location.Y + this.Height)
{
point.X = point.X - this.Location.X;
point.Y = point.Y - this.Location.Y;
Bitmap img = (Bitmap)PanelToBitmap(this);
Color color = img.GetPixel(point.X, point.Y);
form.label1.Text = color.R.ToString();
form.label2.Text = color.G.ToString();
form.label3.Text = color.B.ToString();
}
Is there any function that is able to get the pixels that are actually visible to the user? I was thinking about the GetPixel function in the Gdi32 library, although people say it's slow.