line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Image::TextMode::Reader::ADF; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
1482
|
use Moo; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
16
|
|
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
|
|
|
|
|
3
|
my $version; |
13
|
3
|
|
|
|
|
19
|
read( $fh, $version, 1 ); |
14
|
3
|
|
|
|
|
19
|
$version = unpack( 'C', $version ); |
15
|
3
|
|
|
|
|
29
|
$image->header( { version => $version } ); |
16
|
|
|
|
|
|
|
|
17
|
3
|
|
|
|
|
1118
|
my $paldata; |
18
|
3
|
|
|
|
|
9
|
read( $fh, $paldata, 192 ); |
19
|
3
|
|
|
|
|
9
|
_parse_palette( $image, $paldata ); |
20
|
|
|
|
|
|
|
|
21
|
3
|
|
|
|
|
4020
|
my $fontdata; |
22
|
3
|
|
|
|
|
20
|
read( $fh, $fontdata, 4096 ); |
23
|
3
|
|
|
|
|
10
|
_parse_font( $image, $fontdata ); |
24
|
|
|
|
|
|
|
|
25
|
3
|
|
|
|
|
5596
|
my ( $x, $y ) = ( 0, 0 ); |
26
|
3
|
|
|
|
|
8
|
my $chardata; |
27
|
3
|
|
|
|
|
18
|
while ( read( $fh, $chardata, 2 ) ) { |
28
|
240
|
|
|
|
|
571
|
my @data = unpack( 'aC', $chardata ); |
29
|
240
|
50
|
33
|
|
|
940
|
last if tell( $fh ) > $options->{ filesize } || $data[ 0 ] eq chr( 26 ); |
30
|
240
|
|
|
|
|
720
|
$image->putpixel( { char => $data[ 0 ], attr => $data[ 1 ] }, $x, |
31
|
|
|
|
|
|
|
$y ); |
32
|
|
|
|
|
|
|
|
33
|
240
|
|
|
|
|
8062
|
$x++; |
34
|
240
|
100
|
|
|
|
855
|
if ( $x == 80 ) { |
35
|
3
|
|
|
|
|
4
|
$x = 0; |
36
|
3
|
|
|
|
|
31
|
$y++; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
3
|
|
|
|
|
46
|
return $image; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub _parse_palette { |
44
|
3
|
|
|
3
|
|
5
|
my ( $image, $data ) = @_; |
45
|
|
|
|
|
|
|
|
46
|
3
|
|
|
|
|
80
|
my @pal = unpack( 'C*', $data ); |
47
|
3
|
|
|
|
|
42
|
my @colors; |
48
|
3
|
|
|
|
|
9
|
for ( @color_idx ) { |
49
|
48
|
|
|
|
|
42
|
my $offset = $_ * 3; |
50
|
48
|
|
|
|
|
55
|
push @colors, [ map { $_ << 2 | $_ >> 4 } @pal[ $offset .. $offset + 2 ] ]; |
|
144
|
|
|
|
|
207
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
$image->palette( |
54
|
3
|
|
|
|
|
44
|
Image::TextMode::Palette->new( { colors => \@colors } ) ); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _parse_font { |
58
|
3
|
|
|
3
|
|
7
|
my ( $image, $data ) = @_; |
59
|
3
|
|
|
|
|
7
|
my $height = 16; |
60
|
3
|
|
|
|
|
5
|
my @chars; |
61
|
|
|
|
|
|
|
|
62
|
3
|
|
|
|
|
15
|
for ( 0 .. ( length( $data ) / $height ) - 1 ) { |
63
|
768
|
|
|
|
|
2635
|
push @chars, |
64
|
|
|
|
|
|
|
[ unpack( 'C*', substr( $data, $_ * $height, $height ) ) ]; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
$image->font( |
68
|
3
|
|
|
|
|
61
|
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-2014 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; |