@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)); }
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; }
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); } }
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); }
/** * 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; }
static { SUPPORTED_FORMATS.addAll(Arrays.asList(ImageIO.getWriterFormatNames())); }