Re: Drawing Pixels with NSBezierPath
Re: Drawing Pixels with NSBezierPath
- Subject: Re: Drawing Pixels with NSBezierPath
- From: Scott Thompson <email@hidden>
- Date: Tue, 6 Jul 2004 22:37:33 -0500
Use OpenGL.
<http://developer.apple.com/opengl>
<http://developer.apple.com/documentation/Cocoa/Conceptual/OpenGL>
Create a rectangular texture the same size as your view's bounds, and
set the context to per-pixel orthogonal projection. Enable client
storage and texture range, and texture priority 0. Now you can write
into the texture's memory buffer and store direct pixel color values,
using row/col indexing. Many ways to do what you want with the
pixels. Your speed should increase a hundred-fold, and it's only a
little more complicated to support hardware that requires power-of-2
texture sizes (ATI Rage 128/Pro/M3).
Another option would be to allocate a pixel buffer yourself, set up the
pixels the way you want them to look, then use Core Graphics to create
a CGImage from that pixel buffer. This is conceptually similar to the
OpenGL route, but will require a lot less overhead to setup and use.
For that matter you could probably create an NSBitmapImageRep from your
pixel buffer, create an NSImage from that, and use NSImage's drawing
routines to get much the same effect.
Scott
_______________________________________________
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.