View difference between Paste ID: TSTB8jk8 and NLd34ZVY
SHOW: | | - or go back to the newest paste.
1
#!/usr/bin/perl
2
3
use strict;
4
use Data::Dumper;
5
6
my $bmp_header = join '', map (chr, 0x42,0x4d,0xf6,0xd4,0x04,0x00,0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x10,0x01,0x00,0x00,0x84,0x01,0x00,0x00,0x01,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0xc0,0xd4,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00);
7
opendir (DIR, ".") || die "$!";
8
my @files = grep /\.npd$/i, grep !/^\.\.?$/, readdir DIR;
9
closedir DIR;
10
11
foreach my $file (@files) {
12
  my $fn = $file; $fn =~ s/\.npd$/.bmp/i;
13
  open (fo, ">".$fn) || die "$!";
14
  binmode fo;
15
  print fo $bmp_header;
16
  open (fh, "<".$file) || die "$!";
17
  binmode fh;
18-
  for(my $i=0; $i<388;$i++) {
18+
  for(my $i=0; $i<240;$i++) {
19-
    seek fh, -((272*3*2)+($i*272*3)), 2;
19+
    seek fh, -((320*3*2)+($i*320*3)), 2;
20-
    read fh, my $buf, 272*3;
20+
    read fh, my $buf, 320*3;
21-
    for(my $c=0;$c<272;$c++) { substr($buf, $c*3+2,1, substr($buf, $c*3, 1, substr($buf, $c*3+2,1))); }
21+
    for(my $c=0;$c<320;$c++) { substr($buf, $c*3+2,1, substr($buf, $c*3, 1, substr($buf, $c*3+2,1))); }
22
    print fo $buf;
23
  }
24
  close fh;
25
  close fo;
26
}