Sha256: 1aa6390fb06ebc3bb281fe1e776d8a2cdf06817ae4af98118a375da45b5b6f48

Contents?: true

Size: 1.35 KB

Versions: 38

Compression:

Stored size: 1.35 KB

Contents

#!/usr/bin/env ruby
=begin
  scale.rb - Ruby/GdkPixbuf sample script.

  Copyright (c) 2002-2020 Ruby-GNOME Project Team
  This program is licenced under the same licence as Ruby-GNOME.

  $Id: scale.rb,v 1.10 2006/06/17 14:38:08 mutoh Exp $
=end

require 'gtk3'

filename = ARGV[0]
unless filename
  puts "ruby #{$0} filename"
  exit(1)
end

vbox = Gtk::Box.new(:vertical)

src =  GdkPixbuf::Pixbuf.new(:file => filename)
vbox.add(Gtk::Image.new(:pixbuf => src))

dst = src.scale(200, 200, :nearest)
dst.scale!(src, 60, 60, 90, 90, -50, 50, 6, 3)
vbox.add(Gtk::Image.new(:pixbuf => dst))

dst2 = GdkPixbuf::Pixbuf.new(:colorspace => :rgb,
                             :has_alpha =>true,
                             :bits_per_sample => 8,
                             :width => 200,
                             :height => 200)
dst2.scale!(src, 0, 0, 100, 100, 0, 0, 1.5, 1.5)

vbox.add(Gtk::Image.new(:pixbuf => dst2))

dst3 = GdkPixbuf::Pixbuf.new(:colorspace => :rgb,
                             :has_alpha =>true,
                             :bits_per_sample => 8,
                             :width => 200,
                             :height => 200)
dst3.scale!(src, 0, 0, 200, 200, 0, 0, 5, 3, :hyper)
vbox.add(Gtk::Image.new(:pixbuf => dst3))

window = Gtk::Window.new
window.signal_connect('delete-event') do
  Gtk.main_quit
end

window.add(vbox).show_all

Gtk.main

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
gdk_pixbuf2-4.2.7 sample/scale.rb
gdk_pixbuf2-4.2.6 sample/scale.rb
gdk_pixbuf2-4.2.5 sample/scale.rb
gdk_pixbuf2-4.2.4 sample/scale.rb
gdk_pixbuf2-4.2.3 sample/scale.rb
gdk_pixbuf2-4.2.2 sample/scale.rb
gdk_pixbuf2-4.2.1 sample/scale.rb
gdk_pixbuf2-4.2.0 sample/scale.rb
gdk_pixbuf2-4.1.9 sample/scale.rb
gdk_pixbuf2-4.1.8 sample/scale.rb
gdk_pixbuf2-4.1.7 sample/scale.rb
gdk_pixbuf2-4.1.6 sample/scale.rb
gdk_pixbuf2-4.1.5 sample/scale.rb
gdk_pixbuf2-4.1.4 sample/scale.rb
gdk_pixbuf2-4.1.3 sample/scale.rb
gdk_pixbuf2-4.1.2 sample/scale.rb
gdk_pixbuf2-4.1.1 sample/scale.rb
gdk_pixbuf2-4.1.0 sample/scale.rb
gdk_pixbuf2-4.0.9 sample/scale.rb
gdk_pixbuf2-4.0.8 sample/scale.rb