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 -- -- Don Wilde "If you are creative and add value to the world, sleep well. You''ve earned it." _______________________________________________ wxruby-users mailing list wxruby-users@rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users
On 24/11/10 00:48, Don Wilde wrote:> 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?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 Quiz response for a Wx Mathematical Image Generator: http://rubyquiz.strd6.com/quizzes/191-mathematical-image-generator alex
On Thu, Nov 25, 2010 at 7:13 AM, Alex Fenton <alex at pressure.to> wrote:> On 24/11/10 00:48, Don Wilde wrote: > >> 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? >> > > > 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 Quiz 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. -- -- Don Wilde "If you are creative and add value to the world, sleep well. You''ve earned it." -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20101125/052a04d6/attachment.html>
On Thu, Nov 25, 2010 at 9:02 AM, Don Wilde <dwilde1 at gmail.com> wrote:> On Thu, Nov 25, 2010 at 7:13 AM, Alex Fenton <alex at pressure.to> wrote: > >> On 24/11/10 00:48, Don Wilde wrote: >> >>> 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? >>> >> >> >> 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 Quiz 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. > > >I should mention that I do know who Alonzo Church is, thanks to John McCarthy. Am I dating myself from the LISPocene Era? :D -- -- Don Wilde "If you are creative and add value to the world, sleep well. You''ve earned it." -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20101125/992f5841/attachment-0001.html>