Alex Fenton
9/11/2007 5:45:00 PM
Hi
Weston Campbell wrote:
> I've been working with ruby for quite a while now, and I still don't
> know how to manipulate graphics. I know about libraries like RMagick,
> but how do they do it?
Libraries like RMagick are intended for manipulating images in files
(for example, resizing or rotating them) without actually displaying
them on screen.
> What are the rudimentary methods used to, say,
> display an image or pixel to the screen?
For that you will need a GUI toolkit which knows how to display images
and pixels within a desktop environment like Windows or OS X.
There are several GUI toolkits available for Ruby. They all have
strengths and weaknesses but any should be able to draw an image on screen.
As an example, wxRuby is easy to install (gem install wxruby) and
handles a wide variety of image formats (JPG/PNG/TIF/BMP etc). It has a
demonstration of painting images on screen in samples/images/images.rb.
It can also use Device Contexts to draw primitives like lines and
circles, as well as images and text, onto screen or to a printer. See
samples/printing/printing.rb
I would expect most of the other major toolkits have similar examples of
how to achieve this with that API.
> Do I have to use C or Java just
> to accomplish this?
No, thank goodness.
hth
alex