line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Image::TextMode::Reader::ADF; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
1083
|
use Moo; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
15
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
extends 'Image::TextMode::Reader'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
my @color_idx = ( 0, 1, 2, 3, 4, 5, 20, 7, 56, 57, 58, 59, 60, 61, 62, 63 ); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub _read { |
10
|
3
|
|
|
3
|
|
7
|
my ( $self, $image, $fh, $options ) = @_; |
11
|
|
|
|
|
|
|
|
12
|
3
|
|
|
|
|
5
|
my $version; |
13
|
3
|
|
|
|
|
17
|
read( $fh, $version, 1 ); |
14
|
3
|
|
|
|
|
15
|
$version = unpack( 'C', $version ); |
15
|
3
|
|
|
|
|
32
|
$image->header( { version => $version } ); |
16
|
|
|
|
|
|
|
|
17
|
3
|
|
|
|
|
1071
|
my $paldata; |
18
|
3
|
|
|
|
|
57
|
read( $fh, $paldata, 192 ); |
19
|
3
|
|
|
|
|
9
|
_parse_palette( $image, $paldata ); |
20
|
|
|
|
|
|
|
|
21
|
3
|
|
|
|
|
3727
|
my $fontdata; |
22
|
3
|
|
|
|
|
16
|
read( $fh, $fontdata, 4096 ); |
23
|
3
|
|
|
|
|
9
|
_parse_font( $image, $fontdata ); |
24
|
|
|
|
|
|
|
|
25
|
3
|
|
|
|
|
5210
|
my ( $x, $y ) = ( 0, 0 ); |
26
|
3
|
|
|
|
|
7
|
my $chardata; |
27
|
3
|
|
|
|
|
19
|
while ( read( $fh, $chardata, 2 ) ) { |
28
|
240
|
|
|
|
|
574
|
my @data = unpack( 'aC', $chardata ); |
29
|
240
|
50
|
33
|
|
|
938
|
last if tell( $fh ) > $options->{ filesize } || $data[ 0 ] eq chr( 26 ); |
30
|
240
|
|
|
|
|
710
|
$image->putpixel( { char => $data[ 0 ], attr => $data[ 1 ] }, $x, |
31
|
|
|
|
|
|
|
$y ); |
32
|
|
|
|
|
|
|
|
33
|
240
|
|
|
|
|
7591
|
$x++; |
34
|
240
|
100
|
|
|
|
776
|
if ( $x == 80 ) { |
35
|
3
|
|
|
|
|
7
|
$x = 0; |
36
|
3
|
|
|
|
|
43
|
$y++; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
3
|
|
|
|
|
59
|
return $image; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub _parse_palette { |
44
|
3
|
|
|
3
|
|
6
|
my ( $image, $data ) = @_; |
45
|
|
|
|
|
|
|
|
46
|
3
|
|
|
|
|
79
|
my @pal = unpack( 'C*', $data ); |
47
|
3
|
|
|
|
|
17
|
my @colors; |
48
|
3
|
|
|
|
|
8
|
for ( @color_idx ) { |
49
|
48
|
|
|
|
|
40
|
my $offset = $_ * 3; |
50
|
48
|
|
|
|
|
69
|
push @colors, [ map { $_ << 2 | $_ >> 4 } @pal[ $offset .. $offset + 2 ] ]; |
|
144
|
|
|
|
|
217
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
$image->palette( |
54
|
3
|
|
|
|
|
45
|
Image::TextMode::Palette->new( { colors => \@colors } ) ); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _parse_font { |
58
|
3
|
|
|
3
|
|
5
|
my ( $image, $data ) = @_; |
59
|
3
|
|
|
|
|
4
|
my $height = 16; |
60
|
3
|
|
|
|
|
3
|
my @chars; |
61
|
|
|
|
|
|
|
|
62
|
3
|
|
|
|
|
14
|
for ( 0 .. ( length( $data ) / $height ) - 1 ) { |
63
|
768
|
|
|
|
|
2089
|
push @chars, |
64
|
|
|
|
|
|
|
[ unpack( 'C*', substr( $data, $_ * $height, $height ) ) ]; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
$image->font( |
68
|
3
|
|
|
|
|
51
|
Image::TextMode::Font->new( |
69
|
|
|
|
|
|
|
{ width => 8, |
70
|
|
|
|
|
|
|
height => $height, |
71
|
|
|
|
|
|
|
chars => \@chars, |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
) |
74
|
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 NAME |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Image::TextMode::Reader::ADF - Reads ADF files |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 DESCRIPTION |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Provides reading capabilities for the ADF format. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 AUTHOR |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Brian Cassidy Ebricas@cpan.orgE |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Copyright 2008-2015 by Brian Cassidy |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
94
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; |