Forum: Ruby Bitmap -> GIF/PNG/JPG

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Cabf735ce7b8b4471ef46ea54f71832d?d=identicon&s=25 Michael Mahemoff (Guest)
on 2007-05-21 13:28
Hi,

Can anyone please recommend a package for generating images from a
bitmap vector. e.g. If I have an list of integers, each representing a
colour on the bitmap, and I want to build a GIF from it (along with some
other meta-info like dimensions).

The main options seem to be RMagick and RCairo, but neither seems to
take a bitmap input. I'd have to create a blank canvas and draw each
pixel. Do-able but inefficient.

Thanks,
Michael
B33ea5c12d767bfd1253940a960274f5?d=identicon&s=25 Tim Hunter (timhunter)
on 2007-05-21 14:00
Michael Mahemoff wrote:
> Hi,
>
> Can anyone please recommend a package for generating images from a
> bitmap vector. e.g. If I have an list of integers, each representing a
> colour on the bitmap, and I want to build a GIF from it (along with some
> other meta-info like dimensions).
>
> The main options seem to be RMagick and RCairo, but neither seems to
> take a bitmap input. I'd have to create a blank canvas and draw each
> pixel. Do-able but inefficient.
>
Check out Magick::Image#import_pixels:
http://www.simplesystems.org/RMagick/doc/image2.ht.... If
the input pixels are in a string buffer this is an extremely fast
method. If the pixel data are in an array it's still faster than drawing
each pixel separately.

If your pixel data are in a file you may be able to simply describe it
as being in "RGB" or "RGBA" format, in which case RMagick can convert it
for you. See http://www.imagemagick.org/script/formats.php.
This topic is locked and can not be replied to.