The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Image::Base::Gtk2::Gdk::Drawable -- draw into a Gdk window or pixmap

SYNOPSIS

 use Image::Base::Gtk2::Gdk::Drawable;
 my $image = Image::Base::Gtk2::Gdk::Drawable->new
                 (-drawable => $win_or_pixmap);
 $image->line (0,0, 99,99, '#FF00FF');
 $image->rectangle (10,10, 20,15, 'white');

CLASS HIERARCHY

Image::Base::Gtk2::Gdk::Drawable is a subclass of Image::Base,

    Image::Base
      Image::Base::Gtk2::Gdk::Drawable

DESCRIPTION

Image::Base::Gtk2::Gdk::Drawable extends Image::Base to draw into a Gdk drawable, meaning either a window or a pixmap.

Colour names are anything recognised by Gtk2::Gdk::Color->parse, which means various names like "pink" plus hex #RRGGBB or #RRRRGGGGBBB. As of Gtk 2.20 the colour names are the Pango compiled-in copy of the X11 rgb.txt. Special names "set" and "clear" mean pixel values 1 and 0 for use with bitmaps.

The Image::Base::Gtk2::Gdk::Pixmap subclass has some specifics for creating pixmaps, but this base Drawable is enough to draw into an existing one.

Native Gdk drawing does much more than Image::Base but if you have some generic pixel twiddling code for Image::Base then this Drawable class lets you point it at a Gdk window etc. Drawing into a window is a good way to show slow drawing progressively, rather than drawing into a pixmap or image file and only displaying when complete. See Image::Base::Multiplex for a way to do both simultaneously.

FUNCTIONS

See "FUNCTIONS" in Image::Base for the behaviour common to all Image-Base classes.

$image = Image::Base::Gtk2::Gdk::Drawable->new (key=>value,...)

Create and return a new image object. A -drawable parameter must be given,

    $image = Image::Base::Gtk2::Gdk::Drawable->new
                 (-drawable => $win_or_pixmap);

Further parameters are applied per set (see "ATTRIBUTES" below).

$image->xy ($x, $y, $colour)

Get or set the pixel at $x,$y.

In the current code colours are returned in #RRGGBB form and require a colormap. Perhaps in the future it will be #RRRRGGGGBBBB form since under X there's 16-bit resolution. Generally a colormap is required, though bitmaps without a colormap give 0 and 1. The intention is probably to have pixmaps without colormaps give back raw pixel values. Maybe bitmaps could give back "set" and "clear" as an option.

Fetching a pixel is an X server round-trip and reading out a big region will be slow. The server can give a region or the entire drawable in one go, so some function for that would be better if much fetching is needed.

ATTRIBUTES

-drawable (Gtk2::Gdk::Drawable object)

The target drawable.

-width (integer)
-height (integer)

The size of the drawable per $drawable->get_size.

-colormap (Gtk2::Gdk::Colormap, or undef)

The colormap in the underlying -drawable per $drawable->get_colormap. Windows always have a colormap, but pixmaps may or may not.

-depth (integer, read-only)

The number of bits per pixel in the drawable, from $drawable->get_depth.

-screen (Gtk2::Gdk::Screen, read-only)

The screen of the underlying drawable ($drawable->get_screen).

SEE ALSO

Image::Base, Image::Base::Gtk2::Gdk::Pixmap, Image::Base::Gtk2::Gdk::Window, Gtk2::Gdk::Drawable, Image::Base::Multiplex

HOME PAGE

http://user42.tuxfamily.org/image-base-gtk2/index.html

LICENSE

Copyright 2010, 2011, 2012 Kevin Ryde

Image-Base-Gtk2 is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

Image-Base-Gtk2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Image-Base-Gtk2. If not, see http://www.gnu.org/licenses/.