title: Pixel matrix how to scale
body: <p>I'm doing a sierpinski's carpet program and i managed to create a PGM image from a matrix.I first create a char **matrix which has # or ' ' .# = white color , ' ' = black color, and then i create a int **pixels with values 0 or 255 for black and white, pretty simple. The matrix size is equal to number of iterations of sierpinski's carpet : for 3 iterations of the algorithm i have a resulting matrix(so image) of 27 by 27 pixels. How can i multiply this matrix in order to enlarge the resulting picture but keep the same image.Something like for each pixel i want it to be  4 pixels in the output image. C program.</p>
  
  <p>EDIT: Code for printing a PGM image from a matrix of pixel values</p>
  
  <pre><code>void print(char fout[30],int **pixels,int width,int height){
  
  int i,j;
  FILE *f = fopen(fout,"w");
  fprintf(f,"%s\n","P2");
  fprintf(f,"%d %d\n",width,height);
  fprintf(f,"%d\n",255);
  for(i=height-1;i&gt;=0;i--){
          for(j=0;j&lt;width;j++){
                  fprintf(f,"%d ",pixels[i][j]);
          }
          fprintf(f,"\n");
  }
  
  fclose(f);
  </code></pre>
  
  <p>}</p>
  
  <p>Code for creating the pixel value matrix</p>
  
  <pre><code>for(i=0;i&lt;size;i++)
      for(j=0;j&lt;size;j++)
          if(basegrid[i][j] == ' ')
              pixels[i][j]=0;
          else
              pixels[i][j]=255;
  </code></pre>