[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

WxRuby: Opening and Displaying PNG images on a window

kpeng1

7/25/2006 4:36:00 PM

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.

1 Answer

Alex Fenton

7/25/2006 6:02:00 PM

0

kpeng1 wrote:
> 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.ht... .

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