| 1 | package Data::Petitcom::Resource::GRP; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use parent qw{ Data::Petitcom::Resource }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use bytes (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use Data::Petitcom::PTC; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use Data::Petitcom::BMP qw{ Load BMP2DATA DATA2BMP }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 4 | ▶ | use constant RESOURCE => 'GRP'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 4 | ▶ | use constant BMP_WIDTH => 256; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 4 | ▶ | use constant BMP_HEIGHT => 192; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 4 | ▶ | use constant PTC_NAME => 'DPTC_GRP'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 23 | ▶ | sub data { | ||||||||||||||||||||||||||
|
Subroutine
data: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 18 | 23 | my $self = shift; | |||||||||||||||||||||||||||
| 19 | 23 | ▶ | if (my $raw_bmp = shift) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | 10 | my $bmp = Load($raw_bmp); | |||||||||||||||||||||||||||
| 21 | Carp::croak "unsupported width x height: $bmp->{width} x $bmp->{height}" | ||||||||||||||||||||||||||||
| 22 | if ( $bmp->{width} != $self->BMP_WIDTH() | ||||||||||||||||||||||||||||
| 23 | 10 | ▶ | || $bmp->{height} != $self->BMP_HEIGHT() ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$bmp->{"width"} != $self->BMP_WIDTH or $bmp->{"height"} != $self->BMP_HEIGHT
MC/DC50%1/2
$bmp->{"width"} != $self->BMP_WIDTH or $bmp->{"height"} != $self->BMP_HEIGHT
$bmp->{"width"} != $self->BMP_WIDTH
$bmp->{"height"} != $self->BMP_HEIGHT
Truth table66%2/3
A or B
A= $bmp->{"width"} != $self->BMP_WIDTHB= $bmp->{"height"} != $self->BMP_HEIGHT
| |||||||||||||||||||||||||||||
| 24 | 8 | $self->{data} = $raw_bmp; | |||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | 21 | return $self->{data}; | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 4 | ▶ | sub save { | ||||||||||||||||||||||||||
|
Subroutine
save: called CC=6 SCAR=18.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 30 | 4 | my $self = shift; | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 4 | my %opts = @_; | |||||||||||||||||||||||||||
| 33 | 4 | ▶ | my $name = delete $opts{name} || $self->PTC_NAME(); | ||||||||||||||||||||||||||
|
Condition33%1/3
delete $opts{'name'} || $self->PTC_NAME
MC/DC0%0/2
delete $opts{'name'} || $self->PTC_NAME
delete $opts{'name'}
$self->PTC_NAME
Truth table33%1/3
A || B
A= delete $opts{'name'}B= $self->PTC_NAME
| |||||||||||||||||||||||||||||
| 34 | my $sp_width = ( $self->RESOURCE() eq 'GRP' ) | ||||||||||||||||||||||||||||
| 35 | ? 64 | ||||||||||||||||||||||||||||
| 36 | 4 | ▶ | : delete $opts{sp_width} || 16; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
delete $opts{"sp_width"} or 16
MC/DC0%0/1
delete $opts{"sp_width"} or 16
delete $opts{"sp_width"}
Truth table50%1/2
A
A= delete $opts{"sp_width"}
| |||||||||||||||||||||||||||||
| 37 | my $sp_height = ( $self->RESOURCE() eq 'GRP' ) | ||||||||||||||||||||||||||||
| 38 | ? 64 | ||||||||||||||||||||||||||||
| 39 | 4 | ▶ | : delete $opts{sp_height} || 16; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
delete $opts{"sp_height"} or 16
MC/DC0%0/1
delete $opts{"sp_height"} or 16
delete $opts{"sp_height"}
Truth table50%1/2
A
A= delete $opts{"sp_height"}
| |||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 4 | my $ptc = Data::Petitcom::PTC->new( | |||||||||||||||||||||||||||
| 43 | resource => $self->RESOURCE(), | ||||||||||||||||||||||||||||
| 44 | name => $name, | ||||||||||||||||||||||||||||
| 45 | version => 'PETC0100', | ||||||||||||||||||||||||||||
| 46 | data => BMP2DATA( | ||||||||||||||||||||||||||||
| 47 | $self->data, | ||||||||||||||||||||||||||||
| 48 | sp_width => $sp_width, | ||||||||||||||||||||||||||||
| 49 | sp_height => $sp_height, | ||||||||||||||||||||||||||||
| 50 | ), | ||||||||||||||||||||||||||||
| 51 | ); | ||||||||||||||||||||||||||||
| 52 | 4 | return $ptc; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 2 | ▶ | sub load { | ||||||||||||||||||||||||||
|
Subroutine
load: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 56 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 57 | 2 | my $ptc = shift; | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 2 | my %opts = @_; | |||||||||||||||||||||||||||
| 60 | my $sp_width = ( $self->RESOURCE() eq 'GRP' ) | ||||||||||||||||||||||||||||
| 61 | ? 64 | ||||||||||||||||||||||||||||
| 62 | 2 | ▶ | : delete $opts{sp_width} || 16; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
delete $opts{"sp_width"} or 16
MC/DC0%0/1
delete $opts{"sp_width"} or 16
delete $opts{"sp_width"}
Truth table50%1/2
A
A= delete $opts{"sp_width"}
| |||||||||||||||||||||||||||||
| 63 | my $sp_height = ( $self->RESOURCE() eq 'GRP' ) | ||||||||||||||||||||||||||||
| 64 | ? 64 | ||||||||||||||||||||||||||||
| 65 | 2 | ▶ | : delete $opts{sp_height} || 16; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
delete $opts{"sp_height"} or 16
MC/DC0%0/1
delete $opts{"sp_height"} or 16
delete $opts{"sp_height"}
Truth table50%1/2
A
A= delete $opts{"sp_height"}
| |||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 2 | my $bmp = DATA2BMP( | |||||||||||||||||||||||||||
| 68 | bytes::substr( $ptc->data, 0x0C ), | ||||||||||||||||||||||||||||
| 69 | width => $self->BMP_WIDTH(), | ||||||||||||||||||||||||||||
| 70 | height => $self->BMP_HEIGHT(), | ||||||||||||||||||||||||||||
| 71 | sp_width => $sp_width, | ||||||||||||||||||||||||||||
| 72 | sp_height => $sp_height, | ||||||||||||||||||||||||||||
| 73 | ); | ||||||||||||||||||||||||||||
| 74 | 2 | $self->data($bmp); | |||||||||||||||||||||||||||
| 75 | 2 | return $self; | |||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 4 | 1; | |||||||||||||||||||||||||||