Example #1
0
        public static List <Point> getAllExistingColorPositions(Color color)
        {
            int          searchValue    = color.ToArgb();
            List <Point> ExistingColors = new List <Point>();

            using (Bitmap bmp = GetCaptureUx())
            {
                using (FastBitmap bitmap = new FastBitmap(bmp))
                {
                    bitmap.Lock();

                    for (int x = 0; x < bmp.Width; x++)
                    {
                        for (int y = 0; y < bmp.Height; y++)
                        {
                            if (searchValue == bitmap.GetPixelInt(x, y))
                            {
                                ExistingColors.Add(new Point((Screen.PrimaryScreen.Bounds.Size.Width / 2) - (1024 / 2) + x, (Screen.PrimaryScreen.Bounds.Size.Height / 2) - (768 / 2) + y));
                            }
                        }
                    }
                }
            }

            return(ExistingColors);
        }
Example #2
0
        public static Point?GetColorPosition(Color color)
        {
            int searchValue = color.ToArgb();

            using (Bitmap bmp = GetCaptureUx())
            {
                using (FastBitmap bitmap = new FastBitmap(bmp))
                {
                    bitmap.Lock();

                    for (int x = 0; x < bmp.Width; x++)
                    {
                        for (int y = 0; y < bmp.Height; y++)
                        {
                            if (searchValue == bitmap.GetPixelInt(x, y))
                            {
                                return(new Point((Screen.PrimaryScreen.Bounds.Size.Width / 2) - (1024 / 2) + x, (Screen.PrimaryScreen.Bounds.Size.Height / 2) - (768 / 2) + y));
                            }
                        }
                    }
                }
            }
            return(null);
        }