home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / grfxrexx.zip / LitPCX.Cmd < prev    next >
OS/2 REXX Batch file  |  1995-09-23  |  3KB  |  79 lines

  1. /*********************************************************************
  2.  LitPCX - Raphaël Vanney, 09/95
  3.  
  4.  The purpose of this REXX program is to get information from a PCX file.
  5.  There's of course no waranty of any kind associated to it. Use freely.
  6. **********************************************************************/
  7.  
  8. Debug=1
  9. Parse Arg NomF
  10. Say GetPCXDesc(NomF)
  11. Drop NomF PCX.
  12. Exit
  13.  
  14. GetPCXDesc:
  15. /* Get description for a PCX file ; if first character of returned
  16.    string is a "(", an error occured and the returned string is a
  17.    description of the error rather than of the file.
  18.    Normally returns "width x height (colors)".
  19.    Extra info is available in PCX. if no error occured :
  20.  
  21.      PCX.version         version of PaintBrush
  22.      PCX.comp            encoding method (should be 1=RLE)
  23.      PCX.bits            bits/pixel/plan
  24.      PCX.xmin            \
  25.      PCX.ymin             \ Image coordinates ; usually xmin=ymin=0
  26.      PCX.xmax             /
  27.      PCX.ymax            /
  28.      PCX.width           image width (xmax-xmin+1)
  29.      PCX.height          image height (ymax-ymin+1)
  30.      PCX.planes          # of planes
  31.      PCX.colors          color information
  32. */
  33.  
  34. Parse Arg FName
  35. Drop PCX.
  36.  
  37. If FName="" Then Return "(must supply a filename)"
  38.  
  39. /* read file header */
  40.  
  41. Hdr=C2D(CharIn(FName, 1))                    /* manufacturer */
  42. PCX.version=C2D(CharIn(FName))               /* PaintBrush version */
  43. PCX.comp=C2D(CharIn(FName))                  /* encoding (1=RLL) */
  44. PCX.bits=C2D(CharIn(FName))                  /* bits per pixel */
  45. PCX.xmin=C2D(Reverse(CharIn(FName, , 2)))
  46. PCX.ymin=C2D(Reverse(CharIn(FName, , 2)))
  47. PCX.xmax=C2D(Reverse(CharIn(FName, , 2)))
  48. PCX.ymax=C2D(Reverse(CharIn(FName, , 2)))
  49. PCX.width=PCX.xmax-PCX.xmin+1
  50. PCX.height=PCX.ymax-PCX.ymin+1
  51. PCX.planes=C2D(CharIn(FName, 66))            /* # of planes */
  52.  
  53. If (Hdr<>10) | (PCX.version>7) | (PCX.version<1) | ,
  54.    (PCX.comp<0) | (PCX.comp>1) | (PCX.planes<0) | (PCX.planes>4) Then
  55. Do
  56.      Drop Hdr PCX.
  57.      rc=CharOut(FName)
  58.      Return "(not a PCX file)"
  59. End
  60. Drop Hdr
  61.  
  62. Bits=PCX.planes*PCX.bits
  63. If Bits>=15 Then PCX.colors=Bits"-bit true color"
  64.             Else PCX.colors=2**Bits" colors"
  65. Drop Bits
  66.  
  67. If Debug Then
  68. Do
  69.      Say "PaintBrush version       "PCX.version
  70.      Say "Encoding                 "PCX.comp
  71.      Say "Bits/pixel               "PCX.bits
  72.      Say "x0, y0, x1, y1           "PCX.xmin","PCX.ymin","PCX.xmax","PCX.ymax
  73.      Say "Planes                   "PCX.planes
  74. End
  75.  
  76. rc=CharOut(FName)
  77.  
  78. Return PCX.width||" x "||PCX.height||" ("||PCX.colors||")"
  79.