(b) To get the pixels from an actual JPEG image, the image has to
be decompressed first. A library jpeg
is provided, which contains
the following function defined in jpeg:h that decompresses a JPEG
image:
// this function reads a JPEG image from file named
// input_file_name
// and stores the pixel data in the file named
// output_file_name
// The function returns the number of bytes written
int loadJPG(const char* input_file_name,
const char * output_file_name);
The output le is a binary le where the rst item is an integer
representing the width of the image, the second item is an integer
representing the height, and then the pixel data follows in the same
way as described in a). Write a function that first calls loadJPG
to decompress the image and then reads into memory the pixel data
written by loadJPG Your function should have the following header:
unsigned char * get_pixels(char * filename,
int *width, int *height);
The function returns a pointer to where the pixel data is stored in
memory and also returns the width and height of the image in pa-
rameters width and height.