コード例 #1
0
        /// <summary>
        /// Gets a rectangle containing the minimap with the non-minimap corners set to false
        /// </summary>
        /// <param name="filter">the filter to use on the minimap</param>
        /// <param name="offset">gets set to the offset from the game screen to the minimap piece</param>
        /// <returns>true for the pixels on the minimap that match the filter</returns>
        public bool[,] MinimapFilter(ColorFilter filter, out Point offset)
        {
            if (Screen.Width < 1)    //the screen has not been read yet
            {
                offset = new Point(0, 0);
                return(null);
            }

            int    left   = ScreenWidth - OFFSET_LEFT;
            int    right  = left + WIDTH - 1;
            int    top    = OFFSET_TOP;
            int    bottom = top + HEIGHT - 1;
            Point  center = new Point((left + right) / 2, (top + bottom) / 2);
            double radius = CLICK_RADIUS;
            double distance;

            offset = new Point(left, top);
            bool[,] minimapFilter = new bool[right - left + 1, bottom - top + 1];

            for (int x = left; x <= right; x++)
            {
                for (int y = top; y <= bottom; y++)
                {
                    distance = Math.Sqrt(Math.Pow(x - center.X, 2) + Math.Pow(y - center.Y, 2));
                    if (distance <= radius)
                    {
                        minimapFilter[x - left, y - top] = filter.ColorInRange(Screen[x, y]);
                    }
                }
            }

            return(minimapFilter);
        }
コード例 #2
0
        /// <summary>
        /// Filters a portion of the rgbImage into a binary image
        /// </summary>
        /// <param name="rgbImage">unfiltered image</param>
        /// <param name="filter">color range to use for filtering</param>
        /// <param name="filterPixels">filtered binary image</param>
        /// <param name="xMin">inclusive</param>
        /// <param name="xMax">exclusive</param>
        private static void ColorFilterPiece(Color[,] rgbImage, ColorFilter filter, ref bool[,] filterPixels, int xMin, int xMax)
        {
            Color pixelColor;
            int   height = rgbImage.GetLength(1);

            for (int x = xMin; x < xMax; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    pixelColor         = rgbImage[x, y];
                    filterPixels[x, y] = filter.ColorInRange(pixelColor);
                }
            }
        }