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

  1. /*
  2.  *  String drawing routines
  3.  *
  4.  *  RCS:
  5.  *      $Revision: 2.3 $
  6.  *      $Date: 1996/05/03 02:21:34 $
  7.  *
  8.  *  Security:
  9.  *      Unclassified
  10.  *
  11.  *  Description:
  12.  *      Adapted from gd 1.2 by TB
  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.  *      text
  32.  *
  33.  *  Development History:
  34.  *      who                 when        why
  35.  *      muquit@semcor.com   30-Aug-95   first cut
  36.  */
  37.  
  38. #include "combine.h"
  39. #include "gdfonts.h"
  40.  
  41. void ImageChar(image,f,x,y,c,font_info)
  42. Image
  43.     *image;
  44. gdFontPtr
  45.     f;
  46. int
  47.     x,
  48.     y;
  49. char
  50.     c;
  51. SFontInfo
  52.     *font_info;
  53. {
  54.     int
  55.         cx,
  56.         cy,
  57.         px,
  58.         py;
  59.  
  60.     int
  61.         fline;
  62.  
  63.     cx=0;
  64.     cy=0;
  65.  
  66.     if ((c < f->offset) || (c >= (f->offset + f->nchars)))
  67.         return;
  68.  
  69.     fline=(c - f->offset) * f->h * f->w;
  70.     for (py = y; (py < (y + f->h)); py++)
  71.     {
  72.         for (px = x; (px < (x + f->w)); px++)
  73.         {
  74.             if (font_info->do_bg == True)
  75.             {
  76.                 if (f->data[fline + cy * f->w + cx])
  77.                     SetPixel(image,px,py,font_info,0);
  78.                 else
  79.                     SetPixel(image,px,py,font_info,1);
  80.             }
  81.             else
  82.             {
  83.                 if (f->data[fline + cy * f->w + cx])
  84.                     SetPixel(image,px,py,font_info,0);
  85.             }                
  86.             cx++;
  87.         }
  88.         cx=0;
  89.         cy++;
  90.     }
  91. }
  92.  
  93. void ImageString(image,f,x,y,s,font_info)
  94. Image
  95.     *image;
  96. gdFontPtr
  97.     f;
  98. int
  99.     x,
  100.     y;
  101. char
  102.     *s;
  103. SFontInfo
  104.     *font_info;
  105. {
  106.     int
  107.         i,
  108.         l;
  109.  
  110.     l=(int) strlen(s);
  111.  
  112.     for (i=0; i < l; i++)
  113.     {
  114.         ImageChar(image,f,x,y,s[i],font_info);
  115.         x += f->w;
  116.     }
  117. }
  118.  
  119.  
  120.