我正在做一个程序来读取名为imagename.00x的TIFF,其中x是页面的序列!!
问题是,从日食运行它,它完美运行,阅读directoy,获取文件列表,显示第一个,我可以使用Previosly和Next按钮显示另一个页面..
但是当我制作.jar并尝试显示图像时(它可以检查是否存在“Matricula”的指示符/数量,问题是它何时找到并尝试绘制我想),它会返回此错误:
Exception in thread "AWT-EventQueue-0" java.util.ServiceConfigurationError: java
x.imageio.spi.ImageReaderSpi: Provider com.sun.media.imageioimpl.plugins.jpeg.CL
ibJPEGImageReaderSpi could not be instantiated: java.lang.IllegalArgumentExcepti
on: vendorName == null!
at java.util.ServiceLoader.fail(Unknown Source)
at java.util.ServiceLoader.access$100(Unknown Source)
at java.util.ServiceLoader$LazyIterator.next(Unknown Source)
at java.util.ServiceLoader$1.next(Unknown Source)
at javax.imageio.spi.IIORegistry.registerApplicationClasspathSpis(Unknow
n Source)
at javax.imageio.spi.IIORegistry.<init>(Unknown Source)
at javax.imageio.spi.IIORegistry.getDefaultInstance(Unknown Source)
at javax.imageio.ImageIO.<clinit>(Unknown Source)
at certidoesOrganizado.GeraImagem.<init>(GeraImagem.java:25)
at certidoesOrganizado.gui.EnviaLink(gui.java:267)
at certidoesOrganizado.gui.geraListaArquivos(gui.java:233)
at certidoesOrganizado.gui.limpaCaracteres(gui.java:194)
at certidoesOrganizado.gui.confereCaracteres(gui.java:155)
at certidoesOrganizado.gui$2.actionPerformed(gui.java:77)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Sour
ce)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
... more lines
GeraImagem.java,它接收到TIFF文件的PATH和编辑标签的屏幕
package certidoesOrganizado;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.*;
public class GeraImagem extends Component {
/**
*
*/
public static final long serialVersionUID = -6532574194776055714L;
Image img;
BufferedImage resizedImage = null;
public void paint(Graphics g) {
g.drawImage(img, 0, 0, null);
}
public GeraImagem(String novolink, gui tela) {
try {
img = ImageIO.read(new File(novolink));
img = resizeImage(img, 380, 518);
tela.alteraLabel(img);
} catch (IOException e) {
e.printStackTrace();
}
}
public Dimension getPreferredSize() {
if (img == null) {
return new Dimension(100, 100);
} else {
return new Dimension(img.getWidth(null), img.getHeight(null));
}
}
// Metodo usado para fazer o resize
public Image resizeImage(Image originalImage, int biggerWidth,int biggerHeight) {
try {
int type = BufferedImage.TYPE_INT_ARGB;
resizedImage = new BufferedImage(biggerWidth, biggerHeight, type);
Graphics2D g = resizedImage.createGraphics();
g.setComposite(AlphaComposite.Src);
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g.setRenderingHint(RenderingHints.KEY_RENDERING,RenderingHints.VALUE_RENDER_QUALITY);
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
g.drawImage(originalImage, 0, 0, biggerWidth, biggerHeight, null);
g.dispose();
} catch (SecurityException e) {
JOptionPane.showMessageDialog(null, "Erro ao converter imagem!",
"Erro", JOptionPane.ERROR_MESSAGE);
}
return resizedImage;
}
}
答案 0 :(得分:2)
找到解决方案 - &gt;
https://www.servoy.com/forum/viewtopic.php?f=8&t=13625&p=70765#p70765
只需使用此jai_imagio.jar即可解决问题;)