Class: Qt::Image

Inherits:
Object show all
Defined in:
lib/rui/toolkits/qtbase/qt.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_renderer(size, renderer, id = nil) ⇒ Object

Render an svg object onto a new image of the specified size. If id is not specified, the whole svg file is rendered.



82
83
84
85
86
87
88
89
90
91
# File 'lib/rui/toolkits/qtbase/qt.rb', line 82

def self.from_renderer(size, renderer, id = nil)
  img = Qt::Image.painted(size) do |p| 
    if id
      renderer.render(p, id)
    else
      renderer.render(p)
    end
  end
  img
end

.painted(size, &blk) ⇒ Object

Paint on an image using the given block. The block is passed a painter to use for drawing.



71
72
73
74
75
76
# File 'lib/rui/toolkits/qtbase/qt.rb', line 71

def self.painted(size, &blk)
  img = Qt::Image.new(size.x, size.y, Qt::Image::Format_ARGB32_Premultiplied)
  img.fill(0)
  Qt::Painter.new(img).paint(&blk)
  img
end

Instance Method Details

#to_pixObject

Convert this image to a pixmap.



63
64
65
# File 'lib/rui/toolkits/qtbase/qt.rb', line 63

def to_pix
  Qt::Pixmap.from_image self
end