hsv2rgb.c
Go to the documentation of this file.00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 #include <malloc.h>
00004 #include <math.h>
00005 #include <string.h>
00006 #include <unistd.h>
00007 #include <ppm.h>
00008
00009 #include "hsv2rgb.proto"
00010
00011 int main(int argc, char *argv[]) {
00012
00013 FILE *ppm_file;
00014 PPM *im1, *im_rgb;
00015 enum file_types ppm_type;
00016 enum ppm_error the_error;
00017
00018 ppm_file = stdin;
00019
00020 switch(ppm_type = read_magic_no(ppm_file)) {
00021 case PGM_ASC: case PPM_ASC: case PGM_RAW: case PPM_RAW:
00022 if ((the_error = read_ppm(ppm_file, &im1, ppm_type)) != PPM_OK) {
00023 ppm_handle_error(the_error);
00024 exit(1);
00025 }
00026 break;
00027 default:
00028 fprintf(stderr, "Unrecognized file type.\n");
00029 break;
00030 }
00031
00032 if ((the_error = hsv2rgb_ppm(im1, &im_rgb)) != PPM_OK) {
00033 ppm_handle_error(the_error);
00034 exit(1);
00035 }
00036
00037 if ((the_error = write_ppm(stdout, im_rgb, PPM_RAW)) != PPM_OK) {
00038 ppm_handle_error(the_error);
00039 exit(1);
00040 }
00041
00042 exit(0);
00043 }