WxRuby: Opening and Displaying PNG images on a window

K

kpeng1

Hello,

I am still pretty new to wxwidgets and I am trying to learn as fast as
possible.

Currently I am using wxruby and I want to build an application that
would display all png images that are in its current directory as
thumbnails and once a user clicks on one of these thumbnails another
application would launch displaying a better resolution or larger
version of the thumbnail image.

I have been looking at the Image, ImageList and PNGHandler classes, but
I cannot seem to get anything to work. I cannot even declare a handler.

At this point I just want png thumbnails to display in a window.

Any help or hints would be appreciated.
 
A

Alex Fenton

kpeng1 said:
Hello,

I am still pretty new to wxwidgets and I am trying to learn as fast as
possible.

A good place to start is among the samples that come with wxruby and wxruby2. These give short illustrations of how to use a lot of the classes.
I have been looking at the Image, ImageList and PNGHandler classes, but
I cannot seem to get anything to work. I cannot even declare a handler.

There is a sample that shows how to load a PNG image. Something like:

class MyFrame < Wx::Frame
def initialize(title)
super(nil, -1, title)
evt_paint { on_paint }
image = Wx::Image.new('paperclip.png') # load the image from the file
@bitmap = Wx::Bitmap.new(image) # convert it to a bitmap, ready for drawing with
end

def on_paint
paint do | dc |
dc.clear
dc.draw_bitmap(@bitmap, 0, 0, false) # draw the
end
end
end

At this point I just want png thumbnails to display in a window.

Wx::Image seems to have 'resize' and 'rescale' methods among others, though I haven't ever tried these. All the methods that are (potentially) available can be seen at http://www.wxwindows.org/manuals/2.6.3/wx_wximage.html#wximage .

You could also use another package to create thumbnails, eg RMagick.
Any help or hints would be appreciated.

Another source of help is the wxruby mailing list

cheers
alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top