#include <bmp.h>
#include <image.h>
#include <io.h>
#include <stdio.h>

int main( int argc, char** argv ) {
    if(argc != 4) {
        fprintf(stderr, "Error: invalid count of arguments!");
        return 1;
    }

    struct image first_image = {0};

    FILE* source = fopen(argv[1], "rb");
    if(!source) return 2; 
    enum read_status status_r = from_bmp(source, &first_image);
    if(status_r != READ_OK) return 12; 
    fclose(source);

    struct image second_image = {0};
    transform_image(&first_image, &second_image, argv[3]);

    FILE* destination = fopen(argv[2], "wb");
    if(!destination) return 4;
    enum write_status status_w = to_bmp(destination, &second_image);
    if(status_w != WRITE_OK) return 3;
    fclose(destination);

    return 0;
}