NAME
Parse::Binary - Unpack binary data structures into object hierarchies
VERSION
This document describes version 0.11 of Parse::Binary, released January 25, 2009.
SYNOPSIS
# This class represents a Win32 .ico file:
Magic
=>
'a2'
,
Type
=>
'v'
,
Count
=>
'v'
,
'Icon'
=> [
'a16'
,
'{$Count}'
, 1 ],
Data
=>
'a*'
,
);
# An individual icon resource:
Width
=>
'C'
,
Height
=>
'C'
,
ColorCount
=>
'C'
,
Reserved
=>
'C'
,
Planes
=>
'v'
,
BitCount
=>
'v'
,
ImageSize
=>
'V'
,
ImageOffset
=>
'v'
,
);
sub
Data {
my
(
$self
) =
@_
;
return
$self
->parent->
substr
(
$self
->ImageOffset,
$self
->ImageSize);
}
# Simple .ico file dumper that uses them:
my
$icon_file
= IconFile->new(
'input.ico'
);
foreach
my
$icon
(
$icon_file
->members) {
"Dimension: "
,
$icon
->Width,
"x"
,
$icon
->Height, $/;
"Colors: "
, 2 **
$icon
->BitCount, $/;
"Image Size: "
,
$icon
->ImageSize,
" bytes"
, $/;
"Actual Size: "
,
length
(
$icon
->Data),
" bytes"
, $/, $/;
}
$icon_file
->
write
(
'output.ico'
);
# save as another .ico file
DESCRIPTION
This module makes parsing binary data structures much easier, by serving as a base class for classes that represents the binary data, which may contain objects of other classes to represent parts of itself.
Documentation is unfortunately a bit lacking at this moment. Please read the tests and source code of Parse::AFP and Win32::Exe for examples of using this module.
AUTHORS
Audrey Tang <cpan@audreyt.org>
COPYRIGHT
Copyright 2004-2009 by Audrey Tang <cpan@audreyt.org>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.