Я пытался написать пример. (Не перетаскивать)
require 'gtk3'
path = ARGV[0]
win = Gtk::Window.new('MyApp')
win.signal_connect('destroy') { Gtk.main_quit }
box = Gtk::Box.new(:vertical)
scr = Gtk::HScale.new(0.1, 5.0, 0.1)
scr.value = 1.0
swi = Gtk::ScrolledWindow.new
swi.set_size_request(300, 300)
img = Gtk::Image.new
pxb = Gdk::Pixbuf.new(file: path)
img.pixbuf = pxb
v_old = scr.value
scr.signal_connect('value-changed') do
v = scr.value
pxb_resized = pxb.scale(pxb.width * v, pxb.height * v, :hyper)
img.pixbuf = pxb_resized
# To keep center of image when you zoom up
w = swi.allocation.width
swi.vadjustment = swi.vadjustment.set_value(
(swi.vadjustment.value + w / 2.0) * (v / v_old) - w / 2.0
)
h = swi.allocation.height
swi.hadjustment = swi.hadjustment.set_value(
(swi.hadjustment.value + h / 2.0) * (v / v_old) - h / 2.0
)
v_old = v
end
# packing
win.add box
box.pack_start scr
box.pack_start swi, expand: true, fill: true
swi.add img
win.show_all
Gtk.main
Но на Mac pixbuf есть некоторые проблемы.https://github.com/ruby-gnome2/ruby-gnome2/issues/1079