I’m having a grand time making cpu stats for an embedded board show up
in my
ruby app, but I have run into a roadblock. I used RMagick’s RVG graphics
to
create the graph, and it works fine when I just dump it to an image file
such as .png. I’m trying to eliminate that step and write it directly to
a
panel in my Wx gui, but it appears – and there’s a statement in the
docs
that confirms it – that RVG::Image != Magick::Image. I experimented
quite a
bit with the sample program that takes a RMagick image and inserts it,
but I
haven’t been able to make those techniques work for RVG. Is there a
conversion?
I’ve started looking at the Wx GraphicsContext methodology, but it isn’t
as
elegant. Suggestions?
wxRuby 2.0.1
RMagick 2.12.1
Ubuntu 9.10 32 bit
Ruby 1.87 p 302
I’ve started looking at the Wx GraphicsContext methodology, but it
isn’t as elegant. Suggestions?
I’m not completely sure I understand what you want to do - but I think
the easiest way is to Wx tell RVG to render the vector at a given
resolution in a well-known bitmap format (eg PNG), and then display that
in Wx.
You can bypass writing the rendered image to disk by using Image.read,
and a StringIO if necessary - so it can just be passed about in memory.
Re-render the image when the display size changes. You might find
something useful in my Ruby Q. response for a Wx Mathematical Image
Generator: http://rubyquiz.strd6.com/quizzes/191-mathematical-image-generator
conversion?
You can bypass writing the rendered image to disk by using Image.read, and
a StringIO if necessary - so it can just be passed about in memory.
Re-render the image when the display size changes. You might find something
useful in my Ruby Q. response for a Wx Mathematical Image Generator: http://rubyquiz.strd6.com/quizzes/191-mathematical-image-generator
alex
Alex, thanks!
Your presentation and the sample file in wxruby samples were outstanding
and
a heck of a lot of fun to play with. Some of the other demos get too
cute
for their own good, but yours was very clear. I am using it to figure
out
how to get my DC from point-painting to lines.
I have decided to rework my code so that the graph-drawing code is
embedded
in the Window subclass and done completely in wx DC methodology. It’s
not as
straightforwardly obvious and Ruby idiomatic, but I’m making it work and
the
code outside of the graph-drawing routine is getting much cleaner.
bit with the sample program that takes a RMagick image and inserts it, but I
a well-known bitmap format (eg PNG), and then display that in Wx.
Alex, thanks!
I should mention that I do know who Alonzo Church is, thanks to John
McCarthy. Am I dating myself from the LISPocene Era?
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.