home *** CD-ROM | disk | FTP | other *** search
/ DTP Toolbox / DTPToolbox.iso / utilities / propage_pdraw / donsgenies / adproscripts.lha / ScreenPrint.adpro < prev    next >
Encoding:
Text File  |  1993-04-15  |  3.5 KB  |  162 lines

  1. /* Program to use ADPro to separate a picture into a selected number of colours, suitable for screen printing. */
  2.  
  3. trace r
  4.  
  5. options results
  6. address "ADPro"
  7. getfile '"Select picture to process"'
  8. if rc=10 then exit
  9. filename = ADPro_Result
  10. getdir '"Select where to save results"'
  11. if rc=10 then exit
  12. outdirectory = strip(ADPro_Result)
  13. if right(outdirectory,1)~= ":" then outdirectory = outdirectory"/"
  14.  
  15.  
  16. address "ADPro"
  17.  
  18. lformat "UNIVERSAL"
  19. sformat "IFF"
  20.  
  21. /* Use the current screen format. */
  22.  
  23. screen_type
  24. stype = ADPro_result
  25.  
  26. /* Here is where you ask the user for figures */
  27.  
  28. getnumber '"How many inks?"' 4 2 256
  29. colours = ADPro_result
  30. if rc~=0 then colours = 0
  31. if colours>256 then colours = 256
  32.  
  33. colon = lastpos('/', filename)
  34. if colon = 0 then colon = pos(':', filename)
  35. if colon = 0 then do
  36.     path = ""
  37.     filebase = filename
  38.     end
  39. else do
  40.     path =left(filename, colon)
  41.     filebase = substr(filename,colon+1)
  42.     end
  43.  
  44. pstatus unlocked
  45. load filename
  46.  
  47. ptotal 256
  48. poffset 0
  49. pused colours
  50. if colours<33 then newtotal = 32
  51. if colours<17 then newtotal = 16
  52. if colours<9 then newtotal = 8
  53. if colours<5 then newtotal = 4
  54. ptotal newtotal
  55. render_type "CUST"
  56. dither 6  /* Random dither */
  57. execute
  58. pstatus locked
  59. psave "ram:palette"
  60. do i = 0 to colours-1
  61.     ppoke i
  62.     pcolours.i = ADPRO_RESULT
  63.     end
  64.  
  65. /* Construct a name for the new file and save it  */
  66. newname = outdirectory||filebase||".all"
  67. save newname "IMAGE"
  68. if rc~=0 then do
  69.     okay1 '"Trouble saving file "||newname'
  70.     exit
  71.     end
  72.  
  73. /* Set palette to all white */
  74. do i = 0 to colours-1
  75.     ppoke i 255 255 255
  76.     end
  77.  
  78. /* Set each colour in turn to black and save picture */
  79. do i = 0 to colours-1
  80.     ppoke i 0 0 0
  81.     /* Construct a name for the new file and save it  */
  82.     filenumber = right(i,3,"0")
  83.     newname = outdirectory||filebase||"."||filenumber
  84.     save newname "IMAGE"
  85.     if rc~=0 then do
  86.         okay1 '"Trouble saving file "||newname'
  87.         exit
  88.         end
  89.     ppoke i 255 255 255
  90.     end
  91.  
  92. pused 2
  93. ptotal 2
  94. ppoke 0 0 0 0
  95. do i= 0 to colours-1
  96.     /* Construct a name for the file, load it and resave it as 1 bitplane */
  97.     filenumber = right(i,3,"0")
  98.     newname = outdirectory||filebase||"."||filenumber
  99.     load newname
  100.     render_type "CUST"
  101.     res = RC
  102.     execute
  103.     save newname "IMAGE"
  104.     if rc~=0 then do
  105.         okay1 '"Trouble saving file "||newname'
  106.         exit
  107.         end
  108.     end
  109. trace r
  110. /* Make a colour chart  */
  111. screen_type 4
  112. dither 0
  113. pstatus "UNLOCKED"
  114. render_type 32  /* This could be changed to 256 if you have AGA. HAM & EHB don't seem to work. */
  115. res = RC
  116.  
  117. lformat "BACKDROP"
  118. load "X" 320 256 "COLOR" 140 140 140
  119. operator "TEXT_VISUAL" font_type "BITMAPPED" font_dir "fonts:" font_name "TOPAZ" emboss_direction "OFF" render_type "MIX" set_colors 0 0 0 set_font_size 11 set_blur "-1" set_render 100 set_yoffset 12 string '"INK COLOUR CHART"' center_xoffset draw
  120. le = 2
  121. te = 42
  122. j = 1
  123. do i = 0 to 23
  124.     if i = colours then break
  125.     operator "RECTANGLE" le te 36 64 "-1" pcolours.i
  126.     le = le+40
  127.     j = j+1
  128.     if j = 9 | j= 17 then do
  129.         le = 2
  130.         te = te+68
  131.         end
  132.     end
  133.  
  134. execute
  135. /* Construct a name for the chart file and save it  */
  136. newname = outdirectory||filebase||".chart"
  137. save newname "IMAGE"
  138. if rc~=0 then do
  139.     okay1 '"Trouble saving file "||newname'
  140.     exit
  141.     end
  142.  
  143. lformat "UNIVERSAL"
  144. ADPRO_TO_FRONT
  145. exit_msg("Done")
  146. end
  147.  
  148. /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
  149.  
  150. error:
  151. syntax:
  152.     do
  153.     exit_msg("Arexx program failed due to error: "errortext(rc))
  154.     end
  155.  
  156. exit_msg:
  157.     do
  158.     parse arg message
  159.     if message ~= "" then
  160.     okay1 message
  161.     exit
  162.     end