Java Code Examples for javax.imageio.ImageIO.getReaderFileSuffixes()

The following are Jave code examples for showing how to use getReaderFileSuffixes() of the javax.imageio.ImageIO class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: PPRCarTrade   File: TelaEditarImagensVeiculo.java   View Source Code Vote up 6 votes
private void btn_AdicionarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_AdicionarActionPerformed
    // TODO add your handling code here:
    JFileChooser fc = new JFileChooser();
    FileFilter imageFilter = new FileNameExtensionFilter("Image files", ImageIO.getReaderFileSuffixes());
    fc.setFileFilter(imageFilter);
    int result = fc.showOpenDialog(null);
    if(result == JFileChooser.APPROVE_OPTION){
        try {
            String path = fc.getSelectedFile().getAbsolutePath();
            imagens.add(new ImageIcon(path));
            if(!auxImagens.contains(imagens.get(imagens.size() - 1))){
                auxImagens.add(imagens.get(imagens.size() - 1));
            }
            JOptionPane.showMessageDialog(this, "Imagem carregada com sucesso!");
        } catch(Exception e){
            JOptionPane.showMessageDialog(null, "Ocorreu um erro ao carregar a imagem!", "Erro", JOptionPane.ERROR_MESSAGE);
        }            
    }
    jsl_Slider.setMaximum(Math.max(0, imagens.size() - 1));
}
 
Example 2
Project: PPRCarTrade   File: TelaVenda.java   View Source Code Vote up 6 votes
private void btn_CarregarImagemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_CarregarImagemActionPerformed
    // TODO add your handling code here:
    JFileChooser fc = new JFileChooser();
    FileFilter imageFilter = new FileNameExtensionFilter("Image files", ImageIO.getReaderFileSuffixes());
    fc.setFileFilter(imageFilter);
    int result = fc.showOpenDialog(null);
    if(result == JFileChooser.APPROVE_OPTION){
        try {
            String path = fc.getSelectedFile().getAbsolutePath();
            imagens.add(new ImageIcon(path));
            JOptionPane.showMessageDialog(this, "Imagem carregada com sucesso!");
        } catch(Exception e){
            JOptionPane.showMessageDialog(null, "Ocorreu um erro ao carregar a imagem!", "Erro", JOptionPane.ERROR_MESSAGE);
        }            
    }
}
 
Example 3
Project: openjdk-jdk10   File: GetReaderWriterInfoNullTest.java   View Source Code Vote up 6 votes
public static void main (String[] args) throws IIOException {
    // Verify getReaderMIMETypes() behavior by keeping MIMEType as null.
    TestImageReaderSpi mimeNullReadSpi =
            new TestImageReaderSpi(FORMATNAMES, SUFFIXES, null);
    IIORegistry.getDefaultInstance().
            registerServiceProvider(mimeNullReadSpi);
    ImageIO.getReaderMIMETypes();
    IIORegistry.getDefaultInstance().
            deregisterServiceProvider(mimeNullReadSpi);

    /*
     * Verify getReaderFileSuffixes() behavior by keeping
     * file suffix as null.
     */
    TestImageReaderSpi suffixNullReadSpi =
            new TestImageReaderSpi(FORMATNAMES, null, MIMETYPES);
    IIORegistry.getDefaultInstance().
            registerServiceProvider(suffixNullReadSpi);
    ImageIO.getReaderFileSuffixes();
    IIORegistry.getDefaultInstance().
            deregisterServiceProvider(suffixNullReadSpi);
}
 
Example 4
Project: openjdk-jdk10   File: GetReaderWriterInfo.java   View Source Code Vote up 5 votes
private static void testGetReaderFileSuffixes() {
    String[] suffixes = ImageIO.getReaderFileSuffixes();
    for (String s : suffixes) {
        Iterator<ImageReader> it = ImageIO.getImageReadersBySuffix(s);
        if (!it.hasNext()) {
            throw new RuntimeException("getReaderFileSuffixes returned " +
                                       "an unknown suffix: " + s);
        }
    }
}
 
Example 5
Project: ait-platform   File: AitDocumentDao.java   View Source Code Vote up 5 votes
private boolean canCreateThumbnail(String fileName) {
	String[] suffixes = ImageIO.getReaderFileSuffixes();
	for (String suffix : suffixes) {
		if (fileName.endsWith(suffix)) {
			return true;
		}
	}
	return false;
}