From: "Ara.T.Howard" Date: 2005-08-30T09:02:39+09:00 Subject: Re: rmagick question On Tue, 30 Aug 2005, Timothy Hunter wrote: > I'm not surprised that the 256-color IM is the fastest solution. I'm also > not surprised that a pure-C solution is faster than a Ruby solution. All > those channel values have to be converted from integers to Fixnums and back > to integers, not to mention constructing 5M Magick::Pixel objects. > > Thanks for sharing what you learned. This'll be useful for the next guy to > face a similar problem. hi tim- i was playing with something along the lines of na = NArray::byte 1000, 1000 img = RMagick::Image::new # i forget the syntax attm img.set_pixels na.to_s but this blew up with a complaint about needing an array. my question - is there any reason to check the type for these sorts of things? i mean, if it's only a few methods required why not just call them and blow up if the obj does not support them? i was hoping to combine NArray and RMagick for the obvious speed advantage one could gain - for instance being able to 'darken' and image a little with na = na - 1 is pretty powerful... but getting the values back out puts you into loop land... in general it seems like there should be someway, with RMagick, to say img.pixels = buffer and that buffer had better be a binary packed respresentation of the pixels. this would allow usage with narray and mmap. the nice thing about using mmap is that you could spawn subprocesses to work on part of an image using shared memory and, when all children had finished, dump the pixels into your image. it could be very powerful. the narray lib has a similar approach in that you can say things like na = NArray::to_na buffer, NArray::BYTE, 1000, 1000 and the buffer is slurped in at once, i assume using memcpy. might an approach like this for image magic make faster operations possible? or is the layout of pixels never inline is a way that could take advantage of something like that? cheers. -a -- =============================================================================== | email :: ara [dot] t [dot] howard [at] noaa [dot] gov | phone :: 303.497.6469 | Your life dwells amoung the causes of death | Like a lamp standing in a strong breeze. --Nagarjuna ===============================================================================