Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main(int argc, char **argv) {
- struct Png image;
- int index = 0, key;
- int x0 = 0, y0 = 0, x1 = 0, y1 = 0, x2 = 0, y2 = 0, line_fat = 0, flag = 0;
- int Red = 0, Green = 0, Blue = 0;
- int x_photos = 1, y_photos = 1;
- char* output = argv[1];
- read_png_file(argv[1], &image);
- int width_pixel = process_file(&image);
- const struct option firstCordStruct = {"first", required_argument, NULL, 'f'};
- const struct option secondCordStruct = {"second", required_argument, NULL, 's'};
- const struct option thirdCordStruct = {"third", required_argument, NULL, 't'};
- const struct option fatLineStruct = {"line", required_argument, NULL, 'l'};
- const struct option castStruct = {"cast", required_argument, NULL, 'c'};
- const struct option xPhotosStruct = {"xPhoto", required_argument, NULL, 'x'};
- const struct option yPhotosStruct = {"yPhoto", required_argument, NULL, 'y'};
- const struct option colorStruct = {"color", required_argument, NULL, 'C'};
- const struct option outputStruct = {"output", required_argument, NULL, 'o'};
- opterr = 0;
- if(argc == 1 || !strcmp(argv[2], "help")){
- printHelp();
- return 0;
- }else if(!strcmp(argv[2], "info")){
- print_info(&image);
- return 0;
- }else if(!strcmp(argv[2], "triangle")) {
- struct option options[] = {firstCordStruct, secondCordStruct, thirdCordStruct, fatLineStruct,
- castStruct, colorStruct, outputStruct};
- while((key = getopt_long(argc, argv, "f:s:t:l:c:C:o:", options, &index)) != -1) {
- choice("triangle", key, &x0, &y0, &x1, &y1, &x2, &y2, &line_fat,
- &flag, &output, &Red, &Green, &Blue, 0, 0);
- }
- print_triangle(&image, width_pixel, x0, y0, x1, y1, x2, y2, line_fat, flag, Red, Green, Blue);
- write_png_file(output, &image);
- }else if(!strcmp(argv[2], "line")) {
- struct option options[] = {firstCordStruct, secondCordStruct, fatLineStruct, colorStruct,
- outputStruct};
- while((key = getopt_long(argc, argv, "f:s:l:C:o:", options, &index)) != -1) {
- choice("line", key, &x0, &y0, &x1, &y1, 0, 0, &line_fat,
- 0, &output, &Red, &Green, &Blue, 0, 0);
- }
- paint_line(&image, width_pixel, x0, y0, x1, y1, line_fat, Red, Green, Blue);
- write_png_file(output, &image);
- }else if(!strcmp(argv[2], "collage")) {
- struct option options[] = {xPhotosStruct, yPhotosStruct, outputStruct};
- while((key = getopt_long(argc, argv, "x:y:o:", options, &index)) != -1) {
- choice("collage", key, 0, 0, 0, 0, 0, 0, 0,
- 0, &output, 0, 0, 0, &x_photos, &y_photos);
- }
- make_collage(&image, width_pixel, x_photos, y_photos);
- write_png_file(output, &image);
- }
- for (int y = 0; y < image.height; y++)
- free(image.row_pointers[y]);
- free(image.row_pointers);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement