home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!wupost!eclnews!cec2!ppc1
- From: ppc1@cec2.wustl.edu (Peter Pui Tak Chiu)
- Subject: off-screen bitmap
- Message-ID: <1993Jan2.062516.17378@wuecl.wustl.edu>
- Sender: usenet@wuecl.wustl.edu (News Administrator)
- Nntp-Posting-Host: cec2
- Organization: Washington University, St. Louis MO
- Date: Sat, 2 Jan 1993 06:25:16 GMT
- Lines: 93
-
- hi everyone...
-
- i am trying to create an off-screen buffer in which i can draw in and then
- copy the completed picture back to the screen. i have tried the following
- method but it doesn't seem to work very well...
-
- i am using MPW.
-
- first of all, i create a BitMap of size 300 x 300 pixels in memory by the
- following:
-
- move #11552,d0 ; size of BitMap
- ; since rowWidth = 38, so each row has 304 bits
- ; 304 x 304 / 8 = 11552 bytes
- ext d0 ; extend to long word
- _NewPtr ; get non-relocatable block of size 11552
- move.l a0,BitMap.baseAddr ; set up BitMap base address
- move #38,BitMap.rowBytes ; set up rowBytes
- clr BitMap.bounds.Top ; set up bounding rectangle
- clr BitMap.bounds.Left
- move #300,BitMap.bounds.Bottom
- move #300,BitMap.bounds.Right
-
- BitMap is defined as follows:
-
- Rect RECORD 0
- Top: ds 1
- Left: ds 1
- Bottom: ds 1
- Right: ds 1
- ORG Top
- TopLeft: ds.l 1
- BottomRight: ds.l 1
- ENDR
-
- BitMapRecord RECORD 0
- baseAddr: ds.l 1
- rowBytes: ds.w 1
- bounds: ds.l Rect
- ENDR
-
- BitMap ds BitMapRecord
-
- note that i have missed out some code that checks if there exists a block
- of size 11552 bytes... just to make things clear.
-
- then i save all the drawings into the BitMap and restore them onto the
- window by doing this:
-
- pea BitMap ; BitMap is the only parameter
- _SetPBits ; set port to BitMap
-
- ...... CALLS TO DRAWING ROUTINES, MoveTo, LineTo, ...etc
-
- move.l myWindowPointer,-(sp) ;push pointer of myWindow
- _SetPort ;set port to myWindow
-
- pea BitMap ;source BitMap
- pea myRectangle ;source Rectangle
- pea myRectangle ;destination rectangle
- move #srcCopy,-(sp) ;normal copy mode
- clr.l -(sp) ;don't want to clip to a maskRgn, so just
- ;pass NIL for the maskRgn parameter
- _StdBits ;call bit transfer
-
- where myRectangle is defined as:
- myRectangle: dc 0,0,300,300
-
- and myWindowPointer is defined as:
- myWindowPointer: ds.l 1
-
- the problem that i have is only part of the BitMap got copied to the
- destination window. The area that got copied is (top:0, left:0, bottom:80,
- right: 100) and the rest of the 300x300 window area is just a mess...
-
- i really don't know what has gone wrong... i have been sitting all day in
- front of the computer trying to figure out what could be wrong but still
- didn't make any progress.
-
- the only thing i am suspecting wrong is the NIL parameter. I want to pass
- a NIL pointer for the last parameter of _StdBits but i am not sure what to
- push on stack. should i just pass a long word zero? or what?
-
- what is the constant value defined for NIL or NIL pointer...???
-
- i really would appreciate it if anyone can give me some suggestion on this
- matter.
-
- thank you very much in advance!!!
-
- peter
-
-
-