Exemple #1
0
int main(int argc, char *argv[])
{
	char *filename = malloc(strlen(argv[1]) + 4 + 1);
	char *filenameWrite = malloc(strlen(argv[1]) + 8 + 1);
	long double *imageArray;
	long double *imageBlurred;
	int x, y, z;

    sprintf(filename, "%s.txt", argv[1]);
    sprintf(filenameWrite, "%s_out.txt", argv[1]);

	x = strtol(argv[2], NULL, 10);
	y = strtol(argv[3], NULL, 10);
	z = strtol(argv[4], NULL, 10);

    imageArray = malloc(sizeof(long double) * x * y * z);
    imageBlurred = malloc(sizeof(long double) * x * y * z);

    read_file_to_array(x, y, z, filename, imageArray);
    blur_image(x, y, z, imageArray, imageBlurred);
    write_array_to_file(x, y, z, filenameWrite, imageBlurred);

    free(imageArray);
    free(imageBlurred);

    free(filename);
    free(filenameWrite);

	return 0;
}
Exemple #2
0
int main(int argc, char *argv[]) {
    long   file_size;
    byte_t    *file_bytes;
    char    input_file_name[MAX_FILE_NAME_SIZE];
    char    output_file_name[MAX_FILE_NAME_SIZE];
    int     i;

    if (argc != 3) {
        printf("Usage: %s <input_file_name> <output_file_name>\n", argv[0]);
        exit(1);
    }

    strcpy(input_file_name, argv[1]);
    strcpy(output_file_name, argv[2]);
    
    file_size = get_file_size(input_file_name);
    file_bytes = malloc(file_size*sizeof(*file_bytes));
    read_file_to_array(input_file_name, file_bytes, file_size);

    printf("    %02x ", file_bytes[0]);
    for (i = 1; i < file_size; i++) {
        if (i % 16 == 0)
            printf("\n    ");
        else if (i % 4 == 0)
            printf(" ");
        printf("%02X ", file_bytes[i]);
    }
    printf("\n");

    for (i = 0; i < file_size; i++)
        file_bytes[i] ^= 0xFF; 

    write_array_to_file(output_file_name, file_bytes, file_size);

    free (file_bytes);
    return 0;
}