Re: Quickly drawing non-antialiased, discrete, pixels
Re: Quickly drawing non-antialiased, discrete, pixels
- Subject: Re: Quickly drawing non-antialiased, discrete, pixels
- From: Bill Bumgarner <email@hidden>
- Date: Sun, 5 Jan 2003 20:23:18 -0500
On Sunday, Jan 5, 2003, at 17:26 US/Eastern, Cameron Hayne wrote:
On 5/1/03 2:04 pm, "Bill Bumgarner" <email@hidden> wrote:
I'm actually using simply RGB w/no alpha channel. It
takes 20 seconds to render 100,000 points with 2 second update
intervals.
Hmm, maybe I'm not understanding properly but this sounds extremely
slow -
does that mean you have a display update rate of 5000 pixels per
second?
The calculation algorithm itself is in pure Python and, hence, is about
a bazillion times slower than anything written in straight C.
Specifically:
def hopalong(a=30.0, b=1.0, c=0.9, iterations=1000000, numColors=1000,
scale=10.0, xoffset=150, yoffset=150):
x = 0.0
y = 0.0
colors = genColors(numColors)
colorIter = iterations / len(colors)
while 1:
for i in range(len(colors)):
points = []
for j in range(colorIter):
if x < 0:
temp = y + math.sqrt(abs(b * x - c))
else:
temp = y - math.sqrt(abs(b * x - c))
y = a - x
x = temp
points.append( ( xoffset + (scale * x), yoffset +
(scale * y) ) )
yield (colors[i], points)
Your point made me test what happens with zero rendering -- answer:
using an NSBitmapImageRep in RGBRGBRGBRGB (i.e. non-planar mode) is
actually relatively efficient. The overhead is still significant in
comparison to being able to directly pain individual pixels, but not to
the degree I thought.
It seems that there simply isn't an efficient way to paint sets of
individual discrete pixels under Cocoa right now. I will need to
investigate either CG or OpenGL.
My test application "ImageCalc" gets a display update rate of 2
megapixels
per second on my iBook 600. I'm calculating the pixel values (at a
rate of 5
megapixels per second) and displaying periodically via
NSBitmapImageRep like
you are doing. But my pixel values are 0-255 so I'm using an 8 bit
NSBitmapImageRep with NSDeviceWhiteColorSpace. Can it be that using
full-colour is that much more expensive?
Doubtful -- I'm sure that if I were to rewrite the above algorithm in
straight C, I would see a similar fill rate. Full-color-- assuming a
reasonable pixel layout-- should be considerably more efficient in that
you don't have to look up each pixel in some other table to get the
values that are then shoved onto the screen.
You can download my ImageCalc project at:
http://hayne.net/MacDev/ImageCalc/
To see the update rates, open the Statistics drawer via the Window
menu.
I will do that when I'm on something better than a 20kbit/second
connection at 12cents/minute. :-)
b.bum
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.