コード例 #1
0
ファイル: PhotoThumbnail.java プロジェクト: timabell/gpsprune
 /**
  * Run method, for loading image in separate thread
  *
  * @see java.lang.Runnable#run()
  */
 public void run() {
   if (_inPanel) {
     // use either exif thumbnail or photo scaled down to sensible size
     if (_photo.getExifThumbnail() != null) {
       // Use exif thumbnail
       Image image = new ImageIcon(_photo.getExifThumbnail()).getImage();
       _thumbnail =
           ImageUtils.createScaledImage(image, image.getWidth(null), image.getHeight(null));
       image = null;
     } else {
       // no exif thumbnail available, going to have to read whole thing
       int picWidth = _photo.getWidth();
       int picHeight = _photo.getHeight();
       if (picWidth > -1 && picHeight > -1) {
         // Just set a "reasonable" thumbnail size for now
         final int DEFAULT_THUMB_SIZE = 400;
         // calculate maximum thumbnail size
         Dimension thumbSize =
             ImageUtils.getThumbnailSize(
                 picWidth, picHeight, DEFAULT_THUMB_SIZE, DEFAULT_THUMB_SIZE);
         // Make icon to load image into
         Image image = _photo.createImageIcon().getImage();
         // save scaled, smoothed thumbnail for reuse
         _thumbnail = ImageUtils.createScaledImage(image, thumbSize.width, thumbSize.height);
         image = null;
       } else _loadFailed = true;
     }
   } else {
     _thumbnail = _photo.createImageIcon().getImage();
   }
   _loadingImage = false;
   repaint();
 }