line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Petitcom::Resource::GRP; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
2064
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
1249
|
|
4
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
4
|
|
|
|
|
20
|
|
|
4
|
|
|
|
|
133
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
20
|
use parent qw{ Data::Petitcom::Resource }; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
32
|
|
7
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
2214
|
use bytes (); |
|
4
|
|
|
|
|
24
|
|
|
4
|
|
|
|
|
81
|
|
9
|
4
|
|
|
4
|
|
1077
|
use Data::Petitcom::PTC; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
130
|
|
10
|
4
|
|
|
4
|
|
2581
|
use Data::Petitcom::BMP qw{ Load BMP2DATA DATA2BMP }; |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
420
|
|
11
|
|
|
|
|
|
|
|
12
|
4
|
|
|
4
|
|
33
|
use constant RESOURCE => 'GRP'; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
242
|
|
13
|
4
|
|
|
4
|
|
22
|
use constant BMP_WIDTH => 256; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
205
|
|
14
|
4
|
|
|
4
|
|
21
|
use constant BMP_HEIGHT => 192; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
239
|
|
15
|
4
|
|
|
4
|
|
23
|
use constant PTC_NAME => 'DPTC_GRP'; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
1889
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub data { |
18
|
23
|
|
|
23
|
0
|
6119
|
my $self = shift; |
19
|
23
|
100
|
|
|
|
85
|
if (my $raw_bmp = shift) { |
20
|
10
|
|
|
|
|
56
|
my $bmp = Load($raw_bmp); |
21
|
10
|
100
|
66
|
|
|
299
|
Carp::croak "unsupported width x height: $bmp->{width} x $bmp->{height}" |
22
|
|
|
|
|
|
|
if ( $bmp->{width} != $self->BMP_WIDTH() |
23
|
|
|
|
|
|
|
|| $bmp->{height} != $self->BMP_HEIGHT() ); |
24
|
8
|
|
|
|
|
4627
|
$self->{data} = $raw_bmp; |
25
|
|
|
|
|
|
|
} |
26
|
21
|
|
|
|
|
200
|
return $self->{data}; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub save { |
30
|
4
|
|
|
4
|
0
|
21
|
my $self = shift; |
31
|
|
|
|
|
|
|
|
32
|
4
|
|
|
|
|
18
|
my %opts = @_; |
33
|
4
|
|
33
|
|
|
64
|
my $name = delete $opts{name} || $self->PTC_NAME(); |
34
|
4
|
100
|
50
|
|
|
53
|
my $sp_width = ( $self->RESOURCE() eq 'GRP' ) |
35
|
|
|
|
|
|
|
? 64 |
36
|
|
|
|
|
|
|
: delete $opts{sp_width} || 16; |
37
|
4
|
100
|
50
|
|
|
33
|
my $sp_height = ( $self->RESOURCE() eq 'GRP' ) |
38
|
|
|
|
|
|
|
? 64 |
39
|
|
|
|
|
|
|
: delete $opts{sp_height} || 16; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
4
|
|
|
|
|
26
|
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
|
|
|
|
|
28
|
return $ptc; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub load { |
56
|
2
|
|
|
2
|
0
|
5
|
my $self = shift; |
57
|
2
|
|
|
|
|
3
|
my $ptc = shift; |
58
|
|
|
|
|
|
|
|
59
|
2
|
|
|
|
|
11
|
my %opts = @_; |
60
|
2
|
100
|
50
|
|
|
19
|
my $sp_width = ( $self->RESOURCE() eq 'GRP' ) |
61
|
|
|
|
|
|
|
? 64 |
62
|
|
|
|
|
|
|
: delete $opts{sp_width} || 16; |
63
|
2
|
100
|
50
|
|
|
14
|
my $sp_height = ( $self->RESOURCE() eq 'GRP' ) |
64
|
|
|
|
|
|
|
? 64 |
65
|
|
|
|
|
|
|
: delete $opts{sp_height} || 16; |
66
|
|
|
|
|
|
|
|
67
|
2
|
|
|
|
|
11
|
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
|
|
|
|
|
5460
|
$self->data($bmp); |
75
|
2
|
|
|
|
|
1383
|
return $self; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |