Sha256: 2e86ec6ff4da43d97b1a7387ddc1dc4915b6cc0172c6914a868ed00bde4237e8

Contents?: true

Size: 1.06 KB

Versions: 17

Compression:

Stored size: 1.06 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

17 entries across 17 versions & 1 rubygems

Version Path
wxruby-1.9.3-i386-mswin32 samples/drawing/images.rb
wxruby-1.9.2-powerpc-darwin8.10.0 samples/images/images.rb
wxruby-1.9.2-i686-linux samples/images/images.rb
wxruby-1.9.2-i686-darwin8.8.2 samples/images/images.rb
wxruby-1.9.1-powerpc-darwin8.3.0 samples/images/images.rb
wxruby-1.9.1-i686-linux samples/images/images.rb
wxruby-1.9.1-i686-darwin8.4.1 samples/images/images.rb
wxruby-1.9.0-powerpc-darwin8.10.0 samples/images/images.rb
wxruby-1.9.0-i686-linux samples/images/images.rb
wxruby-1.9.0-i686-darwin8.4.1 samples/images/images.rb
wxruby-1.9.0-i386-mswin32 samples/images/images.rb
wxruby-1.9.1-x86_64-linux samples/images/images.rb
wxruby-1.9.2-x86_64-linux samples/images/images.rb
wxruby-1.9.3-universal-darwin samples/drawing/images.rb
wxruby-1.9.3-x86-linux samples/drawing/images.rb
wxruby-1.9.4-x86_64-linux samples/drawing/images.rb
wxruby-1.9.4-x86-linux samples/drawing/images.rb