NAME
Image::Base::PNGwriter -- draw PNG format images
SYNOPSIS
use Image::Base::PNGwriter;
my $image = Image::Base::PNGwriter->new (-width => 100,
-height => 100);
$image->line (0,0, 99,99, '#FF00FF');
$image->rectangle (10,10, 20,15, 'white');
$image->ellipse (30,30, 90,90, '#AAAA3333DDDD');
$image->save ('/some/filename.png');
CLASS HIERARCHY
Image::Base::PNGwriter
is a subclass of Image::Base
,
Image::Base
Image::Base::PNGwriter
DESCRIPTION
Image::Base::PNGwriter
extends Image::Base
to create or update PNG format image files using the Image::PNGwriter
module and PNGwriter library.
The native PNGwriter has more features, but this module is an easy way to point Image::Base
style code at a PNGwriter to get PNG from some Image::Base
code.
X,Y coordinates are the usual Image::Base
style 0,0 at the top-left corner. The underlying PNGwriter library is 1,1 at the bottom-left but Image::Base::PNGwriter
converts.
Colour Names
Colours can be
"#RGB" 1 to 4 digit hex
"#RRGGBB"
"#RRRGGGBBB"
"#RRRRGGGGBBBB"
"black"
"white"
There's no colour name database in PNGwriter and no names here except "black" and "white".
FUNCTIONS
See "FUNCTIONS" in Image::Base for behaviour common to all Image-Base classes.
$image = Image::Base::PNGwriter->new (key=>value,...)
-
Create and return an image object. A new image can be started with
-width
and-height
,$image = Image::Base::PNGwriter->new (-width => 200, -height => 100);
Or an existing file can be read,
$image = Image::Base::PNGwriter->new (-file => '/some/filename.png');
Or an
Image::PNGwriter
object can be given,my $p = Image::PNGwriter->new(200,100, 0, '/tmp/foo.png'); $image = Image::Base::PNGwriter->new (-pngwriter => $p);
$image->ellipse ($x1,$y1, $x2,$y2, $colour)
$image->ellipse ($x1,$y1, $x2,$y2, $colour, $fill)
-
Draw an ellipse within the rectangle top-left corner
$x1
,$y1
and bottom-right$x2
,$y2
. Optional$fill
true means a filled ellipse.In the current implementation circles with an odd diameter (meaning
$x2-$x1+1
is an odd number and equal to$y2-$y1+1
) are drawn with PNGwriter and the rest go toImage::Base
. This is a bit inconsistent but uses the features of PNGwriter as far as possible and its drawing should be faster. $image->diamond ($x1,$y1, $x2,$y2, $colour)
$image->diamond ($x1,$y1, $x2,$y2, $colour, $fill)
-
Draw a diamond shape within the rectangle top-left
$x1
,$y1
and bottom-right$x2
,$y2
. Optional$fill
true means a filled diamond.In PNGwriter 0.5.3 a filled diamond might miss the top-most pixel for some sizes. Currently there's no attempt to do anything about that here. At small sizes the shape sometimes isn't very good either.
ATTRIBUTES
The following attributes can be get()
and set()
.
-file
(string filename)-
The file to load in a
new()
, and the default filename for subsequentsave()
orload()
. -width
(integer)-height
(integer)-
Setting these changes the size of the image, but also clears it to all black. The image must be at least 1x1 pixels.
-zlib_compression
(integer 0-9 or -1)-
The amount of data compression to apply when saving. The value is Zlib style 0 for no compression up to 9 for maximum. -1 means Zlib's default level (which is usually 6).
-pngwriter
(Image::PNGwriter
object)-
The underlying
Image::PNGwriter
object in use.Filename and compression level can't be read out of a pngwriter object, which means that if you set
-pngwriter
then aget()
of the-file
or-zlib_compression
will returnundef
and there's no default filename forload()
. But asave()
uses the filename and compression in the object. Perhaps this will improve in the future.
SEE ALSO
Image::Base, Image::PNGwriter, Image::Base::GD
HOME PAGE
http://user42.tuxfamily.org/image-base-pngwriter/index.html
LICENSE
Image-Base-PNGwriter is Copyright 2010, 2011, 2012 Kevin Ryde
Image-Base-PNGwriter 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-PNGwriter 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-PNGwriter. If not, see <http://www.gnu.org/licenses/>.