home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / UNIX / Web / Utilities / wwwcount-2.3 / utils / mkstrip.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-07  |  3.3 KB  |  183 lines

  1. /*
  2.  *  mkstrip - program to make a image strip out of several gif images
  3.  *
  4.  *  RCS:
  5.  *      $Revision$
  6.  *      $Date$
  7.  *
  8.  *  Security:
  9.  *      Unclassified
  10.  *
  11.  *  Description:
  12.  *      text
  13.  *
  14.  *  Input Parameters:
  15.  *      type    identifier  description
  16.  *
  17.  *      text
  18.  *
  19.  *  Output Parameters:
  20.  *      type    identifier  description
  21.  *
  22.  *      text
  23.  *
  24.  *  Return Values:
  25.  *      value   description
  26.  *
  27.  *  Side Effects:
  28.  *      text
  29.  *
  30.  *  Limitations and Comments:
  31.  *      This program keeps info about the strips in the GIF comment
  32.  *      extension, which is used by the counter program.
  33.  *
  34.  *  Development History:
  35.  *      who                 when        why
  36.  *      muquit@semcor.com   18-Mar-96   first cut
  37.  */
  38.  
  39.  
  40. #include "combine.h"
  41. #include "count.h"
  42.  
  43. void Usage _Declare ((void));
  44. void Debug _Declare ((char *));
  45. void MakeStripImage _Declare ((char **,int));
  46.  
  47. char
  48.     *progname;
  49.  
  50. #define MKSTRIP_VERSION "1.0"
  51. #define DEBUG   1
  52.  
  53. void main(argc,argv)
  54. int
  55.     argc;
  56. char
  57.     *argv[];
  58. {
  59.     int
  60.         i;
  61.  
  62.     char
  63.         tmpbuf[2048];
  64.  
  65.     *tmpbuf='\0';
  66.     progname=argv[0];
  67.     if (argc < 2)
  68.     {
  69.         Usage();
  70.     }
  71.  
  72.     MakeStripImage(argv,argc);
  73. }
  74.  
  75. void Usage()
  76. {
  77.     (void) fprintf (stderr,"mkstrip Version %s\n\n", MKSTRIP_VERSION);
  78.     (void) fprintf (stderr,
  79.         "Usage: %s image1.gif image2.gif image3.gif ... > final.gif\n\n", progname);
  80.     exit(1);
  81. }
  82.  
  83. void Debug(str)
  84. char
  85.     *str;
  86. {
  87. #ifdef DEBUG
  88.     (void) fprintf (stderr,"%s\n",str);
  89. #endif
  90.     return;
  91. }
  92.  
  93. void MakeStripImage(files,n)
  94. char
  95.     **files;
  96. int
  97.     n;
  98. {
  99.     int
  100.         i;
  101.     
  102.     int
  103.         rc;
  104.  
  105.     unsigned int
  106.         w,
  107.         h,
  108.         bw,
  109.         bh;
  110.  
  111.     Image
  112.         *base_image,
  113.         *sub_image;
  114.  
  115.     int
  116.         do_comment,
  117.         count,
  118.         segment;
  119.  
  120.     w=h=bw=bh=0;
  121.     count=0;
  122.     segment=0;
  123.     do_comment=0;
  124.  
  125.     for (i=1; i < n; i++)
  126.     {
  127.         rc=GetGIFsize(files[i],&w,&h);
  128.         if (rc)
  129.         {
  130.             (void) fprintf (stderr,
  131.                 " Unable to determine digit imaeg size for: %s\n",files[i]);
  132.             exit(1);
  133.         }
  134.         bw += w;
  135.         if (h > bh)
  136.             bh=h;
  137.     }
  138.  
  139.  
  140.     base_image=CreateBaseImage (bw,bh,0,0,0,DirectClass);
  141.     /*
  142.     ** add comment to the image. this is important. we will determine
  143.     ** the number of digit images by reading it
  144.     */
  145.     base_image->comments=(char *) malloc(100*sizeof(char));
  146.     if (base_image != (Image *) NULL)
  147.         do_comment=1;
  148.  
  149.     if (do_comment == 1)
  150.     {
  151.         (void) sprintf(base_image->comments,"%d",(n-1));
  152.     }
  153.     if (base_image == (Image *) NULL)
  154.     {
  155.         (void) fprintf (stderr," Unable to create base image!\n");
  156.         exit(1);
  157.     }
  158.  
  159.     bw=bh=0;
  160.     for (i=1; i < n; i++)
  161.     {
  162.         sub_image=ReadImage(files[i]);
  163.         if (sub_image != (Image *) NULL)
  164.         {
  165.             FlattenImage(base_image,sub_image,ReplaceCompositeOp,bw,0);
  166.             if (do_comment == 1)
  167.                 (void) sprintf(base_image->comments,
  168.                      "%s:%d",base_image->comments,bw);
  169.             bw += sub_image->columns;
  170.             DestroyAnyImageStruct(&sub_image);
  171.         }
  172.         else
  173.         {
  174.             (void) fprintf (stderr,"Failed to create image strip!\n");
  175.             exit(1);
  176.         }
  177.     }
  178.     if (do_comment == 1)
  179.        (void) sprintf(base_image->comments,
  180.              "%s:%d",base_image->comments,bw);
  181.     WriteGIFImage(base_image,(char *) NULL);
  182. }
  183.