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); }
/// <summary> /// Locks this bitmap into memory and returns a FastBitmap that can be used to manipulate its pixels /// </summary> /// <param name="bitmap">The bitmap to lock</param> /// <param name="lockFormat">The underlying pixel format to use when locking the bitmap</param> /// <returns>A locked FastBitmap</returns> public static FastBitmap FastLock(this Bitmap bitmap, FastBitmapLockFormat lockFormat) { var fast = new FastBitmap(bitmap); fast.Lock(lockFormat); return(fast); }
/// <summary> /// Locks this bitmap into memory and returns a FastBitmap that can be used to manipulate its pixels /// </summary> /// <param name="bitmap">The bitmap to lock</param> /// <returns>A locked FastBitmap</returns> public static FastBitmap FastLock(this Bitmap bitmap) { var fast = new FastBitmap(bitmap); fast.Lock(); return(fast); }
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); }