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