home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Graphics / Graphics.zip / blendgif.zip / gifvu.rxx < prev    next >
Text File  |  1999-02-18  |  4KB  |  116 lines

  1. /************************/
  2. /* Display info from a gif file. A list of the logical "blocks"
  3.    comprising a gif file is displayed, followed by relevant
  4.    information extracted from each block.
  5.  
  6.    MUST BE COMBINED WITH THE THE PROCEDURES IN PARSEGIF.RXX
  7.  
  8. Usage:
  9.   status=show_gifcontents(gifimage,dopause)
  10.  
  11. where:
  12.   gifimage: the contents of a gif file; say as read using
  13.             gifimage=charin(gif_file,1,chars(gif_file))
  14.   DOPause : If 1, then pause (wait for ENTER key) after displaying
  15.             info on each block
  16. and 
  17.   status = number of blocks in the gif file
  18.  
  19. For example, the following program will display the structure of
  20. a user supplied gif file:
  21.  
  22. ----------------begin example------------------------------- 
  23. parse arg gif_File
  24. gifimage=charin(gif_file,1,chars(gif_file))
  25. nblocks=show_gifcontents(gifimage,1)
  26. exit
  27. -----------------end example-------------------------------
  28.  
  29.  
  30. */
  31. show_gifcontents:PROCEDURE
  32. parse arg gifcontents,dopause
  33. talist=read_gif_block(gifcontents,1,'',1)
  34. say " Structure of the gif file is: "
  35. say "   " talist
  36. cts.=0
  37. ti=words(talist)
  38. do iJmm=1 to ti
  39.    ainfo=strip(word(talist,iJmm))
  40.    aa='!'ainfo
  41.    ii=cts.aa+1
  42.    cts.aa=ii
  43.    ab=read_gif_block(gifcontents,ii,ainfo,1)
  44.    say " ------ " ainfo ii ", length = "||length(ab)
  45.    select
  46.       when ainfo='CMT' then do
  47.          aa=read_comment_block(ab)
  48.          say "  comment= " aa
  49.       end
  50.       when ainfo='ACE' then do
  51.          niter=read_animation_block(ab)
  52.          parse var niter appname','niter
  53.          if appname="NETSCAPE" then do
  54.              say "  NETSCAPE:  # iters = " niter
  55.           end
  56.           else do
  57.              say "  Appname= " appname
  58.           end
  59.       end /* do */
  60.  
  61.       when ainfo='IMG' then do
  62.          ct_name='CT.'
  63.          ct.=0
  64.          stuff=read_image_block(ab,0)
  65.          parse var stuff lpos tpos width height lct lctsize interl sort ',' imgdata
  66.  
  67.          say "  Position (l,t): " lpos tpos
  68.          say "  Size (w,h): " width height
  69.          if lct=1 then 
  70.                 say '  Local color with ' lctsize '('ct.0 ') colors.'
  71.          else
  72.                 say "  No local ct (though ctsize = "lctsize
  73.          say "  Interlace, sort flags: " interl ',' sort
  74.          say "  Size of compressed image: " length(imgdata)
  75.       end /* do */
  76.  
  77.       when ainfo='LSD' then do
  78.           ct_name='CT.'
  79.           stuff=read_lsd_block(ab)
  80.           parse var stuff width height gcflag gcsize colres sort bkgcolor aspect
  81.           say "  Image width,height = " width height
  82.           say "  Color resolution, aspect, bkg color " colres aspect bkgcolor 
  83.           if gcflag=1 then
  84.               say "  " gcsize '(' ct.0 ") colors in global color table (sorted="sort
  85.           else
  86.               say "   No global ct (though size = " gcsize
  87.  
  88.       end /* do */
  89.  
  90.       when ainfo='GCE' then do
  91.         stuff=read_gce_block(ab)
  92.         parse var stuff disposal usrinflag tcflag delay tcindex
  93.         say "  Disposal, user input flag, delay : " disposal usrinflag delay
  94.         say "  Transparency flag, index : "tcflag',' tcindex
  95.  
  96.       end /* do */
  97.       when ainfo='TRM' then do
  98.          iterate
  99.      end
  100.      when  ainfo='00' then do  /* junk, remove */
  101.         say " found and ignoring 00  block "
  102.        iterate
  103.      end
  104.      otherwise say " unknown extension "
  105.    end  /* select */
  106.    if dopause=1 then do
  107.        call charout,' .... hit enter to view next block .... '
  108.        pull xxx
  109.        say
  110.    end /* do */
  111. end /* do */
  112.  
  113. return ti
  114.  
  115.  
  116.