From: Tim Hunter Date: 2005-04-05T03:09:43+09:00 Subject: Re: Extension question Joe Van Dyk wrote: > Hi, > > I'm generating a fairly large image file (can be 10000x10000) pixels > by reading some binary data and setting each pixel. As you can > imagine, pure Ruby is REALLY slow, I think because of the loops. I've > written the program in C and it's literally hundreds to thousands of > times faster (depending on image size). Have you tried RMagick? http://rmagick.rubyforge.org. The constitute method may be useful: http://www.simplesystems.org/RMagick/doc/image1.html#constitute That method requires you to have all the pixel data in memory at once, though, which could be a problem unless you have a LOT of RAM. You could use import_pixels to set just a subset of pixels at a time: http://www.simplesystems.org/RMagick/doc/image2.html#import_pixels That would minimize the memory requirements. In both cases you'd have to convert your binary data to a Ruby numeric type. Don't know whether that would be too slow or not.