[comp.sys.mac.programmer] Graduate CompSci Progs for MacHack

gilsonr@turing.cs.rpi.edu (Robert Gilson) (04/15/90)

	What's the fastest way to turn on one pixel? Do I really have to
call MoveTo() and LineTo() each time? Is there a routine SetPixel() that
would be the sibling of GetPixel()? 

	Any help would be appreciated. 
	Thanks in advance.
	Bob 

keith@Apple.COM (Keith Rollin) (04/15/90)

In article <_$S#VX_@rpi.edu> gilsonr@turing.cs.rpi.edu (Robert Gilson) writes:
>
>	What's the fastest way to turn on one pixel? Do I really have to
>call MoveTo() and LineTo() each time? Is there a routine SetPixel() that
>would be the sibling of GetPixel()? 

Bob,

There are two ways you can do this (three, if you count the one you propose):

1) Call PaintRect with a one pixel by one pixel rectangle. I understand
from one of the QuickDraw guys that this is pretty well optimized.
Using this technique, you can write your own SetPixel that takes a
point, converts it to the appropriate rectangle, and calls PaintRect.
(Please don't ask me why it's not in the QuickDraw call set - I don't
know the answer.)

2) If you are drawing to your own Bitmap or Pixmap, you can do the math
and set the appropriate bits yourself. Many people do this if they are
doing a lot of pixel-by-pixel operations, such as plotting a graph or
countour map. The reason why you can do this with an offscreen
(c)grafport is because you don't have to take into account other
windows and ports that may be overlapping yours, and you don't have to
worry about the visRgn being something other than the full size of your
port. The advantage of this method is that it's fast. The disadvantages
are that you have to figure out the location of the bits you have to
set, do some bitfield operations, figure out the pixel value if you are
running in a color system, and futz with 32-bit CPU mode if you are
running with 32-bit color QuickDraw.

-- 
------------------------------------------------------------------------------
Keith Rollin  ---  Apple Computer, Inc.  ---  Developer Technical Support
INTERNET: keith@apple.com
    UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith
"Argue for your Apple, and sure enough, it's yours" - Keith Rollin, Contusions