CXT105@PSUVM.BITNET (Christopher Tate) (02/17/89)
I know this is going to sound pretty stupid, but I don't have access to the Inside Macintosh books.... What is the best way to plot a single point in a given GrafPort (window, screen or other)? A friend has told me the only way he knows of is to MoveTo the proper point, then Line(0,0) to draw it. This strikes me as pretty strange; there should be a primitive for drawing a single point. Unfortunately, I don't have access to IM, and neither the Turbo Pascal manual nor the LightspeedC 1.00 (!) manual (which is all that the Comp Center here has -- the C is version 2.some) is terribly easy to use for investigating the built-in routines. Can someone help me? ------- Christopher Tate | somewhere i have never travelled, cxt105@psuvm.psu.edu | gladly beyond any experience, ...!psuvax1!psuvm.bitnet!cxt105 | your eyes have their silence.
rubinoff@linc.cis.upenn.edu (Robert Rubinoff) (02/18/89)
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)? >A friend has told me the only way he knows of is to MoveTo the proper point, >then Line(0,0) to draw it. This strikes me as pretty strange; there should be >a primitive for drawing a single point. Since QuickDraw points fall inbetween pixels, I doubt very much whether you want to draw just a point. Presumably you want to draw just a single pixel; the simplest way to do that is to either draw a 1x1 rectangle around it or a 1-pixel long 1-pixel wide line across it. But since the pen must be at least one pixel high and one pixel wide to draw, this really means drawing a 0x0 rectangle or a 0-length line. Robert
lim@iris.ucdavis.edu (Lloyd Lim) (02/18/89)
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)? > >A friend has told me the only way he knows of is to MoveTo the proper point, >then Line(0,0) to draw it. Yep, this is the best way to do it. It's not really that strange. Most people don't draw single points that often anyway. QuickDraw has many more powerful features. +++ Lloyd Lim Internet: lim@iris.ucdavis.edu Compuserve: 72647,660 US Mail: 146 Lysle Leach Hall, U.C. Davis, Davis, CA 95616
oster@dewey.soe.berkeley.edu (David Phillip Oster) (02/19/89)
The problem with drawing a single point is that quickdraw does some fairly complex clipping for you. If you need to draw lots of single points, the best way is to modify an off-screen bitmap via direct bit-twiddling, then CopyBits the modified area to the screen. This lets quickdraw do its clipping more sparingly.
jmunkki@kampi.hut.fi (Juri Munkki) (02/19/89)
In article <3695@ucdavis.ucdavis.edu> lim@iris.ucdavis.edu (Lloyd Lim) writes: >In article <71976CXT105@PSUVM> CXT105@PSUVM.BITNET (Christopher Tate) writes: >>What is the best way to plot a single point in a given GrafPort >> >>A friend has told me the only way he knows of is to MoveTo the proper point, >>then Line(0,0) to draw it. > >Yep, this is the best way to do it. It's not really that strange. Most people >don't draw single points that often anyway. QuickDraw has many more powerful >features. That's the easiest way to do it. The best way (fastest) is to call PaintRect with a rectangle containing a single pixel. You have to make two toolbox calls to draw a pixel, if you use MoveTo and LineTo. The fastest way to draw multiple pixels is to create an offscreen bitmap and write directly to this bitmap. You can then copy this bitmap to your grafport. _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ | Juri Munkki jmunkki@hut.fi jmunkki@fingate.bitnet I Want Ne | | Helsinki University of Technology Computing Centre My Own XT | ~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~
mentat@walt.cc.utexas.edu (Robert Dorsett) (02/20/89)
In article <19810@santra.UUCP> jmunkki@kampi.UUCP (Juri Munkki) writes: >>In article <71976CXT105@PSUVM> CXT105@PSUVM.BITNET (Christopher Tate) writes: >>>What is the best way to plot a single point in a given GrafPort >>> >The fastest way to draw multiple >pixels is to create an offscreen bitmap and write directly to this bitmap. You >can then copy this bitmap to your grafport. That's not entirely true: while it will give you the fastest APPEARANCE of drawing on the screen, it won't be the FASTEST, since you're adding a third step--copying a (potentially large) bitmap to the screen, after making the drawing commands. One need only fool around with a Supermac monitor, copying color bitmaps around, to see the potential problems here. But for flicker-free animation, or to make things "look nice," yes, the use of offscreen bitmaps can make software look really spiffy. The old LSC documentation (and, I believe, the old Megamax documentation) had examples a plenty of drawing directly onto the screen memory, which is the fastest way of plotting of all...:-) Robert Dorsett Internet: mentat@walt.cc.utexas.edu (Robert Dorsett) UUCP: ...cs.utexas.edu!walt.cc.utexas.edu!mentat
casseres@Apple.COM (David Casseres) (02/21/89)
In article <71976CXT105@PSUVM> CXT105@PSUVM.BITNET (Christopher Tate) writes: >I know this is going to sound pretty stupid, but I don't have access to the >Inside Macintosh books.... > >What is the best way to plot a single point in a given GrafPort (window, screen >or other)? > >A friend has told me the only way he knows of is to MoveTo the proper point, >then Line(0,0) to draw it. This strikes me as pretty strange; there should be >a primitive for drawing a single point. Line(0,0) is as primitive as it gets; don't worry, it's efficient. David Casseres
eacj@batcomputer.tn.cornell.edu (Julian Vrieslander) (02/21/89)
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 <pascal.h> #include <OSUtil.h> /* 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