title: Changing a region of the image to "color" in c
body: <pre><code>void region_set( uint8_t array[], 
           unsigned int cols, 
           unsigned int rows,
           unsigned int left,
           unsigned int top,
           unsigned int right,
           unsigned int bottom,
           uint8_t color )
  {
      for (int x = 0; x &lt; ((right-left)*(bottom-top)); x++)
      {
          array[x] = color;
      }
  }
  </code></pre>
  
  <p>The function of this code is to set every pixel in the region of a certain image array to color.  The region includes all columns from [left, right-1] inclusive and all the rows from [top, bottom-1] inclusive.  I tried testing the program, but when I tested it, my image ended up setting the entire width of the image to the color.  When I tried changing top, left, right or bottom, it only changed the height of the image.  But right and left is supposed to change the width of the image.  My mindset was to have (right-left)*(bottom-top) which would affect all pixels in that region.</p>
  
  <p>The test I used to do this was:</p>
  
  <pre><code>  region_set (img, 256, 256, 100, 80, 156, 160, 128);
  </code></pre>
  
  <p>I don't know why my image always sets the entire width to color and changing left, top, right or bottom only changes the height.  Would anybody be able to help me?</p>