home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / UNIX / Web / Utilities / wwwcount-2.3 / combine / crbasei.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-02  |  3.0 KB  |  142 lines

  1. /*
  2.  *    CreateBaseImage()    - create the base image for miv default window
  3.  *
  4.  *    RCS:
  5.  *        $Revision: 2.3 $
  6.  *        $Date: 1996/05/03 02:21:34 $
  7.  *
  8.  *    Security:
  9.  *        Unclassified
  10.  *
  11.  *    Description:
  12.  *        This function creates a white base image.  miv logo and othet small
  13.  *        images will be composited on it
  14.  *
  15.  *    Input Parameters:
  16.  *        type    identifier    description
  17.  *
  18.  *        text
  19.  *
  20.  *    Output Parameters:
  21.  *        type    identifier    description
  22.  *
  23.  *        text
  24.  *
  25.  *    Return Values:
  26.  *        value    description
  27.  *
  28.  *    Side Effects:
  29.  *        text
  30.  *
  31.  *    Limitations and Comments:
  32.  *        text
  33.  *
  34.  *    Development History:
  35.  *        who                    when        why
  36.  *        muquit@semcor.com    15-Dec-94    first cut
  37.  */
  38.  
  39. #include "combine.h"
  40. #include "defines.h"
  41.  
  42. Image *CreateBaseImage(width, height, red, green, blue,class)
  43. unsigned int
  44.     width;
  45.  
  46. unsigned int
  47.     height;
  48. int
  49.     red,
  50.     green,
  51.     blue;
  52. unsigned int
  53.     class;
  54. {
  55.     Image
  56.         *base_image;
  57.  
  58.     register Runlength
  59.         *q;
  60.  
  61.     int
  62.         i;
  63.  
  64.     /*
  65.     ** allocate memory for the base image
  66.     */
  67.  
  68.     base_image = AllocateImageStruct();
  69.  
  70.     if (base_image == (Image *) NULL)
  71.     {
  72.         (void) fprintf (stderr,
  73.             "Unable to create base image!\n");
  74.         return ((Image *) NULL);
  75.     }
  76.     
  77.     (void) strcpy(base_image->filename, "[internal]");
  78.     (void) strcpy(base_image->type, "[internal]");
  79.  
  80.     base_image->class = class;
  81.     base_image->columns = width;
  82.     base_image->rows = height;
  83.     base_image->packets = base_image->columns*base_image->rows;
  84.  
  85.     base_image->pixels = (Runlength *)
  86.         malloc(base_image->packets*sizeof(Runlength));
  87.  
  88.     if (base_image->pixels == (Runlength *) NULL)
  89.     {
  90.         (void) fprintf (stderr,
  91.             "Unable to create base image!\n");
  92.         return ((Image *) NULL);
  93.     }
  94.  
  95.     q = base_image->pixels;
  96.     switch(class)
  97.     {
  98.         case DirectClass:
  99.         {
  100.             for (i=0; i < base_image->packets; i++)
  101.             {
  102.                 q->red = (unsigned char) red;
  103.                 q->green = (unsigned char) green;
  104.                 q->blue = (unsigned char) blue;
  105.                 q->length = 0;
  106.                 q->index = 0;
  107.                 q++;
  108.             }
  109.             break;
  110.         }
  111.  
  112.         case PseudoClass:
  113.         {
  114.             base_image->colors=1;
  115.             base_image->colormap = (RGB *)
  116.                 malloc(base_image->colors*sizeof(RGB));
  117.             if (base_image->colormap == (RGB *) NULL)
  118.             {
  119.                 (void) fprintf (stderr,
  120.                     "Unable to create base image!..malloc failed\n");
  121.                  return ((Image *) NULL);
  122.             }
  123.             base_image->colormap[0].red=(unsigned char) red;
  124.             base_image->colormap[0].green=(unsigned char) green;
  125.             base_image->colormap[0].blue=(unsigned char) blue;
  126.  
  127.             for (i=0; i < base_image->packets; i++)
  128.             {
  129.                 q->red = base_image->colormap[0].red;
  130.                 q->green = base_image->colormap[0].green;
  131.                 q->blue = base_image->colormap[0].blue;
  132.                 q->length = 0;
  133.                 q->index = 0;
  134.                 q++;
  135.             }
  136.             break;
  137.         }
  138.     }
  139.     return (base_image);
  140.  
  141.