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

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