为啥我窗口背景颜色都一样,但是不同点获得的argb值都不同啊???
下面有图,不同的俩点,获取的像素颜色argb值都不一样。。救救孩子代码如下
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;namespace 窗口测试
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }        private void Form1_Load(object sender, EventArgs e)
        {        }
        [DllImport("gdi32.dll")]
        public static extern System.UInt32
            GetPixel(IntPtr hdc, int xPos, int yPos);
        [DllImport("user32.dll")]
        public static extern IntPtr
            GetDC(IntPtr hwnd);
        [DllImport("user32.dll")]
        private static extern IntPtr
            ReleaseDC(IntPtr hc, IntPtr hDest);        public Color GetPixelColor(int x, int y)//函数
        {
            IntPtr hdc = GetDC(IntPtr.Zero);
            uint pixel = GetPixel(hdc, x, y);
            ReleaseDC(IntPtr.Zero, hdc);
            Color color = Color.FromArgb((int)(pixel & 0x000000FF), (int)(pixel & 0x0000FF00) >> 8, (int)(pixel & 0x00FF0000) >> 16);
            color = Color.FromArgb(color.ToArgb());
            return color;        }        List<Point> lp = new List<Point>();
               private void Form1_MouseDown_1(object sender, MouseEventArgs e)
        {
            Graphics g = this.CreateGraphics();
            g.FillRectangle(Brushes.Red, e.X, e.Y, 5, 5);
            lp.Add(e.Location);
            label1.Text = GetPixelColor(e.X, e.Y).ToString();
            g.Dispose();
        }
    }
}