# Inserting RMagick RVG images in wxRuby

**URL:** <https://www.ruby-forum.com/t/inserting-rmagick-rvg-images-in-wxruby/199556>\
**Category:** wxRuby\
**Created:** [November 24, 2010, 2:11am UTC](https://www.ruby-forum.com/t/inserting-rmagick-rvg-images-in-wxruby/199556 "2010-11-24T02:11:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![okkezSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/85f322/32.png) [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Post date:** [November 24, 2010, 2:11am UTC](https://www.ruby-forum.com/t/inserting-rmagick-rvg-images-in-wxruby/199556/1 "2010-11-24T02:11:55Z")

</div>

Hello, all -

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

---

<div class="post-metadata">

**Author:** ![walkins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/96bed5/32.png) [@walkins](https://www.ruby-forum.com/u/walkins)\
**Post date:** [November 25, 2010, 4:32pm UTC](https://www.ruby-forum.com/t/inserting-rmagick-rvg-images-in-wxruby/199556/2 "2010-11-25T16:32:01Z")

</div>

On 24/11/10 00:48, Don W. wrote:

> 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](http://rubyquiz.strd6.com/quizzes/191-mathematical-image-generator)

alex

---

<div class="post-metadata">

**Author:** ![walkins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/96bed5/32.png) [@walkins](https://www.ruby-forum.com/u/walkins)\
**Post date:** [November 25, 2010, 7:10pm UTC](https://www.ruby-forum.com/t/inserting-rmagick-rvg-images-in-wxruby/199556/3 "2010-11-25T19:10:52Z")

</div>

On Thu, Nov 25, 2010 at 7:13 AM, Alex F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > 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](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.

---

<div class="post-metadata">

**Author:** ![walkins](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/96bed5/32.png) [@walkins](https://www.ruby-forum.com/u/walkins)\
**Post date:** [November 25, 2010, 7:12pm UTC](https://www.ruby-forum.com/t/inserting-rmagick-rvg-images-in-wxruby/199556/4 "2010-11-25T19:12:45Z")

</div>

On Thu, Nov 25, 2010 at 9:02 AM, Don W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > > 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? 😃
