Sha256: 9380412dd30656fc78846e75078c26a0f2f449ec52b1afae586d0a5f236dd1a8

Contents?: true

Size: 995 Bytes

Versions: 3

Compression:

Stored size: 995 Bytes

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 ImageFrame < Wx::Frame
  def initialize
    super(nil, :title => 'Simple image demo')

    # Load a PNG bitmap from a file for drawing
    img_file = File.join( File.dirname(__FILE__), 'paperclip.png')
    @bitmap = Wx::Bitmap.new(img_file, Wx::BITMAP_TYPE_PNG)

    # Set up the drawing to be done when the frame needs re-painting
    evt_paint :on_paint
  end

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

Wx::App.run do
  ImageFrame.new.show
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
wxruby-1.9.5-universal-darwin-9 samples/drawing/images.rb
wxruby-1.9.5-x86-linux samples/drawing/images.rb
wxruby-1.9.5-x86_64-linux samples/drawing/images.rb