File Coverage

blib/lib/Image/TextMode/Format/XBin.pm
Criterion Covered Total %
statement 1 3 33.3
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 2 4 50.0


line stmt bran cond sub pod time code
1             package Image::TextMode::Format::XBin;
2              
3 3     3   4219 use Moose;
  0            
  0            
4              
5             # Flag byte constants
6             my $FLAG_PALETTE = 1;
7             my $FLAG_FONT = 2;
8             my $FLAG_COMPRESSED = 4;
9             my $FLAG_NON_BLINK = 8;
10             my $FLAG_FIVETWELVE_CHARS = 16;
11              
12             extends 'Image::TextMode::Format', 'Image::TextMode::Canvas';
13              
14             has 'header' => (
15             is => 'rw',
16             isa => 'HashRef',
17             default => sub {
18             { id => 'XBIN',
19             eofchar => chr( 26 ),
20             map { $_ => 0 } qw( width height fontsize flags )
21             };
22             }
23             );
24              
25             sub has_palette {
26             shift->header->{ flags } & $FLAG_PALETTE;
27             }
28              
29             sub has_font {
30             shift->header->{ flags } & $FLAG_FONT;
31             }
32              
33             sub is_compressed {
34             shift->header->{ flags } & $FLAG_COMPRESSED;
35             }
36              
37             sub is_non_blink {
38             shift->header->{ flags } & $FLAG_NON_BLINK;
39             }
40              
41             sub has_fivetwelve_chars {
42             shift->header->{ flags } & $FLAG_FIVETWELVE_CHARS;
43             }
44              
45             sub extensions { return 'xb', 'xbin' }
46              
47             no Moose;
48              
49             __PACKAGE__->meta->make_immutable;
50              
51             =head1 NAME
52              
53             Image::TextMode::Format::XBin - read and write XBin files
54              
55             =head1 DESCRIPTION
56              
57             XBin stands for "eXtended BIN" -- an extention to the normal raw-image BIN files.
58              
59             XBin features:
60              
61             =over 4
62              
63             =item * allows for binary images up to 65536 columns wide, and 65536 lines high
64              
65             =item * can have an alternate set of palette colors either in blink or in non-blink mode
66              
67             =item * can have different textmode fonts from 1 to 32 scanlines high, consisting of either 256 or 512 different characters
68              
69             =item * can be compressed
70              
71             =back
72              
73             XBin file stucture:
74              
75             +------------+
76             | Header |
77             +------------+
78             | Palette |
79             +------------+
80             | Font |
81             +------------+
82             | Image Data |
83             +------------+
84              
85             Note, the only required element is a header. See the XBin specs for for information.
86             http://www.acid.org/info/xbin/xbin.htm
87              
88             =head1 ACCESSORS
89              
90             =over 4
91              
92             =item * header - A header hashref containing an id, width, height, font size and any extra flags
93              
94             =back
95              
96             =head1 METHODS
97              
98             =head2 new( %args )
99              
100             Creates a XBin instance.
101              
102             =head2 has_palette( )
103              
104             Retrieves palette status from the flag byte in the header.
105              
106             =head2 has_font( )
107              
108             Retrieves font status from the flag byte in the header.
109              
110             =head2 is_compressed( )
111              
112             Retrieves compressed status from the flag byte in the header.
113              
114             =head2 is_non_blink( )
115              
116             Retrieves non-blink status from the flag byte in the header.
117              
118             =head2 has_fivetwelve_chars( )
119              
120             Retrieves 512 character font status from the flag byte in the header.
121              
122             =head2 extensions( )
123              
124             Returns 'xb', 'xbin'.
125              
126             =head1 AUTHOR
127              
128             Brian Cassidy E<lt>bricas@cpan.orgE<gt>
129              
130             =head1 COPYRIGHT AND LICENSE
131              
132             Copyright 2008-2013 by Brian Cassidy
133              
134             This library is free software; you can redistribute it and/or modify
135             it under the same terms as Perl itself.
136              
137             =cut
138              
139             1;