Sha256: b8b722ff817ab14bbfdb625668f9732d96ef788d0d41bbb28b525d8384632b6d
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 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 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wxruby-1.9.5-i386-mswin32 | samples/drawing/images.rb |