home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / hdf / unix / examples.lha / examples / ris8 / putimF.f < prev    next >
Encoding:
Text File  |  1991-10-18  |  2.4 KB  |  110 lines

  1.     Program HDFTEST
  2. C
  3. C   Program for creating an image and storing it in an HDF file
  4. C
  5. C  If "row order" is selected the image created, with it's palette, 
  6. C  should display as an increasingly dark gray scale going from top
  7. C  to bottom, up to 256 rows, then repeating.  If "column order" is
  8. C  chosen, this pattern will be transposed.
  9. C
  10. C  User supplies filename, height, width, compression, and whether
  11. C  to store image in row or column order.
  12. C
  13.     Integer          Row, Column
  14.     Integer       Color
  15.     Integer       Compress
  16.     Integer       ReturnCode
  17.     Integer       Index1, Index2, Index3
  18.     Integer       d8spal, d8pimg 
  19.     Character*1   Image(307200)
  20.     Character*1   Palette(768)
  21.     Character*1   Order
  22.     Character*64  FileName
  23.  
  24.     print *,'HDFTEST - Generate HDF Test File'
  25.  
  26.     print *
  27.     print *,'Row Value: 1-480'
  28.     print 210
  29. 210    Format(' Enter number of rows: ',$)
  30.     read *, Row
  31.  
  32.     print *
  33.     print *,'Column Value: 1-640'
  34.     print 310
  35. 310    Format(' Enter number of columns: ',$)
  36.     read *,Column
  37.  
  38.     print *
  39.     print *,'Row/Column Order: R=Row, C=Column'
  40.     print 410
  41. 410    Format(' Enter order: ',$)
  42.         read (*,420) Order
  43. 420     format (a1)
  44.  
  45.     print *
  46.     print *,'Compression Code: 0=None, 11=Run Length, 12=IMCOMP'
  47.     print 510
  48. 510    Format(' Enter compression code: ',$)
  49.     read *,Compress
  50.  
  51.     print *
  52.     print *,'File Name: Up To 64 Characters'
  53.     print 610
  54. 610    Format(' Enter file name: ',$)
  55.         read (*, 620) Filename
  56. 620     format(a64)
  57.  
  58.     If (Order.eq.'C' .or. Order.eq.'c') then
  59.        Do 720 Index1=1,Row
  60.           Color=0
  61.           Do 710 Index2=1,Column
  62.              Image(((Index1*Column)-Column)+Index2)=CHAR(Color)
  63.              Color=Color+1
  64.              If (Color.gt.255) then
  65.                 Color=0
  66.              End If
  67. 710       continue
  68. 720    continue 
  69.     Else
  70.        Do 820 Index1=1,Column
  71.           Color=0
  72.           Do 810 Index2=1,Row
  73.              Image(((Index2*Column)-Column)+Index1)=CHAR(Color)
  74.              Color=Color+1
  75.              If (Color.gt.255) then
  76.                 Color=0
  77.              End If
  78. 810       continue
  79. 820    continue
  80.     End If
  81.  
  82.     Color=255
  83.     Do 910 Index3=1,768,3
  84.        Palette(Index3+0)=CHAR(Color)
  85.        Palette(Index3+1)=CHAR(Color)
  86.        Palette(Index3+2)=CHAR(Color)
  87.        Color=Color-1
  88.        If (Color.lt.0) then
  89.           Color=255
  90.        End If
  91. 910    continue
  92.  
  93.     ReturnCode = d8spal(Palette)
  94.     If (ReturnCode.ne.0) then
  95.        print *,'Error calling d8spal'
  96.     End If
  97.  
  98.     ReturnCode=d8pimg(FileName,Image,Column,Row,Compress)
  99.     If (ReturnCode.ne.0) then
  100.        print *,'Error calling d8pimg'
  101.     End If
  102.  
  103.     print *
  104.     print *,'HDFTEST - Finished'
  105.  
  106.     Stop
  107.  
  108.     End
  109.  
  110.