GetPixel() публичный Метод

public GetPixel ( Point point ) : int
point Point
Результат int
Пример #1
0
        public static int AbsoluteDiff(FastBitmap bmp1, FastBitmap bmp2, Rectangle sub_rect)
        {
            int diff = 0;

            for (int y = sub_rect.Y; y < sub_rect.Y + sub_rect.Height; y++)
            {
                for (int x = sub_rect.X; x < sub_rect.X + sub_rect.Width; x++)
                {
                    diff += AbsoluteDiff(Color.FromArgb(bmp1.GetPixel(x, y)), Color.FromArgb(bmp2.GetPixel(x, y)));
                }
            }

            return(diff);
        }
Пример #2
0
        public static Rectangle BoundingRectangle(Bitmap bmp, Rectangle bounds, int bound_color)
        {
            FastBitmap fbmp = new FastBitmap(bmp);
            int        s_x = 0, e_x = 0, s_y = 0, e_y = 0; bool done = false;

            for (int x = bounds.X; x < bounds.X + bounds.Width && !done; x++)
            {
                for (int y = bounds.Y; y < bounds.Y + bounds.Height; y++)
                {
                    if (fbmp.GetPixel(x, y) == bound_color)
                    {
                        s_x  = x;
                        done = true;
                        break;
                    }
                }
            }
            done = false;
            for (int x = bounds.X + bounds.Width - 1; x >= bounds.X && !done; x--)
            {
                for (int y = bounds.Y; y < bounds.Y + bounds.Height; y++)
                {
                    if (fbmp.GetPixel(x, y) == bound_color)
                    {
                        e_x  = x;
                        done = true;
                        break;
                    }
                }
            }
            done = false;
            for (int y = bounds.Y; y < bounds.Y + bounds.Height && !done; y++)
            {
                for (int x = bounds.X; x < bounds.X + bounds.Width; x++)
                {
                    if (fbmp.GetPixel(x, y) == bound_color)
                    {
                        s_y  = y;
                        done = true;
                        break;
                    }
                }
            }
            done = false;
            for (int y = bounds.Y + bounds.Height - 1; y >= bounds.Y && !done; y--)
            {
                for (int x = bounds.X; x < bounds.X + bounds.Width; x++)
                {
                    if (fbmp.GetPixel(x, y) == bound_color)
                    {
                        e_y  = y;
                        done = true;
                        break;
                    }
                }
            }

            fbmp.UnlockBitmap();

            //Console.WriteLine(s_x + " " + e_x + " " + s_y + " " + e_y);

            Rectangle crop_rect = new Rectangle(s_x, s_y, e_x - s_x + 1, e_y - s_y + 1);


            return(crop_rect);
        }
Пример #3
0
 public bool IsMatch(FastBitmap bitmap)
 {
     return(bitmap.GetPixel(X, Y) == color);
 }