title: Changing an images size/resolution using struct and pointers in C
body: <p>we have been giving a task to complete at our school where we need to alter an image (invert colors, switch colors, rotate it by 90 degrees, double the size, zoom in on it) and right now I'm trying to double its size by doubling it's resolution but can't figure out how to access that address and change it.
  We've been given two functions, one that can load an image and other that can save the image, so we don't need to worry about that, we've also been given two structs, one with rgb values and one with height and width(in pixels).</p>
  
  <p>I've been looking around but haven't really found anything that works, or I'm just doing it wrong. I've also tried multiple things without success.</p>
  
  <p>Here is my main.c :</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;math.h&gt;
  #include "studentFunctions.h"
  
  int main()
  {
      Image plain;
      char selection;
      readImage("test.png", &amp;plain);
  
      printf("What do you wish to do?\nInvert colors = i.\nSwitch colors = s.\nDoulbe size = d.");
      scanf("%c", &amp;selection);
  
      switch (selection)
      {
  
      case 'i':
          invertColor(plain);
          break;
  
      case 's':
          switchColor(plain);
          break;
  
      case 'd':
          makeBigger(plain);
          break;
      }
  
      printf("Saving PNG\n");
      writeImage("test.png", &amp;plain);
  
      return 0;
      }
  </code></pre>
  
  <p>here is my function.c :</p>
  
  <pre><code>#include "studentFunctions.h"
  
  
  void invertColor(Image plain)
  {
      for (unsigned int i = 0; i &lt; plain.height; i++)
      {
          for (unsigned int j = 0; j &lt; plain.width; j++)
          {
              plain.pixels[i][j].r = 255 - (plain.pixels[i][j].r);
              plain.pixels[i][j].g = 255 - (plain.pixels[i][j].g);
              plain.pixels[i][j].b = 255 - (plain.pixels[i][j].b);
          }
      }
  }
  
  void switchColor(Image plain)
  {
      int temp;
  
      for (unsigned int i = 0; i &lt; plain.height; i++)
      {
          for (unsigned int j = 0; j &lt; plain.width; j++)
          {
              temp = plain.pixels[i][j].r;
  
              plain.pixels[i][j].r = plain.pixels[i][j].b;
              plain.pixels[i][j].b = plain.pixels[i][j].g;
              plain.pixels[i][j].g = temp;
          }
      }
  }
  
  void makeBigger(Image* plain)
  {
      *plain-&gt;height *= 2;
      *plain-&gt;width *= 2;
  
  }
  </code></pre>
  
  <p>as you see I tried to point at the plain.height and plain.width to change the image resolution but this doesn't work. When hovering over "plain" it says "operand of '*' must be a pointer". What does this actually mean, and what is the correct way to do this?</p>
  
  <p>The two functions we were giving looks like this:</p>
  
  <pre><code>void writeImage(char* filename, Image *img);
  </code></pre>
  
  <p>and</p>
  
  <pre><code>void readImage(char *filename, Image *img);
  </code></pre>
  
  <p>and the two structs we were giving are: </p>
  
  <pre><code>typedef struct image {
  Pixel **pixels;
  unsigned int height;
  unsigned int width;
  } Image;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>typedef struct pixel {
  uint8_t r;
  uint8_t g;
  uint8_t b;
  } Pixel;
  </code></pre>
  
  <p>We can't edit or see the two given function nor the two structs.</p>
  
  <p>Preferable I'd like an explanation of this and maybe a simple example, rather than a straight answer, as I am trying to learn and understand this. As last note I'm new to programming in general and especially in C, hope it's clear enough.
  Thanks for answer.</p>
  
  <p>Edit:
  Here is my header file:</p>
  
  <pre><code>#ifndef STUDENTFUNCTIONS_H
  #define STUDENTFUNCTIONS_H
  
  #include &lt;functions.h&gt;
  
  void invertColor(Image plain);
  void switchColor(Image plain);
  void makeBigger(Image* plain);
  
  #endif
  </code></pre>