#!/usr/bin/perl -w =head1 README wqvlinktoppm - convert Palm WQVLink database backup to ppm images This is a quick hack to parse out Casio Wrist Camera images from the Palm's WQVLinkDB.pdb backup file. To use (unashamedly *nix-specific instructions): echo "Backing up Palm" mkdir -p ~/pilot/backup; pilot-xfer -s ~/pilot/backup echo "Finding images" wqvlinktoppm ~/pilot/backup/WQVLinkDB.pdb echo "viewing images" ee wqv_image_*.ppm Acknowledgements: - http://www.mgroeber.de/misc/wqvprot.htm - details of image bytes and header - http://www.casio.com/support/index.cfm?page=/support/software/wrist_camera.html WQVLink as Palm PRC To do: - make it friendlier. I'm not going to, this is a quick hack ;) - read metadata. Again, not bothered Author: jm /at/ jmason.org -- License: GPL Last modified Sep 26 2001 jm =cut # make a quick CLUT (colour lookup table) for the WQV palette my @clut = ( ); for my $gray (0..15) { $clut[$gray] = 0x100 - ($gray * 16); } $clut[0] = 0xff; # read the header open (STDIN, "<$ARGV[0]") or die "usage: wqvlinktoppm WQVLinkDB.pdb\n"; read STDIN, $_, 0x4c; read STDIN, $_, 0x02; my $NUM_PICS = unpack ("n1", $_); # these were determined by inspection. $SKIP_HEADER_LEN = 0x02 + (8 * $NUM_PICS) + 0x13e; $PIC_WIDTH_PIXELS = 120; $PIC_HEIGHT_PIXELS = 120; # each pixel == 1 nybble $BYTES_PER_PIC = ($PIC_WIDTH_PIXELS*$PIC_HEIGHT_PIXELS) / 2; $SKIP_BETWEEN_PICS_LEN = 836; read STDIN, $_, $SKIP_HEADER_LEN; # skip header my $num = 0; while (!eof STDIN) { read STDIN, $_, $BYTES_PER_PIC; my @bytes = unpack ("C*", $_); my @nybs = (); for my $i (0..($BYTES_PER_PIC-1)) { my $byte = pop (@bytes); push (@nybs, $byte & 0x0f); push (@nybs, ($byte & 0xf0) >> 4); } $num++; my $fname = sprintf ("wqv_image_%03d.ppm", $num); open (OUT, ">$fname") or die "write to $fname failed"; print OUT "P3\n120 120\n15\n"; my $ls = 0; for my $x (0..($PIC_WIDTH_PIXELS-1)) { for my $y (0..($PIC_HEIGHT_PIXELS-1)) { my $col = $clut[pop(@nybs)]; printf OUT "%03d %03d %03d ", $col, $col, $col; if ($ls++ > 4) { print OUT "\n"; $ls = 0; } } } print OUT "\n"; close OUT or die "write to $fname failed"; print "Created: $fname\n"; read STDIN, $_, $SKIP_BETWEEN_PICS_LEN; }