NAME
App::MathImage::Image::Base::Gtk::Gdk::Pixbuf -- draw image files using Gtk::Gdk::Pixbuf
SYNOPSIS
use App::MathImage::Image::Base::Gtk::Gdk::Pixbuf;
my $image = App::MathImage::Image::Base::Gtk::Gdk::Pixbuf->new
(-width => 100,
-height => 100);
$image->line (0,0, 99,99, '#FF00FF');
$image->rectangle (10,10, 20,15, 'white');
CLASS HIERARCHY
App::MathImage::Image::Base::Gtk::Gdk::Pixbuf is a subclass of Image::Base,
Image::Base
App::MathImage::Image::Base::Gtk::Gdk::Pixbuf
DESCRIPTION
Untested ...
App::MathImage::Image::Base::Gtk::Gdk::Pixbuf extends Image::Base to create and update image files using GdkPixbuf. PNG and JPEG can always be read and written, and in recent Gtk also TIFF, ICO and BMP. Many further formats can be read but not written, including XPM, GIF, XBM and PCX.
Pixbufs are held in client-side memory and don't require an X server or Gtk->init(), which means they can be used for general-purpose image and image file manipulations.
The current drawing code is not very fast, but if you've got some pixel twiddling in Image::Base style then this is a handy way to have it read or write several file formats.
Colour Names
Colour names are anything recognised by Gtk::Gdk::Color->parse(), which means various names like "pink" plus hex #RRGGBB or #RRRRGGGGBBB. As of Gtk 2.20 the names are from the Pango compiled-in copy of the X11 rgb.txt. Special colour "None" means a transparent pixel on a pixbuf with an "alpha" channel.
Only 8-bit RGB or RGBA pixbufs are supported by this module. This is all that Gtk 2.20 itself supports too.
FUNCTIONS
See "FUNCTIONS" in Image::Base for the behaviour common to all Image-Base classes.
$image = App::MathImage::Image::Base::Gtk::Gdk::Pixbuf->new (key=>value,...)-
Create and return a new GdkPixbuf image object. It can be pointed at an existing pixbuf,
$image = App::MathImage::Image::Base::Gtk::Gdk::Pixbuf->new (-pixbuf => $gdkimage);Or a file can be read,
$image = App::MathImage::Image::Base::Gtk::Gdk::Pixbuf->new (-file => '/my/file/name.jpeg');Or a new pixbuf created with width and height,
$image = App::MathImage::Image::Base::Gtk::Gdk::Pixbuf->new (-width => 10, -height => 10);When creating a pixbuf an alpha channel (transparency) can be requested with
-has_alpha,$image = App::MathImage::Image::Base::Gtk::Gdk::Pixbuf->new (-width => 10, -height => 10, -has_alpha => 1); $image->load ()$image->load ($filename)-
Read the
-file, or set-fileto$filenameand then read. This creates and sets a new underlying-pixbufbecause it's not possible to read into an existing pixbuf object, only read a new one.-file_formatis set from the loaded file's format. $image->save ()$image->save ($filename)-
Write the
-file, or set-fileto$filenameand then write.-file_formatis the saved format.If
-file_formatis not set there's a secret experimental feature which looks up the-filefilename extension in the available pixbuf formats. Is that a good idea, or would just saypngfallback be better?Some formats can be loaded but not saved.
pngandjpegcan be saved always, thenicoin Gtk 2.4 up,bmpin Gtk 2.8 up, andtiffin Gtk 2.10 up.
ATTRIBUTES
-pixbuf(Gtk::Gdk::Pixbufobject)-
The target
Gtk::Gdk::Pixbufobject. -file_format(string, default undef)-
The file format from the last
loadand to use insave. This is one of the GdkPixbuf format names such as "png" or "jpeg", in upper or lower case. -width(integer, read-only)-height(integer, read-only)-
The size of a pixbuf cannot be changed once created.
-has_alpha(boolean, read-only)-
Whether the underlying pixbuf has a alpha channel, meaning a transparency mask (or partial transparency). This cannot be changed once created.
-quality_percent(0 to 100 orundef)-
The image quality when saving to JPEG format. JPEG compresses by reducing colours and resolution in ways that are not too noticeable to the human eye. 100 means full quality, no such reductions.
undefmeans the GdkPixbuf default, which is 75.This becomes the
qualityparameter to$pixbuf->save(). -zlib_compression(integer, no default)-
The Zlib compression level to use when saving.
This becomes the
compressparameter to$pixbuf->save()if applicable (only "png" format currently) and if possible (which means Gtk 2.8.0 up). -hotx(integer or undef, default undef)-hoty(integer or undef, default undef)-
The cursor hotspot in
xpmandicoimages.These are loaded from
xpmandicofiles in Gtk 2.2 up (get_option"x_hot" and "y_hot"), and are saved toicoin Gtk 2.4 and higher (icosaving is new in Gtk 2.4, and there's noxpmsaving as of Gtk 2.22).In the current code these are treated as belonging to the pixbuf, so a new pixbuf set or loaded replaces
-hotxor-hoty. But the settings are not held in the pixbuf as such since as of Gtk 2.22$pixbuf->set_optionwon't replace existing option values in the pixbuf.