home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_10_11 / 1011106a < prev    next >
Text File  |  1992-09-02  |  7KB  |  157 lines

  1.         case 11: /* perform image addition and subtraction */
  2.            printf("\nCIPS> Image Addition:"
  3.                 "\n         output = first + second"
  4.                 "\n      Image Subtractions:"
  5.                 "\n         output = first - second");
  6.            printf("\nCIPS> Enter first image name\n");
  7.            get_image_name(name);
  8.            printf("\nCIPS> Enter second image name\n");
  9.            get_image_name(name2);
  10.            printf("\nCIPS> Enter output image name\n");
  11.            get_image_name(name3);
  12.            printf("\nCIPS> Enter parameters for first image");
  13.            get_parameters(&il, &ie, &ll, &le);
  14.            printf("\nCIPS> Enter parameters for second image");
  15.            get_parameters(&il2, &ie2, &ll2, &le2);
  16.            printf("\nCIPS> Enter parameters for output image");
  17.            get_parameters(&il3, &ie3, &ll3, &le3);
  18.            printf("\n\nCIPS> Enter a=addition    s=subtraction\n");
  19.            printf("\nCIPS> _\b");
  20.            read_string(low_high);
  21.            if(low_high[0] == 'a' || low_high[0] == 'A')
  22.               add_image_array(name, name2, name3,
  23.                   the_image, out_image,
  24.                   il, ie, ll, le,
  25.                   il2, ie2, ll2, le2,
  26.                   il3, ie3, ll3, le3);
  27.            if(low_high[0] == 's' || low_high[0] == 'S')
  28.               subtract_image_array(name, name2, name3,
  29.                   the_image, out_image,
  30.                   il, ie, ll, le,
  31.                   il2, ie2, ll2, le2,
  32.                   il3, ie3, ll3, le3);
  33.         break;
  34.  
  35.         case 12: /* image cutting and pasting */
  36.            printf("\n\nCIPS> Cut from source image and paste to"
  37.                   " destination image");
  38.            printf("\nCIPS> Enter source image name");
  39.            get_image_name(name);
  40.            get_parameters(&il, &ie, &ll, &le);
  41.            check_cut_and_paste_limits(&il, &ie, &ll, &le);
  42.            cut_image_piece(name, the_image,
  43.                            il, ie, ll, le);
  44.            printf("\nCIPS> Enter destination image name");
  45.            get_image_name(name2);
  46.            printf("\nCIPS> Enter destination image parameters");
  47.            get_parameters(&il, &ie, &ll, &le);
  48.            check_cut_and_paste_limits(&il, &ie, &ll, &le);
  49.            paste_image_piece(name2, name, the_image,
  50.                              out_image, il, ie, ll, le);
  51.         break;
  52.  
  53.         case 13: /* image rotation and flipping */
  54.            printf("\nCIPS> Enter source image name");
  55.            get_image_name(name);
  56.            get_parameters(&il, &ie, &ll, &le);
  57.            printf("\nCIPS> Enter destination image name");
  58.            printf("\nCIPS> (source can equal destination)");
  59.            get_image_name(name2);
  60.            printf("\nCIPS> Enter destination image parameters");
  61.            get_parameters(&il2, &ie2, &ll2, &le2);
  62.            printf("\nCIPS> Enter number of Rotations (1, 2, 3)");
  63.            printf("\nCIPS> or type of Flip (4=horizontal 5=vertical)");
  64.            printf("\nCIPS> __\b");
  65.            get_integer(&rotation_type);
  66.            rotate_flip_image_array(name, name2, the_image,
  67.                                out_image, il, ie, ll, le,
  68.                                il2, ie2, ll2, le2,
  69.                                rotation_type);
  70.         break;
  71.  
  72.         case 14: /* image scaling */
  73.            printf("\nCIPS> Enter input image name");
  74.            get_image_name(name);
  75.            get_parameters(&il, &ie, &ll, &le);
  76.            printf("\nCIPS> Enter output image name");
  77.            get_image_name(name2);
  78.            get_scaling_options(zoom_shrink, &scale, method);
  79.            if(zoom_shrink[0] == 'z' || zoom_shrink[0] == 'Z')
  80.               zoom_image_array(name, name2, the_image, out_image,
  81.                                il, ie, ll, le, scale, method);
  82.            if(zoom_shrink[0] == 's' || zoom_shrink[0] == 'S'){
  83.                printf("\nCIPS> Enter output image parameters");
  84.                  get_parameters(&il2, &ie2, &ll2, &le2);
  85.                shrink_image_array(name, name2, the_image, out_image,
  86.                                   il, ie, ll, le, il2, ie2, ll2, le2,
  87.                                   scale, method);
  88.            }
  89.         break;
  90.  
  91.         case 15: /* create image */
  92.            printf("\nCIPS> Enter input name of image to create");
  93.            get_image_name(name);
  94.            printf("\nCIPS> Enter number of %d blocks wide",COLS);
  95.            printf("\n      ___\b\b");
  96.            get_integer(&width);
  97.            printf("\nCIPS> Enter number of %d blocks tall",ROWS);
  98.            printf("\n      ___\b\b");
  99.            get_integer(&length);
  100.            image_header.lsb            = 1;
  101.            image_header.bits_per_pixel = 8;
  102.            image_header.image_length   = length*COLS;
  103.            image_header.image_width    = width*ROWS;
  104.            image_header.strip_offset   = 1000;
  105.            for(i=0; i<ROWS; i++)
  106.               for(j=0; j<COLS; j++)
  107.                  the_image[i][j] = 0;
  108.            create_allocate_tiff_file(name,&image_header,the_image);
  109.         break;
  110.  
  111.         case 20:  /* exit system */
  112.          not_finished = 0;
  113.         break;
  114.  
  115.         default:
  116.          printf("\nCould not understand response, try again");
  117.         break;
  118.  
  119.  
  120. /*--------------------------------------------------------------
  121.   --------------------------------------------------------------*/
  122.  
  123.  
  124.  
  125.    /******************************************************
  126.    *
  127.    *   show_menu(..
  128.    *
  129.    *   This function displays the CIPS main menu.
  130.    *
  131.    *******************************************************/
  132. show_menu()
  133. {
  134.  
  135.         printf("\n\nWelcome to CIPS");
  136.         printf("\nThe C Image Processing System");
  137.         printf("\nThese are you choices:");
  138.         printf("\n\t1.  Display image header");
  139.         printf("\n\t2.  Show image numbers");
  140.         printf("\n\t3.  Print image numbers");
  141.         printf("\n\t4.  Display image (VGA & EGA only)");
  142.         printf("\n\t5.  Display or print image using halftoning");
  143.         printf("\n\t6.  Print graphics image using dithering");
  144.         printf("\n\t7.  Print or display histogram numbers");
  145.         printf("\n\t8.  Perform edge detection");
  146.         printf("\n\t9.  Perform edge enhancement");
  147.         printf("\n\t10. Perform image filtering");
  148.         printf("\n\t11. Perform image addition and subtraction");
  149.         printf("\n\t12. Perform image cutting and pasting");
  150.         printf("\n\t13. Perform image rotation and flipping");
  151.         printf("\n\t14. Perform image scaling");
  152.         printf("\n\t15. Create a blank image");
  153.         printf("\n\t20. Exit system");
  154.         printf("\n\nEnter choice _\b");
  155.  
  156. }    /* ends show_menu */
  157.