Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!perl
- use POSIX;
- use strict;
- use IO::Uncompress::Inflate qw(inflate);
- sub grect {
- my($fh) = @_;
- read $fh, $_, 1;
- $_ = unpack "C", $_;
- $_ = ($_ >> 3) * 4 + 5;
- $_ = ceil($_ / 8) - 1; # skipping rect
- seek $fh, $_, 1;
- $_;
- }
- sub gui16 {
- my($fh) = @_;
- read $fh, $_, 2;
- unpack "v", $_;
- }
- sub gui32 {
- my($fh) = @_;
- read $fh, $_, 4;
- unpack "V", $_;
- }
- sub gtag {
- my ($fh) = @_;
- if (eof($fh)) {
- return 0;
- }
- my ($s, $t);
- $t = gui16($fh);
- ($s, $t) = ($t & 0x3f, $t >> 6);
- if ($s == 0x3f) {
- $s = gui32($fh);
- }
- my $c;
- read $fh, $c, $s;
- [$t, $c];
- }
- my ($fh, $fhz, $s);
- open $fh, $ARGV[0];
- binmode $fh;
- read $fh, $s, 3;
- die "nope" if $s ne "CWS";
- read $fh, $s, 5;
- $fhz = new IO::Uncompress::Inflate $fh;
- grect($fhz);
- gui16($fhz);
- gui16($fhz);
- my ($i, $a) = (0);
- while ($a = gtag($fhz)) {
- open O, ">${i}_$a->[0].o";
- binmode O;
- print O $a->[1];
- $a = undef;
- close O;
- $i++;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement