Here is someone's program, which i need for my project to collect data. I'm unable to understand where is the command #define IMAGE argv[1]
#define IFS argv[2]
pointing to and what are the values being defined in the IMAGE and IFS. These two command are necessary as they are later on required to for reading a file name.
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <alloc.h>
#define IMAGE argv[1]
#define IFS argv[2]
get_image(FILE *ifs_file, unsigned int *assumed_width_of_image, unsigned int
*assumed_height_of_image, unsigned int *width_of_image, unsigned int *height_of_image, char *argv[]);
unsigned int *image;
main(int argc, char *argv[])
{
unsigned char dom[4][4], d1[4][4], ran[8][8], lowest_error, sym, bestsym, domain_whites,range_whites;
unsigned int assumed_width_of_image, assumed_height_of_image, width_of_image,
height_of_image;
unsigned long int count, domx, domy, ranx, rany, bestranx;
time_t start_time;
FILE *ifs_file;
start_time = time(NULL);
if (argc != 3) {
printf("\nUse the following format:\n\ncompress [image_file] [ifs_file]\n\n");
exit
}
if ((ifs_file = fopen(IFS, "wb")) == NULL) {
fprintf(stderr, "\nError opening file %s\n", IFS);
exit(1);
}
get_image(ifs_file, &assumed_width_of_image, &assumed_height_of_image, &width_of_image, &height_of_image, argv);
get_image(FILE *ifs_file, unsigned int *assumed_width_of_image, unsigned int
*assumed_height_of_image, unsigned int *width_of_image, unsigned int *height_of_image, char *argv[])
{
FILE *image_file;
unsigned int buf[24], *header, size_of_header, extra_height;
unsigned long size_of_file, size_of_image;
if ((image_file = fopen(IMAGE, "rb")) == NULL) {
fprintf(stderr, "\nCannot open file %s\n", IMAGE);
exit(1);
}
if (fread(buf, sizeof(unsigned int), 24, image_file) != 24) {
fprintf(stderr, "\nError reading file %s\n", IMAGE);
exit(1);
}
if (buf[0] != 19778) {
printf("%s is not a .BMP file", IMAGE);
exit(0);
}
if (buf[23] != 2) {
printf("%s is not a black and white image", IMAGE);
exit(0);
}