NAME

Image::Base::Tk::Photo -- draw into Tk::Photo

SYNOPSIS

use Image::Base::Tk::Photo;
my $image = Image::Base::Tk::Photo->new (-width => 100,
                                      -height => 100);
$image->rectangle (0,0, 99,99, 'white');
$image->xy (20,20, 'black');
$image->line (50,50, 70,70, '#FF00FF');
$image->line (50,50, 70,70, '#0000AAAA9999');
$image->save ('/some/filename.png');

CLASS HIERARCHY

Image::Base::Tk::Photo is a subclass of Image::Base,

Image::Base
  Image::Base::Tk::Photo

DESCRIPTION

Image::Base::Tk::Photo extends Image::Base to create or update image files using the Tk::Photo module.

See Tk::Photo for the supported file formats. As of Perl-Tk 804 they include PNG, JPEG, XPM, XBM, GIF, BMP, and PPM/PGM.

Colours

Colour names are anything recognised by Tk_GetColor(3tk), which means X11 style

X server F<rgb.txt> names
#RGB            hex
#RRGGBB         hex
#RRRGGGBBB      hex
#RRRRGGGGBBBB   hex

Like Xlib, the shorter hex forms are padded with zeros, so "#FFF" means only "#F000F000F000", which is a light grey rather than white.

FUNCTIONS

$image = Image::Base::Tk::Photo->new (key=>value,...)

Create and return a new photo image object. A new image can be started with -width and -height,

$image = Image::Base::Tk::Photo->new (-for_widget => $widget,
                                      -width => 200, -height => 100);

Or an existing file can be read,

$image = Image::Base::Tk::Photo->new (-file => '/some/filename.xpm');

Or an Tk::Photo object can be given,

$image = Image::Base::Tk::Photo->new (-tkphoto => $tkphoto);
$image->save
$image->save ($filename)

Save to -file, or with a $filename argument set -file then save to that.

The file format is taken from the -file_format (see below) if that was set by a load() or explicit set().

ATTRIBUTES

-width (integer)
-height (integer)

Setting these changes the size of the image.

-tkphoto

The underlying Tk::Photo object.

-file_format (string or undef)

The file format as a string like "png" or "jpeg", or undef if unknown or never set.

After load the -file_format is the format read. Setting -file_format can change the format for a subsequent save.

There's no attempt to check or validate the -file_format value, since it's possible to add new formats to Tk::Photo at run time. Expect save() to croak if the format is unknown.

SEE ALSO

Image::Base, Tk::Photo