#!/usr/bin/perl -w use strict; use Getopt::Std; my $dncachefname = ".dncache"; my %opt; getopts('hVCcn:' => \%opt); map{print "$_: $opt{$_}\n"} keys %opt; if(defined $opt{'h'}) { print <) { $line = $_; chomp($line); if($line =~ /^#/) { next; } ($dn, $fn) = split(/\s+/, $line,2); #print STDERR "dn $dn fn $fn\n"; $dnar{$fn} = $dn; } # close(DNF); } else { open(DNF, ">$dncachefname"); } use Tk; use Tk::JPEG; #use TK::Thumbnail; #use Gtk -init; use Image::Magick; use MIME::Base64; require '_ocr-shotnote3.pl'; my $top = MainWindow->new(); my $topline = $top->Label(-text=>"SHEETS")->pack(); my $cmdline = $top->Frame()->pack(-fill=>'x'); my $Cquit = $cmdline->Button(-text=>"quit",-command=>['exit'])->pack(-side=>'left'); my $metal = $top->Frame(-width=>800,-height=>500)->pack(); my $base; my $rox; my $roy; $base = $metal->Canvas(-width=>800, -height=>800); $roy = $metal->Scrollbar(-orient=>'v',-command=>['yview', $base]); $rox = $metal->Scrollbar(-orient=>'h',-command=>['xview', $base]); $base->configure(-yscrollcommand=>['set', $roy] ); $base->configure(-xscrollcommand=>['set', $rox] ); $base->configure(-scrollregion=>"0 0 1000 80000"); $base->grid(-row=>1,-column=>1, -sticky=>'ns'); $roy->grid(-row=>1,-column=>2,-sticky=>"ns"); $rox->grid(-row=>2,-column=>1,-sticky=>"ew"); my $sumy=0; my $imggap=30; my $sumi=0; sub addsheet { my($fn) = @_; # my $lbl = $base->Label()->pack(); # my $body = $base->Label()->pack(); my $im = Image::Magick->new; my $xsht = $top->Photo( -file => ''); my $w; my $h; #print STDERR "1 fn $fn\n"; $im->Read($fn); # $im->Scale(geometry=>'120x160'); $im->Scale(geometry=>'300x400'); my $data = encode_base64($im->ImageToBlob() ); undef @$im; $xsht->put($data); $w = $xsht->width(); $h = $xsht->height(); #print "size $w x $h\n"; my $v; my $msg; $msg = sprintf("%3d:", $sumi); if(defined $dnar{$fn}) { $v = $dnar{$fn}; } else { $v = &ap($fn, 100); $v =~ s/w/0/g; print DNF "$v $fn\n"; } $base->create('text', 50, $sumy+$imggap/2, -justify=>'right', -text=>$msg); $base->create('text', 250, $sumy+$imggap/2, -justify=>'right', -text=>$v); $base->create('text', 500, $sumy+$imggap/2, -justify=>'left', -text=>$fn); $sumi++; $sumy += $imggap; # $body->configure(-image => $xsht); $base->create('image', $w/2, $sumy+$h/2, -image=>$xsht); $sumy += $h; # $lbl->configure(-text=>$v); } sub addsheetlist { my (@xfs) = @_; my $m; my $tb; my $ta; my $i; $i = 0; $tb = time(); foreach $m (@xfs) { #print STDERR "L fn $m\n"; #print STDERR "$i/$imglimit $m\n"; &addsheet($m); $i++; if($i>=$imglimit) { last; } } $ta = time(); print "i $i\n"; print "sumy $sumy\n"; print "tb $tb\n"; print "ta $ta\n"; print "-- ".($ta-$tb)."\n"; } # &addsheet($ARGV[0]); my @fs; my @cfs; my $i; my $j; my $p; foreach $i (@ARGV) { if(-d $i) { opendir(DIR, $i); @cfs = readdir(DIR); closedir(DIR); foreach $j (@cfs) { $p = $i."/".$j; if(-f $p) { push(@fs, $p); } } } else { push(@fs, $i); } } my $c; $c = 0; foreach $i (@fs) { # print "$i\n"; $c++; } $topline->MapWindow(); $base->MapWindow(); $top->MapWindow(); &addsheetlist(@fs); MainLoop();