<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package Imager::File::ICO;
use strict;
use Imager;
use vars qw($VERSION @ISA);

BEGIN {
  $VERSION = "0.01";
  
  eval {
    require XSLoader;
    XSLoader::load('Imager::File::ICO', $VERSION);
    1;
  } or do {
    require DynaLoader;
    push @ISA, 'DynaLoader';
    bootstrap Imager::File::ICO $VERSION;
  };
}

Imager-&gt;register_reader
  (
   type=&gt;'ico',
   single =&gt; 
   sub { 
     my ($im, $io, %hsh) = @_;
     my $masked = 
       exists $hsh{ico_masked} ? $hsh{ico_masked} : 1;
     $im-&gt;{IMG} = i_readico_single($io, $hsh{page} || 0, $masked);

     unless ($im-&gt;{IMG}) {
       $im-&gt;_set_error(Imager-&gt;_error_as_msg);
       return;
     }
     return $im;
   },
   multiple =&gt;
   sub {
     my ($io, %hsh) = @_;
     
     my $masked = 
       exists $hsh{ico_masked} ? $hsh{ico_masked} : 1;
     my @imgs = i_readico_multi($io, $masked);
     unless (@imgs) {
       Imager-&gt;_set_error(Imager-&gt;_error_as_msg);
       return;
     }
     return map { 
       bless { IMG =&gt; $_, DEBUG =&gt; $Imager::DEBUG, ERRSTR =&gt; undef }, 'Imager'
     } @imgs;
   },
  );

# the readers can read CUR files too
Imager-&gt;register_reader
  (
   type=&gt;'cur',
   single =&gt; 
   sub { 
     my ($im, $io, %hsh) = @_;
     my $masked = 
       exists $hsh{ico_masked} ? $hsh{ico_masked} : 1;
     $im-&gt;{IMG} = i_readico_single($io, $hsh{page} || 0, $masked);

     unless ($im-&gt;{IMG}) {
       $im-&gt;_set_error(Imager-&gt;_error_as_msg);
       return;
     }
     return $im;
   },
   multiple =&gt;
   sub {
     my ($io, %hsh) = @_;
     
     my $masked = 
       exists $hsh{ico_masked} ? $hsh{ico_masked} : 1;
     my @imgs = i_readico_multi($io, $masked);
     unless (@imgs) {
       Imager-&gt;_set_error(Imager-&gt;_error_as_msg);
       return;
     }
     return map { 
       bless { IMG =&gt; $_, DEBUG =&gt; $Imager::DEBUG, ERRSTR =&gt; undef }, 'Imager'
     } @imgs;
   },
  );

Imager-&gt;register_writer
  (
   type=&gt;'ico',
   single =&gt; 
   sub { 
     my ($im, $io, %hsh) = @_;

     unless (i_writeico_wiol($io, $im-&gt;{IMG})) {
       $im-&gt;_set_error(Imager-&gt;_error_as_msg);
       return;
     }
     return $im;
   },
   multiple =&gt;
   sub {
     my ($class, $io, $opts, @images) = @_;

     if (!i_writeico_multi_wiol($io, map $_-&gt;{IMG}, @images)) {
       Imager-&gt;_set_error(Imager-&gt;_error_as_msg);
       return;
     }

     return 1;
   },
  );

Imager-&gt;register_writer
  (
   type=&gt;'cur',
   single =&gt; 
   sub { 
     my ($im, $io, %hsh) = @_;

     unless (i_writecur_wiol($io, $im-&gt;{IMG})) {
       $im-&gt;_set_error(Imager-&gt;_error_as_msg);
       return;
     }
     return $im;
   },
   multiple =&gt;
   sub {
     my ($class, $io, $opts, @images) = @_;

     if (!i_writecur_multi_wiol($io, map $_-&gt;{IMG}, @images)) {
       Imager-&gt;_set_error(Imager-&gt;_error_as_msg);
       return;
     }

     return 1;
   },
  );

1;

__END__

=head1 NAME

Imager::File::ICO - read MS Icon files

=head1 SYNOPSIS

  use Imager;

  my $img = Imager-&gt;new;
  $img-&gt;read(file=&gt;"foo.ico")
    or die $img-&gt;errstr;

  my @imgs = Imager-&gt;read_multi(file =&gt; "foo.ico")
    or die Imager-&gt;errstr;

  $img-&gt;write(file =&gt; "foo.ico")
    or die $img-&gt;errstr;

  Imager-&gt;write_multi({ file =&gt; "foo.ico" }, @imgs)
    or die Imager-&gt;errstr;

=head1 DESCRIPTION

Imager's MS Icon support is documented in L&lt;Imager::Files&gt;.

=head1 AUTHOR

Tony Cook &lt;tony@imager.perl.org&gt;

=head1 SEE ALSO

Imager, Imager::Files.

=cut
</pre></body></html>