Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!batcomputer!eacj From: eacj@batcomputer.tn.cornell.edu (Julian Vrieslander) Newsgroups: comp.sys.mac.programmer Subject: Re: Stupid QuickDraw question Message-ID: <7439@batcomputer.tn.cornell.edu> Date: 21 Feb 89 05:03:59 GMT References: <71976CXT105@PSUVM> Reply-To: eacj@tcgould.tn.cornell.edu (Julian Vrieslander) Organization: Cornell Theory Center, Cornell University, Ithaca NY Lines: 51 In article <71976CXT105@PSUVM> CXT105@PSUVM.BITNET (Christopher Tate) writes: >What is the best way to plot a single point in a given GrafPort (window, screen >or other)? As mentioned in earlier postings, the fastest way to draw points is to set the appropriate bits in the bit image, bypassing Quickdraw completely. But writing directly into the screen's bitMap (screenBits) is strongly discouraged by the Apple compatibility police, and for good reason. You have to do your own clipping if the destination window is not completely visible, and you have to know the details of how the bits in memory are mapped into pixels (may have color or grayscale, etc.). Drawing into an offscale bitMap and CopyBits-ing into the window makes life somewhat easier, but adds a delay. Another, simpler approach that gives a moderate speed gain is calling the traps directly. In LightspeedC this looks as follows: #include #include /* Quickdraw trap numbers */ #define LINE_TRAP 0x92 #define MOVETO_TRAP 0x93 ... DrawSomePointsFast() { register short x,y; long MoveToProc,LineProc; /* Get addresses of QuickDraw traps; calling them directly saves time. */ LineProc = NGetTrapAddress(LINE_TRAP,ToolTrap); MoveToProc = NGetTrapAddress(MOVETO_TRAP,ToolTrap); /* This is a loop where a lot of points get drawn */ for(...) { ... CallPascal(x,y,MoveToProc); CallPascal(0,0,LineProc); } } This technique might be discussed in one of the Mac Tech Notes (but I don't have them with me). -- Julian Vrieslander Neurobiology & Behavior, W250 Mudd Hall, Cornell University, Ithaca NY 14853 UUCP: {cmcl2,decvax,rochester,uw-beaver}!cornell!batcomputer!eacj INTERNET: eacj@tcgould.tn.cornell.edu BITNET: eacj@CRNLTHRY