Ejemplo n.º 1
0
  @Test
  public void test() {
    String[] readerFormatNames = ImageIO.getReaderFormatNames();
    System.out.println(Arrays.asList(readerFormatNames));
    // jpg bmp jpeg wbmp png

    String[] writerFormatNames = ImageIO.getWriterFormatNames();
    System.out.println(Arrays.asList(writerFormatNames));
  }
Ejemplo n.º 2
0
  public static String[] getSupportedFormats() {
    String[] img = ImageIO.getWriterFormatNames();
    String out[] = new String[img.length + 3];

    out[0] = "a2d";
    out[1] = "pat";
    out[2] = "xpda";

    for (int i = 0; i < img.length; i++) {
      out[i + 3] = img[i];
    }

    return out;
  }
Ejemplo n.º 3
0
  private void loadData(File f) {
    if (f.getName().toLowerCase().endsWith("a2d")) loadA2D(f);
    else if (f.getName().toLowerCase().endsWith("pat")) loadPAT(f);
    else if (f.getName().toLowerCase().endsWith("xpda")) loadOldFormat(f);
    else {
      boolean rightFormat = false;
      String[] formatNames = ImageIO.getWriterFormatNames();

      for (int i = 0; i < formatNames.length; i++) {
        rightFormat |= f.getName().toLowerCase().endsWith(formatNames[i]);
      }

      if (rightFormat) loadImage(f);
    }
  }
Ejemplo n.º 4
0
  private void init() {
    scaler = new ScaleSelector();
    chooser = new JFileChooser();
    chooser.setDialogType(JFileChooser.SAVE_DIALOG);
    chooser.setDialogTitle("Export Prefuse Display...");
    chooser.setAcceptAllFileFilterUsed(false);

    HashSet seen = new HashSet();
    String[] fmts = ImageIO.getWriterFormatNames();
    for (int i = 0; i < fmts.length; i++) {
      String s = fmts[i].toLowerCase();
      if (s.length() == 3 && !seen.contains(s)) {
        seen.add(s);
        chooser.setFileFilter(new SimpleFileFilter(s, s.toUpperCase() + " Image (*." + s + ")"));
      }
    }
    seen.clear();
    seen = null;
    chooser.setAccessory(scaler);
  }
Ejemplo n.º 5
0
  /**
   * Method to get the list of supported file extensions for writing
   *
   * @return List of supported file extensions for writing
   * @throws OpenStegoException
   */
  public List<String> getWritableFileExtensions() throws OpenStegoException {
    if (writeFormats != null) {
      return writeFormats;
    }

    String format = null;
    String[] formats = null;
    List<String> formatList = new ArrayList<String>();

    formats = ImageIO.getWriterFormatNames();
    for (int i = 0; i < formats.length; i++) {
      format = formats[i].toLowerCase();
      if (format.indexOf("jpeg") >= 0 && format.indexOf("2000") >= 0) {
        format = "jp2";
      }
      if (!formatList.contains(format)) {
        formatList.add(format);
      }
    }

    Collections.sort(formatList);
    writeFormats = formatList;
    return writeFormats;
  }
Ejemplo n.º 6
0
 static {
   SUPPORTED_FORMATS.addAll(Arrays.asList(ImageIO.getWriterFormatNames()));
 }