Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!usc!apple!well!brecher From: brecher@well.sf.ca.us (Steve Brecher) Newsgroups: comp.sys.mac.programmer Subject: Re: Need help with bitmaps Message-ID: <16625@well.sf.ca.us> Date: 12 Mar 90 02:47:11 GMT References: <101780003@hpcvlx.cv.hp.com> Reply-To: brecher@well.sf.ca.us (Steve Brecher) Organization: Software Supply, Sunnyvale, CA Lines: 40 In article <101780003@hpcvlx.cv.hp.com>, billf@hpcvlx.cv.hp.com (Bill F. Faus) writes: > Can someone give me a mimimal program that illustrates how a bit map > (say a simple rectangle 2 bytes wide and 100 bytes tall) is put onto > screen... > > Which command actually writes to the screen? Is it SetPortBits, or is > it CopyBits? Can bitmaps be displayed without the use of windows? > > char Blob[200]; > ... > SetRect(&myBlob.bounds, 100, 100, 200, 102); You're on the right track. CopyBits can write to the screen, if the destination BitMap (or PixMap -- IM vol. V) coincides with (part of) the screen. SetPortBits just alters the current grafPort data structure; it does not draw. BitMaps can displayed without the use of windows, but you almost never would do that in a real application since the area outside of your windows is "owned" by system software. For your experiments, though, you can draw wherever you want! You want to think in terms of pixels, not bytes. The rectangle you want is 16 pixels wide and 100 pixels tall. Also note that the coordinate arguments to SetRect (L,T,R,B) are not in the same order as the fields of a Rect (T,L,B,R). Hence, your SetRect should be SetRect(&myBlob.bounds, 100, 100, 116, 200); > CopyBits(&myBlob, &myPort.portBits, &myBlob.bounds, &myPort.portRect, > srcCopy, 0L); Given the change to SetRect, this will draw on the screen. But, since CopyBits scales the drawing to fit the destination rectangle, it will draw a much larger area than you intend. To draw a 16x100 rectangle, you will need to change the dstRect argument to such a rectangle, e.g., by making it the same as the srcRect argument. -- brecher@well.sf.ca.us (Steve Brecher)