コード例 #1
0
 private String downloadImage(String url) {
   String filename = WebHelper.getUniqueFilenameFromURL(url);
   if (filename != null) {
     String videoImageDirectory =
         CommonMiningAPIWrapper.getMinedDataDirectory(dataSource) + "videoimages/";
     String fullPath = videoImageDirectory + filename;
     if (log.isTraceEnabled())
       log.trace(
           "downloadImage(): saving videoImageURL=" + url + ", to local filepath=" + fullPath);
     if (ImageHelper.saveImageURL(url, fullPath)) {
       if (RE3Properties.getBoolean("server_mode")) {
         try {
           BufferedImage img = FileSystemAccess.getFileSystem().readBufferedImage(fullPath);
         } catch (InvalidImageException e) {
           return null;
         }
       } else {
         try {
           fetched = true;
           image = FileSystemAccess.getFileSystem().readQImage(fullPath);
         } catch (InvalidImageException e) {
           return null;
         }
       }
       return fullPath;
     }
   }
   return null;
 }
コード例 #2
0
  public static QImage fetchThumbnailImageNow(String imageFilename, QSize size) {
    try {
      QImage img = null;
      if (!imageFilename.equals(SearchRecord.DEFAULT_THUMBNAIL_IMAGE))
        img = FileSystemAccess.getFileSystem().readQImage(imageFilename);
      else img = new QImage(imageFilename);

      /*
      QImage result = (img.width() > size.width()
                 || img.height() > size.height())
                 ? img.scaled(size, Qt.AspectRatioMode.KeepAspectRatio, Qt.TransformationMode.SmoothTransformation)
                 : img.copy();
                 */

      QImage result = null;
      if ((img.width() > size.width() || img.height() > size.height())) {
        result =
            img.scaled(
                size,
                Qt.AspectRatioMode.KeepAspectRatio,
                Qt.TransformationMode.SmoothTransformation);
      } else {
        result = img.copy();
      }

      img.dispose();
      return result;
    } catch (InvalidImageException ie) {
      if (log.isDebugEnabled())
        log.debug("fetchThumbnailImageNow(): could not load image=" + imageFilename);
    } catch (Exception e) {
      log.error("fetchThumbnailImageNow(): error", e);
    }
    return null;
  }