From: Paul Duncan Date: 2006-04-06T04:32:00+09:00 Subject: Re: Creating images from pixel data (RMagick?) --d01dLTUuW90fS44H Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * Tim Blair (tblair@rawnet.com) wrote: [snipped] > Does anyone have any suggestions as to how to increase this generation > speed? I've tried hunting through the RMagick docs for some way to > provide an array of pixel data or something similar, but nothing's > jumped out at me. Test code below. If RMagic has support for some sort of raw format (RGBA, etc), then it will probably be significantly faster to pack your raw pixel data (using Array#pack) and create a new image for each "frame" that way. If that won't work, Imlib2-Ruby may be fast enough to do what you want, I wrote a quick test and that loops and creates a full copy of a 32-bit 640x480 image. Note that depending on your application, this could probably be sped up significantly (specifically, the image data could be modified in place and wrapped using Imlib2::Image.create_using_data instead of copied repeatedly with Image#create_using_copied_data). Here are the machine specs: Linux halcyon 2.6.13.1-bs-skas-skas3-v9-pre7 #5 SMP Fri Oct 21 22:44:15 EDT 2005 i686 GNU/Linux model name : Intel(R) Pentium(R) M processor 2.13GHz cpu MHz : 798.213 bogomips : 1597.88 Here's the results of 5 separate runs on the aforementioned hardware, at 1000 frames each: user system total real cucd (x1000) 0.980000 1.150000 2.130000 ( 19.992796) "frames"/sec =3D ~50.2272937653813 fps cucd (x1000) 0.980000 1.140000 2.120000 ( 20.160243) "frames"/sec =3D ~49.7235522268876 fps cucd (x1000) 0.970000 1.130000 2.100000 ( 26.509965) "frames"/sec =3D ~38.0623666660269 fps cucd (x1000) 0.970000 1.200000 2.170000 ( 20.236222) "frames"/sec =3D ~50.6165552265999 fps cucd (x1000) 0.960000 1.150000 2.110000 ( 18.592911) "frames"/sec =3D ~54.1268296888017 fps Which averages out to approximately 48.5 FPS. Since the tests are measuring different things and our hardware is different, we can't compare times directly, but here's the output from a couple runs of your test code on my machine for reference: pabs@halcyon:~/proj/imlib2-fps-test> time ruby ./rmagic_test.rb=20 real 0m12.247s user 0m11.175s sys 0m0.351s pabs@halcyon:~/proj/imlib2-fps-test> time ruby ./rmagic_test.rb=20 real 0m12.014s user 0m11.197s sys 0m0.290s I've tarred up the test scripts, image (a shot of my football- obsessed friend's basement), and results and posted them at the following URL: http://pablotron.org/files/imlib2-ruby-fps_test.tar.gz (SHA1: d6c4f7208ce030591a064a445130e44fc0b64b0f) > Tim. --=20 Paul Duncan pabs in #ruby-lang (OPN IRC) http://www.pablotron.org/ OpenPGP Key ID: 0x82C29562 --d01dLTUuW90fS44H Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFENBsrzdlT34LClWIRAnDJAKDX0Vt9biWclFP4EhO4ticp2pWS0QCfW6gt +c9W+/Ch2jf+7BnUk7Wp1tA= =oPlb -----END PGP SIGNATURE----- --d01dLTUuW90fS44H--