class PDFWalker::ImgViewer

Attributes

image[R]

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/pdfwalker/imgview.rb, line 26
def initialize
    super()

    set_title "Image view"
    set_decorated false
    set_resizable false

    add_events(Gdk::Event::KEY_RELEASE_MASK)
    signal_connect('key_release_event') { |_, event|
        destroy if event.keyval == Gdk::Keyval::GDK_Escape
    }
end

Public Instance Methods

show_compressed_img(data) click to toggle source
# File lib/pdfwalker/imgview.rb, line 55
def show_compressed_img(data)
    loader = GdkPixbuf::PixbufLoader.new
    loader.last_write data

    pixbuf = loader.pixbuf
    set_default_size pixbuf.width, pixbuf.height

    @image = Gtk::Image.new(pixbuf)
    add @image

    show_all
end
show_raw_img(data, w, h, bpc, bpr) click to toggle source
# File lib/pdfwalker/imgview.rb, line 39
def show_raw_img(data, w, h, bpc, bpr)
    set_default_size w,h

    pixbuf = GdkPixbuf::Pixbuf.new data: data,
                colorspace: GdkPixbuf::Colorspace::RGB,
                has_alpha: false,
                bits_per_sample: bpc,
                width: w, height: h,
                row_stride: bpr

    @image = Gtk::Image.new(pixbuf)
    add @image

    show_all
end