Class: PDFWalker::ImgViewer
- Inherits:
-
Window
- Object
- Window
- PDFWalker::ImgViewer
- Defined in:
- lib/pdfwalker/imgview.rb
Instance Attribute Summary collapse
-
#image ⇒ Object
readonly
Returns the value of attribute image.
Instance Method Summary collapse
-
#initialize ⇒ ImgViewer
constructor
A new instance of ImgViewer.
- #show_compressed_img(data) ⇒ Object
- #show_raw_img(data, w, h, bpc, bpr) ⇒ Object
Constructor Details
#initialize ⇒ ImgViewer
Returns a new instance of ImgViewer.
26 27 28 29 30 31 32 33 34 35 36 37 |
# 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 |
Instance Attribute Details
#image ⇒ Object (readonly)
Returns the value of attribute image.
24 25 26 |
# File 'lib/pdfwalker/imgview.rb', line 24 def image @image end |
Instance Method Details
#show_compressed_img(data) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 |
# 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) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# 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 |