Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!hoptoad!tim From: tim@hoptoad.uucp (Tim Maroney) Newsgroups: comp.sys.mac.programmer Subject: Re: turning on a pixel Message-ID: <8353@hoptoad.uucp> Date: 21 Aug 89 18:21:22 GMT References: <6294@hubcap.clemson.edu> Reply-To: tim@hoptoad.UUCP (Tim Maroney) Organization: Eclectic Software, San Francisco Lines: 45 In article <6294@hubcap.clemson.edu> mikeoro@hubcap.clemson.edu (Michael K O'Rourke) writes: >I am writing a graphics program that turns on many pixels one at a time >by calculating some mathematical eqns. (kind of a fractal). It presently >is using : > >moveto(x,y); >lineto(x,y); > >to turn on a pixel. Is there some quicker way to do this from pascal? >The program is horribly slow right now and it needs to be speeded up. >For instance, does someone have a quick assembly routine that will turn >on a pixel? I'd be willing to convert to LSC so that i could use the >inline assembly if it would really improve speed. First of all, have you tried running the program without any drawing? I wrote a silly little one-level B&W Mandelbrot program on a Mac II a few years back, and it was tremendously slow, but it was spending all its time in math, not in drawing. Fractals are very slow to compute -- generally this is so even when you use tricks like "if every surrounding pixel is black, the contained pixel is black". But assuming that your problem really is in the drawing, then it's probably the trap overhead, not any slowness of the QD routines themselves, which on the Mac Plus and later ROMs really are about as fast as you could hope for. You can short-circuit them by using NGetTrapAddress and calling that address instead of trapping; you might expect to see an improvement of as much as 30% in drawing speed. This is not the world's most kosher technique, but it's marginally better than drawing directly to the screen bitmap from your software, which has been expressly forbidden by every compatibility guidelines list from Eden onwards. But if you must draw to the screen, then it's really not all that hard to do. Just familiarize yourself with the bitmap data structure and the bit twiddling will be easy. Pascal on the Mac has some inline bit-setting operators which should let you avoid assembly language. I'm not going to give much counsel in such a nasty technique, but it really is not hard to mess with bitmaps directly. It just looks that way before you start. -- Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com "There are no Famous People on the net. Only some of us with bigger mouths than others." -- Dan'l Danehy-Oakes, The Roach