Hiya, I was trying to figure out how to display PNG files using wxWindows/wxRuby. Google turned up a few things, mainly discussing the wxImageHandler class and it''s children, etc, but there seems to be no mention of them in the wxRuby source. Are they there, and I missed them, or are they just not there? If there not there, is there a quick and dirty way to get them in? It seems like the build does some automatic stuff, but I''m not really clear on which bits are generated and which bits a are handcoded. If someone could point out a few examples of the generated stuff, I might have a go at adding the wxImageHandler stuff etc. H
You need to call wxInitAllImageHandlers (init_all_image_handlers) first. You''ll need the latest version from CVS, as the 0.1.0 version doesn''t support it. Nick Hunter Kelly wrote:>Hiya, I was trying to figure out how to display PNG files using >wxWindows/wxRuby. Google turned up a few things, mainly discussing >the wxImageHandler class and it''s children, etc, but there seems to >be no mention of them in the wxRuby source. > >Are they there, and I missed them, or are they just not there? > >If there not there, is there a quick and dirty way to get them in? >It seems like the build does some automatic stuff, but I''m not really >clear on which bits are generated and which bits a are handcoded. > >If someone could point out a few examples of the generated stuff, I >might have a go at adding the wxImageHandler stuff etc. > >H > > >_______________________________________________ >wxruby-users mailing list >wxruby-users@rubyforge.org >http://rubyforge.org/mailman/listinfo/wxruby-users > > > > >
Hunter Kelly wrote:> Hiya, I was trying to figure out how to display PNG files using > wxWindows/wxRuby. Google turned up a few things, mainly discussing > the wxImageHandler class and it''s children, etc, but there seems to > be no mention of them in the wxRuby source. > > Are they there, and I missed them, or are they just not there?Greetings! As Nick said, part of the answer is grabbing the latest snapshot of wxruby, and calling Wx::init_all_image_handlers It''s not immediately obvious, but you can grab a nightly snapshot tarball off rubyforge if you don''t have CVS handy. Go to the CVS tab of our project, choose the upper link at the right side (Browse using ViewCVS), and then choose "Download tarball". Note that it will expand into a directory named ''wxruby'' by default, so make sure you''re in the right place before un-tarring it. Anyway, I was curious how this stuff works, so I wrote the following little program (starting with nothing.rb as a skeleton) that will display a .png file in a window. It assumes you have a file named paperclip.png in the current directory. By the way, thanks to Nick Kral for implementing the really cool ''paint'' method. It''s exactly what I wanted here! ############################ require ''wxruby'' class MyFrame < Wx::Frame def initialize(title) super(nil, -1, title) evt_paint do onPaint end image = Wx::Image.new(''paperclip.png'') @bitmap = Wx::Bitmap.new(image) end def onPaint puts("onPaint begin") paint do | dc | dc.clear dc.draw_bitmap(@bitmap, 0, 0, false) end puts("onPaint end") end end class ImagesApp < Wx::App def OnInit frame = MyFrame.new("Minimal wxRuby App") frame.show end end Wx::init_all_image_handlers a = ImagesApp.new a.main_loop() ############################> If someone could point out a few examples of the generated stuff, I > might have a go at adding the wxImageHandler stuff etc.No need for that one, but if you want a class that doesn''t already exist, you can try creating a .t file for it. I described the process recently in this email message: http://rubyforge.org/pipermail/wxruby-users/2003-November/000116.html Cheers, Kevin
Hiya, I was trying to figure out how to display PNG files using wxWindows/wxRuby. Google turned up a few things, mainly discussing the wxImageHandler class and it''s children, etc, but there seems to be no mention of them in the wxRuby source. Are they there, and I missed them, or are they just not there? If there not there, is there a quick and dirty way to get them in? It seems like the build does some automatic stuff, but I''m not really clear on which bits are generated and which bits a are handcoded. If someone could point out a few examples of the generated stuff, I might have a go at adding the wxImageHandler stuff etc. H