home *** CD-ROM | disk | FTP | other *** search
/ AMIGA PD 1 / AMIGA-PD-1.iso / Programme_zum_Heft / Programmieren / Kurztests / ACE / archive / ACEPRGS.LHA / gfx / GetPut.b < prev    next >
Text File  |  1994-11-11  |  2KB  |  81 lines

  1. {* 
  2. ** Simple copy and paste of rastport sections.
  3. **
  4. ** This is _like_ BASIC's GET and PUT commands 
  5. ** but less data is kept (ie. positional not bitmap
  6. ** data).
  7. **
  8. ** Author: David J Benn
  9. **   Date: 10th-11th November 1994
  10. *}
  11.  
  12. CONST default = -1&
  13.  
  14. LIBRARY "graphics.library"
  15.  
  16. DECLARE FUNCTION ClipBlit() LIBRARY graphics
  17.  
  18. STRUCT source_info
  19.   ADDRESS SrcRp
  20.   SHORTINT SrcX
  21.   SHORTINT SrcY
  22.   SHORTINT XSize
  23.   SHORTINT YSize
  24. END STRUCT
  25.  
  26. SUB GetIt(x1&, y1&, x2&, y2&, ADDRESS info_addr)
  27. DECLARE STRUCT source_info *info
  28. {* 
  29. ** Store data needed for PUT operation.
  30. *} 
  31.   info = info_addr
  32.  
  33.   info->SrcRp     = WINDOW(8)           '..source rastport
  34.   info->SrcX     = x1&               '..left
  35.   info->SrcY     = y1&               '..top
  36.   info->XSize     = ABS(x2&-x1&)+1     '..width
  37.   info->YSize     = ABS(y2&-y1&)+1     '..height
  38. END SUB
  39.  
  40. SUB PutIt(SHORTINT DestX, SHORTINT DestY, ADDRESS info_addr)
  41. DECLARE STRUCT source_info *info
  42. {* 
  43. ** PUT image from source rastport to destination rastport.
  44. *}
  45. CONST Minterm = &HC0
  46. ADDRESS DestRp
  47.  
  48.   info = info_addr
  49.  
  50.   DestRp = WINDOW(8)
  51.  
  52.   ClipBlit(info->SrcRp, info->SrcX, info->SrcY, ~
  53.        DestRp, DestX, DestY, info->XSize, info->YSize, ~
  54.        Minterm)
  55. END SUB
  56.  
  57.  
  58. {* Main *}
  59. DECLARE STRUCT source_info src
  60.  
  61. WINDOW 1,"Source",(0,0)-(320,150),2
  62.  
  63. LINE (10,10)-(125,125),2,b    '..Draw a rectangle.
  64. PAINT (100,100),1,2        '..Fill it.
  65.  
  66. GetIt(10,10,125,125,src)    '..Prepare to copy it.
  67.  
  68. WINDOW 2,"Destination",(320,25)-(640,200),10
  69.  
  70. PutIt(20,20,src)        '..Copy & paste from source
  71.                 '..into current output window
  72.                 '..with an x,y offset.
  73.  
  74. '..Wait for window 2's close gadget to be clicked.
  75. GADGET WAIT 0    
  76.  
  77. WINDOW CLOSE 2
  78. WINDOW CLOSE 1
  79.  
  80. END
  81.