home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rexxface.zip / any2RGBxbm.cmd next >
OS/2 REXX Batch file  |  1998-02-01  |  2KB  |  67 lines

  1. /*
  2.  * any2RGBxbm.cmd  -- GIF/BMP(OS2-1.3,Windoze)/XPM/PPM to RGB-XBM
  3.  *
  4.  *         Copyright (C) 1997-1998  OKUNISHI Fujikazu
  5.  *
  6.  * Author:  OKUNISHI Fujikazu <fuji0924@mbox.kyoto-inet.or.jp>
  7.  * Created: Aug 22, 1997
  8.  * Revised: Feb  1, 1998
  9.  *
  10.  * how2use:
  11.  *  ex.)  any2RGBxbm.cmd foo.bmp[RET]
  12.  *
  13.  */
  14.   Trace Off; '@echo off'
  15.   If RxFuncQuery('SysLoadFuncs') Then Do
  16.     Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  17.     Call SysLoadFuncs
  18.   End
  19.   Parse Arg src .
  20.  
  21.   If src='' Then Call EMSG(255 'error: no src file' src)
  22.   If Stream(src,'C','Query Exist')=''
  23.     Then Call EMSG(255 'error: no such file:' src)
  24.  
  25.   pgmFiles = 'noname.red noname.grn noname.blu'
  26.  
  27.   fspec = Left(src, LastPos('.',src) -1)
  28.    rgbPbm = fspec || '.pbm'
  29.    dstXbm = fspec || '.xbm'
  30.  
  31.   tmpFiles = pgmFiles rgbPbm
  32.  
  33.   head=Translate(Linein(src))
  34.  
  35.   Select
  36.     When Left(head,3)='GIF' Then filter='giftopnm.exe'
  37.     When Left(head,2)='BM'  Then filter='bmptoppm.exe'
  38.     When Pos('XPM',head)<>0 Then filter='xpmtoppm.exe'
  39.     When head='P3'  Then filter='cat.exe'  /*no operation*/
  40.   Otherwise Call EMSG(2 'error: invalid file format')
  41.   End
  42.  
  43.   If SysSearchPath('PATH',filter)=''
  44.     Then Call EMSG(1 "error: can't find filter:" filter)
  45.  
  46.   filter src '|ppmtorgb3'
  47.  
  48. /*'pnmcat -lr' pgmFiles '|pgmtopbm |pbmtoxbm>' dstXbm*/
  49. /*'pnmcat -tb' pgmFiles '|pgmtopbm |pbmtoxbm>' dstXbm*/
  50.   'pnmcat -tb' pgmFiles '|pgmtopbm>' rgbPbm  /* `#define fspec_width=' */
  51.   'pbmtoxbm' rgbPbm '>' dstXbm
  52.  
  53. /* clean */
  54.   Do While Words(tmpFiles)>0
  55.      Parse Var tmpFiles del tmpFiles
  56.      Call SysFileDelete(del)
  57.   End
  58. Exit
  59.  
  60. /* ----------------------------------------------------------------- */
  61. EMSG: Procedure
  62.   Parse Arg errcode msg
  63.   Call LineOut STDERR,msg
  64. Exit errcode
  65.  
  66. /* end of procedure */
  67.