Commit | Line | Data |
---|---|---|
1d7e3124 TC |
1 | package Imager::File::PNG; |
2 | use strict; | |
3 | use Imager; | |
4 | use vars qw($VERSION @ISA); | |
5 | ||
6 | BEGIN { | |
d5ccf7cc | 7 | $VERSION = "0.79"; |
1d7e3124 TC |
8 | |
9 | eval { | |
10 | require XSLoader; | |
11 | XSLoader::load('Imager::File::PNG', $VERSION); | |
12 | 1; | |
13 | } or do { | |
14 | require DynaLoader; | |
15 | push @ISA, 'DynaLoader'; | |
16 | bootstrap Imager::File::PNG $VERSION; | |
17 | }; | |
18 | } | |
19 | ||
20 | Imager->register_reader | |
21 | ( | |
22 | type=>'png', | |
23 | single => | |
24 | sub { | |
25 | my ($im, $io, %hsh) = @_; | |
26 | $im->{IMG} = i_readpng_wiol($io); | |
27 | ||
28 | unless ($im->{IMG}) { | |
29 | $im->_set_error(Imager->_error_as_msg); | |
30 | return; | |
31 | } | |
32 | return $im; | |
33 | }, | |
34 | ); | |
35 | ||
36 | Imager->register_writer | |
37 | ( | |
38 | type=>'png', | |
39 | single => | |
40 | sub { | |
41 | my ($im, $io, %hsh) = @_; | |
42 | ||
43 | $im->_set_opts(\%hsh, "i_", $im); | |
44 | $im->_set_opts(\%hsh, "png_", $im); | |
45 | ||
46 | unless (i_writepng_wiol($im->{IMG}, $io)) { | |
47 | $im->_set_error(Imager->_error_as_msg); | |
48 | return; | |
49 | } | |
50 | return $im; | |
51 | }, | |
52 | ); | |
53 | ||
54 | __END__ | |
55 | ||
56 | =head1 NAME | |
57 | ||
58 | Imager::File::PNG - read and write PNG files | |
59 | ||
60 | =head1 SYNOPSIS | |
61 | ||
62 | use Imager; | |
63 | ||
64 | my $img = Imager->new; | |
65 | $img->read(file=>"foo.png") | |
66 | or die $img->errstr; | |
67 | ||
68 | $img->write(file => "foo.png") | |
69 | or die $img->errstr; | |
70 | ||
71 | =head1 DESCRIPTION | |
72 | ||
73 | Imager's PNG support is documented in L<Imager::Files>. | |
74 | ||
75 | =head1 AUTHOR | |
76 | ||
5b480b14 | 77 | Tony Cook <tonyc@cpan.org> |
1d7e3124 TC |
78 | |
79 | =head1 SEE ALSO | |
80 | ||
81 | Imager, Imager::Files. | |
82 | ||
83 | =cut |