Create  Edit  FrontPage  Index  Search  Changes  History  RSS  Login

RSVG::Handle

class RSVG::Handle

Since 2.14

Class Methods

RSVG::Handle.new(gz=nil)

Returns a new rsvg handle. This handle can be used for dynamically loading an image. You need to feed it data using RSVG::Handle#write, then call RSVG::Handle#close when done. No more than one image can be loaded with one handle.

Since 2.12 gz is ignored. RSVG::Handle can handle GZiped SVG or not automatically.

  • gz: Specify true if you want to handle GZipped SVG (svgz) instead of normal SVG (svg).
  • Returns: A new RSVG::Handle
RSVG::Handle.new_from_data(data)
Loads the SVG specified by data.
RSVG::Handle.new_from_file(file_name)
Loads the SVG specified by file_name.
  • file_name: The file name to load. If built with gnome-vfs, can be a URI.
  • Returns: A RSVG::Handle.

Instance Methods

base_uri
Gets the base uri for the self. Since 2.9
  • Returns: the base URI, possibly nil?
base_uri=(base_uri)
Set the base URI for this SVG. Since 2.9
  • base_uri: the base URI
  • Returns: base_uri
close
Closes self, to indicate that loading the image is complete. This will return true if the loader closed successfully.
  • Returns: true if the loader closed successfully, raises RSVG::Error if there was an error, or nil if the loader already closed.
closed?
  • Returns: Whether closed or not
desc
Returns the SVG's description in UTF-8 or nil.
  • Returns: The SVG's description
dimensions
Get the SVG's size. Do not call from within the size_func callback, because an infinite loop will occur.
  • Returns:dimension_data: RSVG::Dimensions?
metadata
Returns the SVG's metadata in UTF-8 or nil. Since 2.9
  • Returns: The SVG's metadata
pixbuf(id=nil)
Returns the pixbuf loaded by handle. If insufficient data has been read to create the pixbuf, or an error occurred in loading, then nil will be returned. Note that the pixbuf may not be complete until RSVG::Handle#close has been called.
  • id: The id of an element inside the SVG, or nil to render the whole SVG
  • Returns: the pixbuf loaded by handle, or nil.
pixbuf_from_file(file_name)

Obsolete since 2.12

Loads a new Gdk::Pixbuf from file_name and returns it. If an error occurred, raises an exception. self is closed by this call.

  • file_name: A file name
  • Returns: A newly allocated Gdk::Pixbuf, or raises an exception.
pixbuf_from_file_at_max_size(file_name, max_width, max_height)

Obsolete since 2.12

Loads a new Gdk::Pixbuf from file_name and returns it. This pixbuf is uniformly scaled so that the it fits into a rectangle of size max_width * max_height. If an error occurred, raises an exception. self is closed by this call.

  • file_name: A file name
  • max_width: The requested max width
  • max_height: The requested max height
  • Returns: A newly allocated Gdk::Pixbuf, or raises an exception.
pixbuf_from_file_at_size(file_name, width, height)

Obsolete since 2.12

Loads a new Gdk::Pixbuf from file_name and returns it. This pixbuf is scaled from the size indicated to the new size indicated by width and height. If either of these are -1, then the default size of the image being loaded is used. If an error occurred, raises an exception. self is closed by this call.

  • file_name: A file name
  • width: The new width, or -1
  • height: The new height, or -1
  • Returns: A newly allocated Gdk::Pixbuf, or raises an exception.
pixbuf_from_file_at_zoom(file_name, x_zoom, y_zoom)

Obsolete since 2.12

Loads a new Gdk::Pixbuf from file_name and returns it. This pixbuf is scaled from the size indicated by the file by a factor of x_zoom and y_zoom. If an error occurred, raises an exception. self is closed by this call.

  • file_name: A file name
  • x_zoom: The horizontal zoom factor
  • y_zoom: The vertical zoom factor
  • Returns: A newly allocated Gdk::Pixbuf, or raises an exception.
pixbuf_from_file_at_zoom_with_max(file_name, x_zoom, y_zoom, max_width, max_height)

Obsolete since 2.12

Loads a new Gdk::Pixbuf from file_name and returns it. This pixbuf is scaled from the size indicated by the file by a factor of x_zoom and y_zoom. If the resulting pixbuf would be larger than max_width/max_height it is uniformly scaled down to fit in that rectangle. If an error occurred, raises an exception. self is closed by this call.

  • file_name: A file name
  • x_zoom: The horizontal zoom factor
  • y_zoom: The vertical zoom factor
  • max_width: The requested max width
  • max_height: The requested max height
  • Returns: A newly allocated Gdk::Pixbuf, or raises an exception.
render_cairo(context, id=nil)
Draws a subset of a SVG to a Cairo surface
  • context: A Cairo::Context
  • id: An element's id within the SVG, or nil to render the whole SVG
set_base_uri(base_uri)
Same as base_uri=.
  • base_uri: the base URI
  • Returns: self
set_dpi(dpi)
Sets the DPI for the outgoing pixbuf. Common values are 75, 90, and 300 DPI. Passing a number <= 0 to dpi will reset the DPI to whatever the default value happens to be.
  • dpi: Dots Per Inch (aka Pixels Per Inch)
  • Returns: nil
set_dpi_x_y(dpi_x, dpi_y)
Sets the DPI for the outgoing pixbuf. Common values are 75, 90, and 300 DPI. Passing a number <= 0 to #dpi_x or #dpi_y will reset the DPI to whatever the default value happens to be.
  • dpi_x: Dots Per Inch (aka Pixels Per Inch) of x
  • dpi_y: Dots Per Inch (aka Pixels Per Inch) of y
  • Returns: nil
set_size_callback(&block)
Sets the sizing function for the self. This function is called right after the size of the image has been loaded. The size of the image is passed in to the block, which may then modify these values to set the real size of the generated pixbuf. If the image has no associated size, then the size arguments are set to -1.
  • block: A block for callback is called width and height. And return the array of new width and height, or nil if don't change the size.
  • Returns: nil
title
Returns the SVG's title in UTF-8 or nil.
  • Returns: The SVG's title
write(buf)
Loads the image. This will return true if the data was loaded successful, and raise RSVG::Error if an error occurred. In the latter case, the loader will be closed, and will not accept further writes.
  • buf: SVG data
  • Returns: true if the write was successful, or raises RSVG::Error if there was an error.
dpi=
  • Returns: self: FIXME
dpi_x
Gets the Horizontal resolution.
  • Returns: Horizontal resolution
dpi_x=(dpi_x)
Sets the Horizontal resolution.
  • dpi_x: Horizontal resolution
  • Returns: dpi_x
dpi_y
Gets the Vertical resolution.
  • Returns: Vertical resolution
dpi_y=(dpi_y)
Sets the Vertical resolution.
  • dpi_y: Vertical resolution
  • Returns: dpi_y
em
Gets the em.
  • Returns: em
ex
Gets the ex.
  • Returns: ex
height
Gets the Image height.
  • Returns: Image height
set_dpi_x(dpi_x)
Same as dpi_x=.
  • dpi_x: Horizontal resolution
  • Returns: self
set_dpi_y(dpi_y)
Same as dpi_y=.
  • dpi_y: Vertical resolution
  • Returns: self
width
Gets the Image width.
  • Returns: Image width

ChangeLog

  • 2006-03-17 kou: updated for 2.14.
  • 2005-10-03 kou: updated for 2.8-2.12.
  • 2005-06-11 kou: completed.

- kou

Last modified:2008/04/10 11:01:33
Keyword(s):
References:[News (2015-09-10 No.1)] [RSVG::Handle] [Ruby/RSVG] [Cairo::Context] [index-ruby-rsvg] [News (2014-12-27 No.1)]