Пример #1
0
        void sampleRooms(Color color)
        {

            int minX = 0;
            int maxX = width;
            int minY = 0;
            int maxY = height;
            int lowestX = width;
            int lowestY = height;
            int heighestX = 0;
            int heighestY = 0;






            for (int sy = 0; sy < height; sy++)
            {


                for (int sx = 0; sx < width; sx++)
                {
                    if (img[(width * sy) + sx] == color && sx < maxX && maxX < width && sx < lowestX)
                    {
                        minX = sx;
                        if (sx < lowestX)
                            lowestX = sx;
                    }
                    if (img[(width * sy) + sx] == color && sx > minX && sx > heighestX)
                    {
                        maxX = sx;
                        heighestX = sx;
                    }

                    if (img[(width * sy) + sx] == color && sy > minY && maxY < height && sy < lowestY)
                    {
                        minY = sy;
                        if (sy < lowestY)
                            lowestY = sy;
                    }
                    if (img[(width * sy) + sx] == color && sy > minY && sy > heighestY)
                    {
                        maxY = sy;
                        heighestY = sy;
                    }


                }

            }

           
                Sampled s = new Sampled(color, lowestX, lowestY, heighestX, heighestY);
                foreach(Sampled te in samples)
                    if(te.getColor()==s.getColor())
                        samples.Remove(te);
                samples.Add(s);
            
        }
Пример #2
0
        void color(int roomNumber)
        {
            Sampled output = null;
            foreach (Sampled s in samples)
            {
                if (s.getColor().R == roomNumber)
                {
                    output = s;
                }
            }
            if (output != null)
            {

                try
                {


                    int topbounds = output.getTop();
                    int leftbounds = output.getLeft();
                    int rightbounds = output.getRight();
                    int bottombounds = output.getBottom();

                    int tempwidth = rightbounds - leftbounds;
                    int tempheight = bottombounds - topbounds;
                    //throw new MyException("left: " + output.getLeft() + " ,right: " + output.getRight() + " ,top: " + output.getTop() + " ,bottom: " + output.getBottom()+" ,widthbounds: "+tempwidth+" ,heightbounds: "+tempheight+"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");


                    for (int y = 0; y < tempheight; y++)
                    {
                        for (int x = 0; x < tempwidth; x++)
                        {
                            if (img[width * (y + topbounds) + (x + leftbounds)] == output.getColor())
                            {
                                //img[width * (y + topbounds) + (x + rightbounds)] = -39424;


                                image.SetPixel(x + leftbounds, y + topbounds, highlight);
                            }

                        }
                    }
                }
                catch (Exception e)
                {
                    throw new ApplicationException(output.toString(), e);
                }
            }
        }
Пример #3
0
        void sampleRooms(Color color)
        {
            int minX = 0;
            int maxX = width;
            int minY = 0;
            int maxY = height;
            int lowestX = width;
            int lowestY = height;
            int heighestX = 0;
            int heighestY = 0;

            for (int sy = 0; sy < height; sy++)
            {

                for (int sx = 0; sx < width; sx++)
                {
                    if (img[(width * sy) + sx] == color && sx < maxX && maxX < width && sx < lowestX)
                    {
                        minX = sx;
                        if (sx < lowestX)
                            lowestX = sx;
                    }
                    if (img[(width * sy) + sx] == color && sx > minX && sx > heighestX)
                    {
                        maxX = sx;
                        heighestX = sx;
                    }

                    if (img[(width * sy) + sx] == color && sy > minY && maxY < height && sy < lowestY)
                    {
                        minY = sy;
                        if (sy < lowestY)
                            lowestY = sy;
                    }
                    if (img[(width * sy) + sx] == color && sy > minY && sy > heighestY)
                    {
                        maxY = sy;
                        heighestY = sy;
                    }

                }

            }

                Sampled s = new Sampled(color, lowestX, lowestY, heighestX, heighestY);
                foreach(Sampled te in samples)
                    if(te.getColor()==s.getColor())
                        samples.Remove(te);
                samples.Add(s);
        }