home *** CD-ROM | disk | FTP | other *** search
/ Netrunner 2004 October / NETRUNNER0410.ISO / regular / ActivePerl-5.8.4.810-MSWin32-x86.msi / _b788d87a44f0f90d36d70db626be7f20 < prev    next >
Text File  |  2004-06-01  |  1KB  |  68 lines

  1. #!/usr/local/bin/perl -w
  2. use strict;
  3. use Tk;
  4. use Tk::JPEG;
  5. use Getopt::Std;
  6. eval { require Tk::PNG; };
  7.  
  8. my $mw  = MainWindow->new();
  9. print "vis=",$mw->visual," d=",$mw->depth,"\n";
  10. my ($vis) = grep(!/\b8\b/,grep(/truecolor/,$mw->visualsavailable));
  11. my @args = ();
  12. if ($vis)
  13.  {
  14.   # print $vis,"\n";
  15.   $mw->destroy;
  16.   $mw = MainWindow->new(-visual => $vis);
  17.  }
  18. else
  19.  {
  20.   @args = (-palette => '4/4/4');
  21.  }
  22. # print "vis=",$mw->visual," d=",$mw->depth,' "',join('" "',$mw->visualsavailable),"\"\n";
  23. my %opt;
  24. getopts('f:',\%opt);
  25. if ($opt{'f'})
  26.  {
  27.   push(@args,'-format' => $opt{'f'});
  28.  }
  29. unless (@ARGV)
  30.  {
  31.   warn "usage $0 [-f format] <imagefile>\n";
  32.   exit 1;
  33.  }
  34. my $file = shift;
  35. my $image = $mw->Photo(-file => $file, @args);
  36. #print join(' ',$image->formats),"\n";
  37. print "w=",$image->width," h=",$image->height,"\n";
  38. $mw->Label(-image => $image)->pack(-expand => 1, -fill => 'both');
  39. $mw->Button(-text => 'Quit', -command => [destroy => $mw])->pack;
  40. MainLoop;
  41.  
  42. __END__
  43.  
  44. =head1 NAME
  45.  
  46. tkjpeg - simple JPEG viewer using perl/Tk
  47.  
  48. =head1 SYNOPSIS
  49.  
  50.   tkjpeg imagefile.jpg
  51.  
  52. =head1 DESCRIPTION
  53.  
  54. Very simplistic image viewer that loads JPEG image, (well actually
  55. anything for which Photo has a handler) and puts it into a
  56. Label for display.
  57.  
  58. It tries to find a fullcolour visual to use if display is deeper than
  59. 8-bit. (On 8-bit it uses a 4/4/4 palette.)
  60.  
  61. =head1 AUTHOR
  62.  
  63. Nick Ing-Simmons <nick@ing-simmons.net>
  64.  
  65. =cut
  66.  
  67.  
  68.