title: Crop BMP file image in c program
body: <p>My function is getting an Image and I am trying to crop the BMP image 
  by size: 100 x 100, 200 x 200, 300 x 300, 400 x 400 by Pixels , 
  i don't know what to do make it work.  please help me </p>
  
  <p>The size of the image is int height and int width and the function knows the values in pixels.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>void re_allocate_pixels(struct RGB_Image *image, int new_height, int new_width)
  {
      int org_height = image-&gt;height;
      int org_width = image-&gt;width;
      int org_size = image-&gt;size;
      int i;
      struct Pixel **pxls;
      pxls = (struct Pixel **)malloc((org_height) * sizeof(struct Pixel *));
      if (pxls == NULL)
      {
          printf("Memory allocation failed\n");
          exit(1);
      }
      for (i = 0; i &lt; org_height; i++)
      {
          pxls[i] = (struct Pixel *)malloc(org_width * sizeof(struct Pixel));
          if (pxls[i] == NULL)
          {
              printf("Memory allocation failed\n");
              exit(1);
          }
      }
       //i have no idea what to do next to crop the image and pixecl 
      /*for (int j = 0; j &lt; org_height; j++)
      {
          for (int k = 0; k &lt; org_width; k++)
          {
              pxls[i][j] = pxls[k][j];
          }
      }*/
  }
  </code></pre>
  
  <p>here are struct data:</p>
  
  <pre><code>    struct Pixel
      {
          unsigned char red;
          unsigned char green;
          unsigned char blue;
      };
      struct RGB_Image
      {
          char file_name[MAX_FILE_NAME_SIZE];
          long height;
          long width;
          long size;
          struct Pixel **pixels;
      };
  </code></pre>
  
  <p>here is how am calling this function </p>
  
  <pre><code>struct RGB_Image *rgb_img_ptr;
  struct RGB_Image image;
  rgb_img_ptr = &amp;image;
  int image_load_ret_value = load_image(rgb_img_ptr);
  re_allocate_pixels(rgb_img_ptr, 100,100); // here is calling 
  </code></pre>