Esempio n. 1
0
        public IActionResult Post([FromBody] Command command)
        {
            var values = new RGBValues(Program.systemNode.SendCommand(command));

            if (values.Valid)
            {
                return(Ok(values));
            }
            return(new StatusCodeResult(510));
        }
Esempio n. 2
0
    /*Find average RGB values for a given 'pixel-sized chunk'*/
    RGBValues AveragePixelChunk(Color[] passedVal)
    {
        double avgRed   = 0.0;
        double avgGreen = 0.0;
        double avgBlue  = 0.0;

        for (int i = 0; i < cellWidth * cellHeight; i++)   //Itterate over every pixel in this chunk of pixels
        {
            avgRed   += passedVal [i].r;
            avgGreen += passedVal [i].g;
            avgBlue  += passedVal [i].b;
        }
        //Calculate average r,g,b values for this chunk
        avgRed   = avgRed / (cellWidth * cellHeight);
        avgGreen = avgGreen / (cellWidth * cellHeight);
        avgBlue  = avgBlue / (cellWidth * cellHeight);

        RGBValues rgb = new RGBValues(); //Create reference to our struct

        rgb.avgRedVal   = avgRed;        //Add average values to struct
        rgb.avgGreenVal = avgGreen;
        rgb.avgBlueVal  = avgBlue;
        return(rgb);        //Return our struct with average values in it
    }