Sha256: 5b69b606c17cbef299b058c5b05e898a799b072650e6b1414589f9077d45abe6
Contents?: true
Size: 1.11 KB
Versions: 3
Compression:
Stored size: 1.11 KB
Contents
#!/usr/bin/env ruby # wxRuby2 Sample Code. Copyright (c) 2004-2006 Kevin B. Smith # Freely reusable code: see SAMPLES-LICENSE.TXT for details begin require 'wx' rescue LoadError => no_wx_err begin require 'rubygems' require 'wx' rescue LoadError raise no_wx_err end end # This sample demonstrates how to draw an image from a file onto a # window. This one uses a small PNG file, but other formats such as JPEG # are supported - see documentation for more details. class MyFrame < Wx::Frame def initialize(title) super(nil, -1, title) evt_paint { on_paint } img_file = File.join( File.dirname(__FILE__), 'paperclip.png') # first load the image into an Image object image = Wx::Image.new(img_file) # then create a Bitmap suitable for drawing @bitmap = Wx::Bitmap.new(image) end def on_paint paint do | dc | dc.clear dc.draw_bitmap(@bitmap, 0, 0, false) end end end class ImagesApp < Wx::App def on_init frame = MyFrame.new("Simple Image Demo") frame.show end end a = ImagesApp.new a.main_loop()
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
wxruby-1.9.4-i386-mswin32 | samples/drawing/images.rb |
wxruby-1.9.2-i386-mswin32 | samples/images/images.rb |
wxruby-1.9.1-i386-mswin32 | samples/images/images.rb |