home *** CD-ROM | disk | FTP | other *** search
/ DTP Toolbox / DTPToolbox.iso / propage4.0 / arexx / importanimframes.pprx < prev    next >
Encoding:
Text File  |  1993-04-13  |  4.8 KB  |  145 lines

  1. /* Program to load a numbered series of pictures (usually animation frames) onto an existing page. New pages are also created as in AutoImport. The box contents are hidden because showing a large number of bitmaps can exhaust chip memory; also, hiding the images greatly speeds up loading. */
  2.  
  3. trace n
  4.  
  5.  
  6. call SafeEndEdit.rexx()
  7. call ppm_AutoUpdate(0)
  8. oldunits = ppm_GetUnits()
  9. call ppm_SetUnits(2)
  10. oldpoints = ppm_GetSize()
  11. call ppm_SetSize(12)
  12.  
  13. address command
  14.  
  15. currentpage = ppm_CurrentPage()
  16. if currentpage = 0 then currentpage = ppm_CreatePage(1,1,1,0,0)
  17. psize = ppm_GetPageSize(currentpage)
  18. pwidth = word(psize,1)
  19. if pwidth<5 then exit_msg("Page too small")
  20. pheight = word(psize,2)
  21.  
  22. filename = ppm_GetFileName("Select First File of Sequence:", "PPage:", "")
  23. if filename = '' then exit_msg("No File Selected")
  24.  
  25. form = "Frames per Row (1-20):4"||"0a"x "Frame Interval:1"||"0a"x "Outline Width (mm):1"
  26. form = ppm_GetForm("Set Layout",5,form)
  27. if form = "" then exit_msg("User Aborted Import")
  28. parse var form rownumber "0a"x interval "0a"x linewidth
  29.  
  30. if rownumber<1 | rownumber>20 then exit_msg("Invalid Row number: "rownumber)
  31. if interval<1 then Exit_msg("Invalid Interval: "interval)
  32.  
  33. colgap = 0.5
  34. rowgap = 1.5
  35. pagemargin = 1.5
  36. pagemargin2 = pagemargin * 2
  37.  
  38. collist = ppm_GetColorList()
  39. collist = substr(collist, pos('0a'x, collist) +1) /* strip off initial line which is number of colours */
  40. firstcolour =  left(collist, pos('0a'x, collist)-1 )
  41. linecolor = firstcolour
  42.  
  43. if datatype(linewidth, 'N') =1 then do
  44.     if linewidth =0 then break 
  45.     linewidth = linewidth/10 /* convert to cm */
  46.     linecolor=ppm_SelectFromList("Select Outline Color",24,18,0,collist)
  47.     if linecolor = "" then linecolor = firstcolour
  48.     end
  49. else do
  50.     linecolor = firstcolour
  51.     linewidth = 0
  52.     end
  53.  
  54. pwidth2 = pwidth- pagemargin2 -((rownumber-1)*colgap) /* 3 is margins */
  55. framewidth = pwidth2/rownumber
  56. frameheight = (framewidth*512)/640
  57. frameheight2 = frameheight+ rowgap
  58. colnumber = (pheight-pagemargin2)%frameheight2
  59. if colnumber = 0 then exit_msg("Page too Small")
  60.  
  61. /* strip off number from end of filename */
  62. do i = 1 to length(filename)
  63.     endofname = right(filename,i)
  64.     if verify(endofname,"0123456789") ~=0 then break
  65.     end
  66. numberlength = length(endofname)-1
  67.  
  68. if numberlength = 0 then exit_msg("Not a numbered file")
  69.     
  70. filenumber = substr(endofname,2)
  71. filebase = left(filename,length(filename)-numberlength)
  72.  
  73. /* Create some boxes */
  74. thispage = currentpage
  75. do limit = 1 to 20   /* safety limit of 20 pages  */
  76.     do i = 1 to colnumber
  77.         do j = 1 to rownumber
  78.             k = j-1
  79.             k2= k * colgap
  80.             m = i-1
  81.             m2 = m * rowgap
  82.  
  83.             currentnumber = right(filenumber,numberlength,"0")
  84.             fullname = filebase||currentnumber
  85.             if ~exists(fullname) then Exit_msg("Done")
  86.  
  87.             boxes.i.j.pic = ppm_CreateBox(pagemargin +(framewidth*k)+k2, pagemargin + (frameheight*m)+ m2, framewidth, frameheight, 0)
  88.             box = boxes.i.j.pic
  89.             call ppm_SetBoxHide(box,1) /* To avoid using up chip RAM */
  90.            
  91.             worked = ppm_ImportBM(box, fullname)
  92.             if worked = 0 then Exit_msg("Done")
  93.             
  94.             size = ppm_GetBoxSize(box)
  95.             boxwidth = word(size,1)
  96.             boxheight = word(size,2)
  97.             boxwidth = boxwidth-(linewidth*2)
  98.             boxheight = boxheight-(linewidth*2)
  99.  
  100.             info = ppm_GetBoxInfo(box)
  101.             width = word(info,2) /* width & height of bitmap */
  102.             height = word(info,3)
  103.  
  104.             width = width/(75/2.54) /* screen images at 75dpi for high res */
  105.             xscale = boxwidth/width
  106.             height = height/(75/2.54)
  107.             yscale = boxheight/height
  108.  
  109.             call ppm_SetBoxScale(box,xscale,yscale)
  110.             call ppm_SetBoxOffset(box,0,0)
  111.             call ppm_SetBoxFrame(box,1)
  112.             call ppm_SetBoxFrameData(box, linecolor, linecolor, linewidth*30, 1, 0)
  113.             call ppm_SetBoxMargins(box, linewidth, linewidth, linewidth, linewidth)
  114.             
  115.             boxes.i.j.caption = ppm_CreateBox(pagemargin +(framewidth*k)+k2, pagemargin + (frameheight*i)+ m2+ 0.2, framewidth, 1, 0)
  116.             captiontext = "Frame "||currentnumber
  117.             overflow = ppm_TextIntoBox(boxes.i.j.caption,captiontext)
  118.             call ppm_ShowStatus(captiontext)
  119.             
  120.             filenumber = filenumber+interval
  121.             end /* of row */
  122.     end /* of column */
  123. /* Create a new page without adding a blank page at end of document */
  124. trace n
  125.     newpage = ppm_CreatePage(thispage,1,1,0,0)
  126.     newpage = ppm_MovePage(newpage+1,newpage)
  127.     thispage = ppm_GoToPage(newpage+1)
  128. trace n
  129.  
  130. end /* 1 to 20 */
  131.  
  132.  
  133.  
  134. exit_msg: 
  135. do
  136.     parse arg message
  137.     if message ~= '' then call ppm_Inform(1, message,)
  138.     call ppm_AutoUpdate(1)
  139.     call ppm_SetUnits(oldunits)
  140.     call ppm_SetSize(oldpoints)
  141.     call ppm_ClearStatus()
  142.     exit
  143. end
  144.  
  145.