Search code examples
macosbitmapscreensaver

OS X ScreenSaver efficient per-pixel manipulation


I want to create a OS X screensaver that will compute color data for each pixel.

Now I'm using

NSBitmapImageRep *canvas;

but calling setPixel for every point and drawInRect every animateOneFrame call just make it useless. It is way too slow. I'm searching for better solutions.

I want to do something like SDL_Surface can do, that is raw screen data modification with double buffering.


Solution

  • You can directly access the raw memory in the NSBitmapImageRep (via it's bitmapData property). This is faster than using the setPixel method but you have to know exactly how the pixel data is stored in memory.