if (do_name() != 'Home') : ?>
endif ?>
Posted by Tom De Smedt on Oct 16, 2009
include("util/comment.php"); ?>
This is the fastest way that I know of (thanks to Duane Bailey's post). It uses a Numeric array to store pixel values between 0 and 255, and NSBitmapImageRep to create a TIFF byte string which you can then pass to the image() command:
from AppKit import NSBitmapImageRep, NSDeviceRGBColorSpace from Numeric import array width, height = 400, 400 pixels = array([0] * width * height * 4, typecode='c') for i in range(len(pixels)/4): pixels[i*4+0] = random(255) # R pixels[i*4+1] = random(255) # G pixels[i*4+2] = random(255) # B pixels[i*4+3] = 255 # A pixels = (pixels, None, None, None, None) img = NSBitmapImageRep.alloc().initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bytesPerRow_bitsPerPixel_( pixels, width, height, 8, 4, True, False, NSDeviceRGBColorSpace, width * 4, 32 ) bytes = img.TIFFRepresentation() image(None, 0, 0, data=bytes)
Speeding Up Bitlevel Noodling
Posted by Brian M. Dennis on Oct 15, 2009Howdy!
I'm a NodeBox noob. For fun, I'm trying to recreate Jared Tarbell's substrate processing sketch in NodeBox. Using the CoreImage module, the code transliteration is pretty straightforward. However, the result is painfully slow.
My guess, as suggested by the CoreImage docs, is that layer.set_pixel is pretty slow. Are there any suggestions for batching up a bunch of bit manipulations and blasting them to a layer all at once? Or alternative, faster ways to do bit level manipulations in NodeBox? I know this isn't supposed to be NodeBox's forte', but I'm hoping there's a common technique that I'm missing.
Thanks in advance!