imagename.00x という名前の TIFF を読み取るプログラムを実行しています。ここで、x はページのシーケンスです!!
問題は、Eclipseから実行すると完全に機能し、ディレクトリを読み取り、ファイルリストを取得し、最初のファイルを表示し、[前へ]ボタンと[次へ]ボタンを使用して別のページを表示できることです..
しかし、.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
TIFF ファイルへの PATH を受け取る GeraImagem.java と、ラベルを編集する画面
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;
}
}