GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Gtk2::Gdk::Pixbuf(3) User Contributed Perl Documentation Gtk2::Gdk::Pixbuf(3)

Gtk2::Gdk::Pixbuf - wrapper for GdkPixbuf

  Glib::Object
  +----Gtk2::Gdk::Pixbuf

  Glib::Object::_Unregistered::GIcon
  Glib::Object::_Unregistered::GLoadableIcon

  • $colorspace (Gtk2::Gdk::Colorspace)
  • $has_alpha (boolean)
  • $bits_per_sample (integer)
  • $width (integer)
  • $height (integer)

  • $data (scalar) packed binary pixel data, usually made with pack()
  • $colorspace (Gtk2::Gdk::Colorspace)
  • $has_alpha (boolean) true if the image data includes an alpha channel (opacity information).
  • $bits_per_sample (integer)
  • $width (integer) in pixels.
  • $height (integer) in pixels.
  • $rowstride (integer) distance in bytes between row starts; usually 3*width for rgb data, 4*width if $has_alpha is true.

Creates a new Gtk2::Gdk::Pixbuf out of in-memory image data. Currently only RGB images with 8 bits per sample are supported.

In C this function allows you to wrap a GdkPixbuf structure around existing pixel data. In Perl, we have to use "pack" to generate a scalar containing the pixel data, and pass that scalar to "new_from_data", which copies the scalar to keep it around. It also manages the memory automagically, so there's no need for a destruction notifier function. This all means that if you change your copy of the data scalar later, the pixbuf will not reflect that, but because of the way perl manages string data and scalars, it would be pretty fragile to do that in the first place. If you need to modify a pixbuf's data after it has been created, you can create new pixbufs for the changed regions and use "$pixbuf->composite", or try a different approach (possibly use a server-side pixmap and gdk drawing primitives, or something like libart).

$filename (localized file name)

May croak with a Glib::Error in $@ on failure.

  • $filename (localized file name)
  • $width (integer)
  • $height (integer)
  • $preserve_aspect_ratio (boolean)

May croak with a Glib::Error in $@ on failure.

Since: gtk+ 2.6

  • $filename (localized file name)
  • $width (integer)
  • $height (integer)

May croak with a Glib::Error in $@ on failure.

Since: gtk+ 2.4

  • $data (scalar) packed binary data, the format is special, see discussion
  • $copy_pixels (boolean) whether $data should be copied, defaults to true

Gtk+ ships with a tool called "gdk-pixbuf-csource", which turns any image understood by gdk-pixbuf into the C syntax of the declaration of a static data structure containing that image data, to be #included directly into your source code. "gdk_pixbuf_new_from_inline" creates a new GdkPixbuf from that data structure.

Currently, this is not very easy to do from Perl. The output of "gdk-pixbuf-csource" must be mangled rather ruthlessly to create valid Perl code using pack and translation from C string escapes to valid Perl string escapes (for encoding and interpretation isses). Because Perl scalars are garbage collected, it's rather rare to have the ability to use static data, so $copy_pixels defaults to true; if you can guarantee the image data will outlive the pixbuf you can pass false here and save some memory.

For more information, see the description of "gdk_pixbuf_new_from_inline" in the C API reference at http://gtk.org/api/ .

May croak with a Glib::Error in $@ on failure.

... (list) xpm data as a list of strings (see discussion)

X Pixel Map (XPM) files are designed to be easy to edit and easy to include directly into C programs. The file format is the C syntax of the declaration and initialization of a variable containing an array of strings. "new_from_xpm_data" allows you to create an image from such data included directly in your program source.

Since XPM files are C syntax, you must mangle that source a bit to work in a Perl program. For example, this is a valid xpm, but it is not valid Perl code:

 /* XPM */
 static char * test_xpm[] = {
 "4 4 3 1",
 "      c None",
 ".     c red",
 "+     c blue",
 ".. +",
 ". ++",
 " ++.",
 "++.."};

You'll need to change the array declaration format, and change the double-quoted strings to single-quoted to avoid Perl interpreting any chars in the strings as special.

 my @test_xpm = (
 '4 4 3 1',
 '      c None',
 '.     c red',
 '+     c blue',
 '.. +',
 '. ++',
 ' ++.',
 '++..');

 $pixbuf = Gtk2::Gdk::Pixbuf->new_from_xpm_data (@test_xpm);

[It's only two or three regexes... Perhaps we should distribute a script to convert XPM files to the proper format?]

  • $src_x (integer)
  • $src_y (integer)
  • $width (integer)
  • $height (integer)

  • $substitute_color (boolean)
  • $r (Glib::UChar)
  • $g (Glib::UChar)
  • $b (Glib::UChar)

Since: gtk+ 2.11

  • $dest (Gtk2::Gdk::Pixbuf)
  • $dest_x (integer)
  • $dest_y (integer)
  • $dest_width (integer)
  • $dest_height (integer)
  • $offset_x (double)
  • $offset_y (double)
  • $scale_x (double)
  • $scale_y (double)
  • $interp_type (Gtk2::Gdk::InterpType)
  • $overall_alpha (integer)

  • $dest (Gtk2::Gdk::Pixbuf)
  • $dest_x (integer)
  • $dest_y (integer)
  • $dest_width (integer)
  • $dest_height (integer)
  • $offset_x (double)
  • $offset_y (double)
  • $scale_x (double)
  • $scale_y (double)
  • $interp_type (Gtk2::Gdk::InterpType)
  • $overall_alpha (integer)
  • $check_x (integer)
  • $check_y (integer)
  • $check_size (integer)
  • $color1 (unsigned)
  • $color2 (unsigned)

  • $dest_width (integer)
  • $dest_height (integer)
  • $interp_type (Gtk2::Gdk::InterpType)
  • $overall_alpha (integer)
  • $check_size (integer)
  • $color1 (unsigned)
  • $color2 (unsigned)

  • $src_x (integer)
  • $src_y (integer)
  • $width (integer)
  • $height (integer)
  • $dest_pixbuf (Gtk2::Gdk::Pixbuf)
  • $dest_x (integer)
  • $dest_y (integer)

$filename (localized file name)

Parses enough of $filename to determine and return the format and size. If the format is unknown or the file can't be opened, returns an empty list.

Since: gtk+ 2.4

$pixel (unsigned) a packed RGBA value.

Clear $pixbuf to contain only the value given in $pixel.

$horizontal (boolean)

Since: gtk+ 2.6

Returns a list of hashes with information about the formats supported by Gtk2::Gdk::Pixbuf.

Since: gtk+ 2.2

  • $src (Gtk2::Gdk::Drawable)
  • $cmap (Gtk2::Gdk::Colormap or undef)
  • $src_x (integer)
  • $src_y (integer)
  • $dest_x (integer)
  • $dest_y (integer)
  • $width (integer)
  • $height (integer)

Fetch pixels from a Gtk2::Gdk::Drawable as a Gtk2::Gdk::Pixbuf. Returns a new Gtk2::Gdk::Pixbuf if you use the class form, or $pixbuf if you call it on an existing pixbuf.

  • $src (Gtk2::Gdk::Image)
  • $cmap (Gtk2::Gdk::Colormap or undef)
  • $src_x (integer)
  • $src_y (integer)
  • $dest_x (integer)
  • $dest_y (integer)
  • $width (integer)
  • $height (integer)

Fetch pixels from a Gtk2::Gdk::Image as a Gtk2::Gdk::Pixbuf. Returns a new Gtk2::Gdk::Pixbuf if you use the class form, or $pixbuf if you call it on an existing pixbuf.

$key (string)

  • $key (string)
  • $value (string)

Since: gtk+ 2.2

Return a copy of the bytes comprising the pixel data of $pixbuf.

As described in the Gdk Pixbuf reference manual (the "Note" section of "The GdkPixbuf Structure"), the last row does not extend to the rowstride, but ends with the last byte of the last pixel. The length of the "get_pixels" return reflects this.

$alpha_threshold (integer)

  • $colormap (Gtk2::Gdk::Colormap)
  • $alpha_threshold (integer)

  • $bitmap (Gtk2::Gdk::Bitmap)
  • $src_x (integer)
  • $src_y (integer)
  • $dest_x (integer)
  • $dest_y (integer)
  • $width (integer)
  • $height (integer)
  • $alpha_threshold (integer)

  • $drawable (Gtk2::Gdk::Drawable)
  • $gc (Gtk2::Gdk::GC)
  • $src_x (integer)
  • $src_y (integer)
  • $dest_x (integer)
  • $dest_y (integer)
  • $width (integer)
  • $height (integer)
  • $dither (Gtk2::Gdk::RgbDither)
  • $x_dither (integer)
  • $y_dither (integer)

  • $drawable (Gtk2::Gdk::Drawable)
  • $src_x (integer)
  • $src_y (integer)
  • $dest_x (integer)
  • $dest_y (integer)
  • $width (integer)
  • $height (integer)
  • $alpha_mode (Gtk2::Gdk::PixbufAlphaMode)
  • $alpha_threshold (integer)
  • $dither (Gtk2::Gdk::RgbDither)
  • $x_dither (integer)
  • $y_dither (integer)

$angle (Gtk2::Gdk::PixbufRotation)

Since: gtk+ 2.6

  • $dest (Gtk2::Gdk::Pixbuf)
  • $saturation (double)
  • $pixelate (boolean)

  • $filename (localized file name)
  • $type (string) name of file format (e.g. "jpeg", "png")
  • ... (list) list of key-value save options

Save $pixbuf to a file named $filename, in the format $type, which is currently "jpeg" or "png". The function will croak if there is an error, which may arise from file- or image format-related issues.

Any values in ... should be key/value string pairs that modify the saving parameters. For example:

 $pixbuf->save ($filename, 'jpeg', quality => '100');

Currently only a few parameters exist. JPEG images can be saved with a "quality" parameter; its value should be in the range [0,100]. Text chunks can be attached to PNG images by specifying parameters of the form "tEXt::key", where key is an ASCII string of length 1-79. The values are UTF-8 encoded strings. (This is a quote from the C API reference; note that the C API reference is the canonical source for this information.)

May croak with a Glib::Error in $@ on failure.

  • $type (string) name of file format (e.g. "jpeg", "png")
  • ... (list) list of key-value save options

Save $pixbuf to a scalar buffer, in the format $type, which is currently "jpeg" or "png". The function will croak if there is an error, which may arise from image format-related issues.

The returned string contains binary data, which may have embedded nuls. Don't try to "print" it.

See "Gtk2::Gdk::Pixbuf::save" for more details.

May croak with a Glib::Error in $@ on failure.

Since: gtk+ 2.4

  • $dest (Gtk2::Gdk::Pixbuf)
  • $dest_x (integer)
  • $dest_y (integer)
  • $dest_width (integer)
  • $dest_height (integer)
  • $offset_x (double)
  • $offset_y (double)
  • $scale_x (double)
  • $scale_y (double)
  • $interp_type (Gtk2::Gdk::InterpType)

  • $dest_width (integer)
  • $dest_height (integer)
  • $interp_type (Gtk2::Gdk::InterpType)

'bits-per-sample' (integer : default 8 : readable / writable / construct-only / private / static-nick / static-blurb / explicit-notify)
The number of bits per sample
'colorspace' (Gtk2::Gdk::Colorspace : default "rgb" : readable / writable / construct-only / private / static-nick / static-blurb / explicit-notify)
The colorspace in which the samples are interpreted
'has-alpha' (boolean : default false : readable / writable / construct-only / private / static-nick / static-blurb / explicit-notify)
Whether the pixbuf has an alpha channel
'height' (integer : default 1 : readable / writable / construct-only / private / static-nick / static-blurb / explicit-notify)
The number of rows of the pixbuf
'n-channels' (integer : default 3 : readable / writable / construct-only / private / static-nick / static-blurb / explicit-notify)
The number of samples per pixel
'pixel-bytes' (Glib::Bytes : default undef : readable / writable / construct-only / private / static-nick / static-blurb / explicit-notify)
Readonly pixel data
'pixels' (gpointer : default 0 : readable / writable / construct-only / private / static-nick / static-blurb / explicit-notify)
A pointer to the pixel data of the pixbuf
'rowstride' (integer : default 1 : readable / writable / construct-only / private / static-nick / static-blurb / explicit-notify)
The number of bytes between the start of a row and the start of the next row
'width' (integer : default 1 : readable / writable / construct-only / private / static-nick / static-blurb / explicit-notify)
The number of columns of the pixbuf

'rgb' / 'GDK_COLORSPACE_RGB'

  • 'nearest' / 'GDK_INTERP_NEAREST'
  • 'tiles' / 'GDK_INTERP_TILES'
  • 'bilinear' / 'GDK_INTERP_BILINEAR'
  • 'hyper' / 'GDK_INTERP_HYPER'

  • 'bilevel' / 'GDK_PIXBUF_ALPHA_BILEVEL'
  • 'full' / 'GDK_PIXBUF_ALPHA_FULL'

  • 'corrupt-image' / 'GDK_PIXBUF_ERROR_CORRUPT_IMAGE'
  • 'insufficient-memory' / 'GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY'
  • 'bad-option' / 'GDK_PIXBUF_ERROR_BAD_OPTION'
  • 'unknown-type' / 'GDK_PIXBUF_ERROR_UNKNOWN_TYPE'
  • 'unsupported-operation' / 'GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION'
  • 'failed' / 'GDK_PIXBUF_ERROR_FAILED'
  • 'incomplete-animation' / 'GDK_PIXBUF_ERROR_INCOMPLETE_ANIMATION'

  • 'none' / 'GDK_PIXBUF_ROTATE_NONE'
  • 'counterclockwise' / 'GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE'
  • 'upsidedown' / 'GDK_PIXBUF_ROTATE_UPSIDEDOWN'
  • 'clockwise' / 'GDK_PIXBUF_ROTATE_CLOCKWISE'

  • 'none' / 'GDK_RGB_DITHER_NONE'
  • 'normal' / 'GDK_RGB_DITHER_NORMAL'
  • 'max' / 'GDK_RGB_DITHER_MAX'

Gtk2, Glib::Object

Copyright (C) 2003-2011 by the gtk2-perl team.

This software is licensed under the LGPL. See Gtk2 for a full notice.

2022-06-07 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.