| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Image::TextMode::Writer::IDF; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 1 |  |  | 1 |  | 382 | use Moo; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 7 |  | 
| 4 | 1 |  |  | 1 |  | 718 | use charnames ':full'; | 
|  | 1 |  |  |  |  | 24513 |  | 
|  | 1 |  |  |  |  | 6 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  | extends 'Image::TextMode::Writer'; | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | my $header_template = 'A4 v v v v'; | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | sub _write { | 
| 11 | 1 |  |  | 1 |  | 2 | my ( $self, $image, $fh, $options ) = @_; | 
| 12 |  |  |  |  |  |  |  | 
| 13 | 1 |  |  |  |  | 17 | my ( $max_x, $max_y ) = map { $_ - 1 } $image->dimensions; | 
|  | 2 |  |  |  |  | 35 |  | 
| 14 |  |  |  |  |  |  |  | 
| 15 | 1 |  |  |  |  | 19 | print $fh pack( $header_template, | 
| 16 |  |  |  |  |  |  | "\N{END OF TRANSMISSION}1.4", | 
| 17 |  |  |  |  |  |  | 0, 0, $max_x, $max_y ); | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | # Don't bother with RLE compression for now | 
| 20 | 1 |  |  |  |  | 3 | for my $y ( 0 .. $max_y ) { | 
| 21 | 1 |  |  |  |  | 3 | for my $x ( 0 .. $max_x ) { | 
| 22 | 80 |  |  |  |  | 151 | my $pixel = $image->getpixel( $x, $y ); | 
| 23 | 80 |  |  |  |  | 469 | print $fh pack( 'aC', $pixel->{ char }, $pixel->{ attr } ); | 
| 24 |  |  |  |  |  |  | } | 
| 25 |  |  |  |  |  |  | } | 
| 26 |  |  |  |  |  |  |  | 
| 27 | 1 |  |  |  |  | 3 | for my $char ( @{ $image->font->chars } ) { | 
|  | 1 |  |  |  |  | 34 |  | 
| 28 | 256 |  |  |  |  | 998 | print $fh pack( 'C*', @$char ); | 
| 29 |  |  |  |  |  |  | } | 
| 30 |  |  |  |  |  |  |  | 
| 31 | 1 |  |  |  |  | 3 | for my $color ( @{ $image->palette->colors } ) { | 
|  | 1 |  |  |  |  | 35 |  | 
| 32 | 16 |  |  |  |  | 503 | print $fh pack( 'C*', map { $_ >> 2 } @$color ); | 
|  | 48 |  |  |  |  | 76 |  | 
| 33 |  |  |  |  |  |  | } | 
| 34 |  |  |  |  |  |  | } | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | =head1 NAME | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  | Image::TextMode::Writer::IDF - Writes IDF files | 
| 39 |  |  |  |  |  |  |  | 
| 40 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | Provides writing capabilities for the IDF format. It currently does not | 
| 43 |  |  |  |  |  |  | support any RLE compression. | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | =head1 AUTHOR | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  | Brian Cassidy Ebricas@cpan.orgE | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | =head1 COPYRIGHT AND LICENSE | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | Copyright 2008-2015 by Brian Cassidy | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | This library is free software; you can redistribute it and/or modify | 
| 54 |  |  |  |  |  |  | it under the same terms as Perl itself. | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | =cut | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | 1; |