SWF/Tag/Jpeg.pm untested

filter: Statementstmt 0.0% 0 / 43 Branchbran 0.0% 0 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 69 CC 9 SCAR 26.1
CC
9
Cov
0%
parseContent
20.0
buildContent
20.0
dumpContent
12.0
CRAP 13.6
1 package IO::SWF::Tag::Jpeg;
2  
3 use strict;
4 use warnings;
5  
6 use base 'IO::SWF::Tag::Base';
7  
8 use IO::SWF::Bit;
9  
10 __PACKAGE__->mk_accessors( qw(
11 _CharacterID
12 _AlphaDataOffset
13 _JPEGData
14 _ZlibBitmapAlphaData
15 ));
16  
17 sub parseContent {
18 my ($self, $tagCode, $content, $opts_href) = @_;
19  
20 my $reader = IO::SWF::Bit->new();
21 $reader->input($content);
22 my $alphaDataOffset;
23 if ($tagCode != 8) { # ! JPEGTablesa
24 $self->_CharacterID($reader->getUI16LE());
25 }
26 if ($tagCode == 35) { # DefgineBitsJPEG3
27 $alphaDataOffset = $reader->getUI32LE();
28 $self->_AlphaDataOffset($alphaDataOffset);
29 }
30 if ($tagCode != 35) { # ! DefgineBitsJPEG3
31 $self->_JPEGData($reader->getDataUntil());
32 } else {
33 $self->_JPEGData($reader->getData($alphaDataOffset));
34 $self->_ZlibBitmapAlphaData($reader->getDataUntil());
35 }
36 }
37  
38 sub dumpContent {
39 my ($self, $tagCode, $opts_href) = @_;
40  
41 if ($tagCode != 8) { # ! JPEGTables
42 print "\tCharacterID:{".$self->_CharacterID."}\n";
43 }
44 if ($tagCode == 35) { # DefineBitsJPEG3
45 print "\tAlphaDataOffset:{".$self->_AlphaDataOffset."}\n";
46 }
47 }
48  
49 sub buildContent {
50 my ($self, $tagCode, $opts_href) = @_;
51 my $writer = IO::SWF::Bit->new();
52 if ($tagCode != 8) { # ! JPEGTablesa
53 $writer->putUI16LE($self->_CharacterID);
54 }
55 if ($tagCode == 35) { # DefgineBitsJPEG3
56 $self->_AlphaDataOffset(length($self->_JPEGData));
57 $writer->putUI32LE($self->_AlphaDataOffset);
58 }
59 if ($tagCode != 35) { # ! DefgineBitsJPEG3
60 $writer->putData($self->_JPEGData);
61 } else {
62 $writer->putData($self->_JPEGData);
63 $writer->putData($self->_ZlibBitmapAlphaData);
64 }
65 return $writer->output();
66 }
67  
68 1;