home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1999 November / PCONLINE_11_99.ISO / filesbbs / OS2 / APCHSSL2.ZIP / OS2HTTPD / alphabyt / ext_gif.cmd next >
Encoding:
Text File  |  1998-12-12  |  4.5 KB  |  155 lines

  1. /* */
  2. /* Load up advanced REXX functions */
  3. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  4. call SysLoadFuncs
  5.  
  6. foo=rxfuncquery('rexxlibregister')
  7. if foo=1 then do
  8.  droprxlib=1 ; gotrxlib=0
  9.  call rxfuncadd 'rexxlibregister','rexxlib', 'rexxlibregister'
  10.  call rexxlibregister
  11. end
  12. foo=rxfuncquery('rxgdloadfuncs')
  13. if foo=1 then do
  14.   Call RxFuncAdd 'RxgdLoadFuncs', 'RXGDUTIL', 'RxgdLoadFuncs'
  15.   Call RxgdLoadFuncs
  16. end
  17.  
  18. say " This utility is meant to be used in conjunction with the gif_text utility "
  19. say
  20. say " Given a grid of fonts in a .GIF file, and a .IND file containing some "
  21. say " basic info, this utility will create an 'alphabyte' -- "
  22. say "      it will extract seperate .GIF files for each  character referenced "
  23. say "      in the .IND file.   "
  24. say " (this can be useful for debugging the .IND file)"
  25. say
  26.  
  27. call charout , " Enter ind file (that contains info on the Grid Of Fonts) ? "
  28. pull anind
  29. if pos('.',anind)=0 then anind=anind'.ind'
  30.  
  31. yow=fileread(anind,lines,,'E')
  32.  
  33. textcolor='000000' ; backcolor='ffffff'
  34. defgifs=' '; xoffset=0 ; yoffset=0 ; inrow=16 ; hchar=47  ; wchar=35 ;isbw=1
  35. charset=' !"'||"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
  36.  
  37. do mm=1 to lines.0
  38.    foo=strip(lines.mm)
  39.    if abbrev(foo,';')=1 | foo="" then iterate
  40.    if pos('=',foo)=0 then iterate
  41.    parse var foo athing '=' stuff ; athing=strip(upper(athing))
  42.    select
  43.       when athing='DEFAULTS' then  defgifs=strip(stuff)
  44.       when athing='TEXT' then do
  45.                stuff2=get_from_hex(stuff)
  46.               if stuff2<>' ' then textcolor=strip(stuff)
  47.       end
  48.       when athing='BACK' then do
  49.          stuff2=get_from_hex(stuff)
  50.          if stuff2<>' ' then backcolor=strip(stuff)
  51.       end
  52.       when athing='DEF_OFFSET' then do
  53.              stuff=translate(stuff,' ',',')
  54.              parse var stuff a1 a2
  55.              if datatype(a1)='NUM'  then xoffset=a1
  56.              if datatype(a2)='NUM'  then yoffset=a2
  57.       end  /* Do */
  58.       when athing='DEF_CHARSIZE' then do
  59.              stuff=translate(stuff,' ',',')
  60.              parse var stuff a1 a2
  61.              if datatype(a1)='NUM'  then wchar=a1
  62.              if datatype(a2)='NUM'  then hchar=a2
  63.       end  /* Do */
  64.       when athing='DEF_CHARS' then charset=stuff
  65.       when athing='DEF_BW' then isbw=pos(strip(upper(stuff)),'Y YES 1')
  66.       when athing='DEF_INROW' then
  67.               if datatype(strip(stuff))='NUM' then inrow=strip(stuff)
  68.       otherwise nop
  69.    end  /* select */
  70. end /* do */
  71. im = RxgdImageCreateFromGIF(defgifs)
  72. if im=1 | im=0 then  do
  73.  say "Error, could not process " defgifs
  74.   exit
  75. end
  76.  
  77. say " Reading from fonts displayed in: " defgifs 
  78. say " The following characters will be produced: " charset
  79.  
  80. backcolor=get_from_hex(backcolor)
  81.    parse var backcolor bdefr bdefg bdefb
  82. textcolor=get_from_hex(textcolor)
  83.    parse var textcolor tdefr tdefg tdefb
  84. ido=0
  85. /* for each character in the charset ... */
  86. /*do ic=1 to length(charset)*/
  87. do ic=1 to length(charset)
  88.      achar=substr(charset,ic,1)
  89.      if achar=' ' then iterate
  90.  
  91. /* determine x offset: */
  92.    irow=1+((ic-0.1)%inrow)
  93.    icol=ic-((irow-1)*inrow)
  94.  
  95. /* upper left is 0,0 */
  96.    xat=xoffset + ((icol-1)*wchar)
  97.    yat=yoffset+ ((irow-1)*hchar)
  98.  
  99.    cim=rxgdimagecreate(wchar,hchar)
  100.  
  101.    foo=rxgdimagecopy(cim,im,0,0,xat,yat,wchar,hchar)
  102.  
  103.  
  104.    foo=rxgdimagecolordeallocate(cim,0)
  105.    oy1=rxgdimagecolorallocate(cim,bdefr,bdefg,bdefb)
  106.    foo=rxgdimagecolordeallocate(cim,1)
  107.    oy2=rxgdimagecolorallocate(cim,tdefr,tdefg,tdefb)
  108.  
  109.    acharg=achar
  110.    if upper(achar)<>achar then acharg=achar'lc'
  111.  
  112.    if pos(upper(achar),'1234567890ABCDEFGHIJKLMNOPQRSTUVXWYZ#-_%$')=0 then DO
  113.         FOO=c2D(ACHAR)
  114.         ACHARg='ASC_'||FOO
  115.    end  /* Do */
  116.  
  117.    acharg=acharg'.GIF'
  118.   foo=rxgdimagegif(cim,acharG)
  119.    say  " Writing character " achar "(@ offset "  xat yat ") to : " acharg
  120.    ido=ido+1
  121.   foo= RxgdImageDestroy(cim)
  122.  
  123.  
  124. end /* do */
  125. say " Total files written= " ido
  126. foo= RxgdImageDestroy(im)
  127.  
  128. exit
  129.  
  130.  
  131.  
  132.  
  133. /**************************/
  134. /* convert ff21b3 "hex" color code to decimal r g b values
  135.   If bad value, return ' /' */
  136. get_from_hex:procedure
  137. parse arg hval
  138.  
  139. hval=strip(strip(hval),,'"')
  140. hval=strip(hval,,'#')
  141. select 
  142.   when length(hval)<>6 then return ' '
  143.   when verify(translate(hval),'0123456789ABCDEF')>0 then return ' '
  144.   otherwise do
  145.     a1=left(hval,2)
  146.     a2=substr(hval,3,2)
  147.     a3=substr(hval,5,2)
  148.     r=x2d(a1)
  149.     g=x2d(a2)
  150.     b=x2d(a3)
  151.   end
  152. end /* do */
  153. return r ' ' g ' ' b
  154.  
  155.