home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sys / mac / programm / 20525 < prev    next >
Encoding:
Text File  |  1993-01-02  |  3.0 KB  |  105 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!wupost!eclnews!cec2!ppc1
  3. From: ppc1@cec2.wustl.edu (Peter Pui Tak Chiu)
  4. Subject: off-screen bitmap
  5. Message-ID: <1993Jan2.062516.17378@wuecl.wustl.edu>
  6. Sender: usenet@wuecl.wustl.edu (News Administrator)
  7. Nntp-Posting-Host: cec2
  8. Organization: Washington University, St. Louis MO
  9. Date: Sat, 2 Jan 1993 06:25:16 GMT
  10. Lines: 93
  11.  
  12. hi everyone...
  13.  
  14. i am trying to create an off-screen buffer in which i can draw in and then
  15. copy the completed picture back to the screen.  i have tried the following
  16. method but it doesn't seem to work very well...
  17.  
  18. i am using MPW.
  19.  
  20. first of all, i create a BitMap of size 300 x 300 pixels in memory by the
  21. following:
  22.  
  23.     move    #11552,d0    ; size of BitMap
  24.                 ; since rowWidth = 38, so each row has 304 bits
  25.                 ; 304 x 304 / 8 = 11552 bytes
  26.     ext    d0        ; extend to long word
  27.     _NewPtr            ; get non-relocatable block of size 11552
  28.     move.l    a0,BitMap.baseAddr    ; set up BitMap base address
  29.     move    #38,BitMap.rowBytes    ; set up rowBytes
  30.     clr    BitMap.bounds.Top    ; set up bounding rectangle
  31.     clr    BitMap.bounds.Left
  32.     move    #300,BitMap.bounds.Bottom
  33.     move    #300,BitMap.bounds.Right
  34.  
  35. BitMap is defined as follows:
  36.  
  37. Rect    RECORD    0
  38.     Top:    ds    1
  39.     Left:    ds    1
  40.     Bottom:    ds    1
  41.     Right:    ds    1
  42.     ORG    Top
  43.     TopLeft:    ds.l    1
  44.     BottomRight:    ds.l    1
  45.     ENDR
  46.  
  47. BitMapRecord    RECORD    0
  48.     baseAddr:    ds.l    1
  49.     rowBytes:    ds.w    1
  50.     bounds:        ds.l    Rect
  51.         ENDR
  52.  
  53. BitMap    ds    BitMapRecord
  54.  
  55. note that i have missed out some code that checks if there exists a block
  56. of size 11552 bytes... just to make things clear.
  57.  
  58. then i save all the drawings into the BitMap and restore them onto the
  59. window by doing this:
  60.  
  61.     pea    BitMap    ; BitMap is the only parameter    
  62.     _SetPBits    ; set port to BitMap
  63.  
  64.     ...... CALLS TO DRAWING ROUTINES, MoveTo, LineTo, ...etc 
  65.  
  66.     move.l    myWindowPointer,-(sp)    ;push pointer of myWindow
  67.     _SetPort            ;set port to myWindow
  68.  
  69.     pea    BitMap        ;source BitMap
  70.     pea    myRectangle    ;source Rectangle
  71.     pea    myRectangle    ;destination rectangle
  72.     move    #srcCopy,-(sp)    ;normal copy mode
  73.     clr.l    -(sp)        ;don't want to clip to a maskRgn, so just
  74.                 ;pass NIL for the maskRgn parameter
  75.     _StdBits        ;call bit transfer
  76.  
  77. where myRectangle is defined as:
  78.     myRectangle:    dc    0,0,300,300
  79.  
  80. and myWindowPointer is defined as:
  81.     myWindowPointer: ds.l    1
  82.  
  83. the problem that i have is only part of the BitMap got copied to the
  84. destination window.  The area that got copied is (top:0, left:0, bottom:80,
  85. right: 100) and the rest of the 300x300 window area is just a mess...
  86.  
  87. i really don't know what has gone wrong... i have been sitting all day in
  88. front of the computer trying to figure out what could be wrong but still
  89. didn't make any progress.
  90.  
  91. the only thing i am suspecting wrong is the NIL parameter.  I want to pass
  92. a NIL pointer for the last parameter of _StdBits but i am not sure what to
  93. push on stack.  should i just pass a long word zero?  or what?
  94.  
  95. what is the constant value defined for NIL or NIL pointer...???
  96.  
  97. i really would appreciate it if anyone can give me some suggestion on this
  98. matter.
  99.     
  100. thank you very much in advance!!!
  101.  
  102. peter
  103.  
  104.  
  105.