Bitmaps

How can I create a bitmap in Ruby? I have a bunch of RGBA values, and need
to convert them into a bitmap or some other picture format.

Thanks,
Joe

Joe Van Dyk wrote:

How can I create a bitmap in Ruby? I have a bunch of RGBA values, and need
to convert them into a bitmap or some other picture format.

I'd recommend the Ruby-GD bindings.

Tim.

···

--
Tim Bates
tim@bates.id.au

Joe Van Dyk wrote:

How can I create a bitmap in Ruby? I have a bunch of RGBA values, and need
to convert them into a bitmap or some other picture format.

You can use my appended PNG writer class. Generating PNM images (there very different to PNG!!!) is even simpler.

Regards,

   Michael

png.rb (3.23 KB)

Joe Van Dyk wrote:

How can I create a bitmap in Ruby? I have a bunch of
RGBA values, and need to convert them into a bitmap or
some other picture format.

Thanks,
Joe

Also, the RGBA values are stored in a unsigned long, in network byte order.
How can I get them out into integers from 0 to 255?

Joe Van Dyk wrote:

How can I create a bitmap in Ruby? I have a bunch of RGBA values, and need
to convert them into a bitmap or some other picture format.

I wanted the reverse recently, and I used RMagick to read my png
files. It would probably work for what you want also.

I was experimenting with a new image coding method like PNG with
Adam-7 pixel ordering, that yields some nice behaviour for raster
maps in that you can create a 1/Nth scale map (N a power of two)
by reading and decompressing only 1/N^2 of the file.

I'd like to write a viewer for the resultant files, but I need to
work out how to create GTK images using RBG data. Any examples
to look at?

I also want to use dynamic images in a column of a GTK treeview.
It looks like it should be possible, but I've scratched my head
nearly hairless trying.

Nice PNG code Michael, thanks.

http://www.ntecs.de/viewcvs/viewcvs/Misc/png.rb

Regards,

   Michael

···

Ara.T.Howard@noaa.gov wrote:

On Tue, 16 Nov 2004, Michael Neumann wrote:

--------------060203080807000504090503
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Joe Van Dyk wrote:

How can I create a bitmap in Ruby? I have a bunch of RGBA values, and need
to convert them into a bitmap or some other picture format.

You can use my appended PNG writer class. Generating PNM images (there
very different to PNG!!!) is even simpler.

Regards,

  Michael

wow. that's some neat code. have you released somewhere?