0

バッファリングされたbmpイメージを読み込んでから、圧縮してjpegに変換しようとしています。バッファリングされた画像行に問題があります。ありがとう、どんな助けでもありがたいです。

public void jpegconvert(String Fname, String Crate)
{

BufferedImage image =  ImageIO.read(Fname);

Iterator<ImageWriter> i = ImageIO.getImageWritersByFormatName("jpeg"); 

// Just get the first JPEG writer available 
ImageWriter jpegWriter = i.next(); 

// Set the compression quality to 0.8 
ImageWriteParam param = jpegWriter.getDefaultWriteParam(); 
param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); 
param.setCompressionQuality(0.8f); 

// Write the image to a file 
FileImageOutputStream out = new FileImageOutputStream(new File("newimage.jpg")); 
jpegWriter.setOutput(out); 
jpegWriter.write(null, new IIOImage(image, null, null), param); 
jpegWriter.dispose(); 
out.close();
}
}

ホバーエラーはこれを言います:

no suitable method found for read(String)
    method ImageIO.read(ImageInputStream) is not applicable
      (actual argument String cannot be converted to ImageInputStream by method invocation conversion)
    method ImageIO.read(URL) is not applicable
      (actual argument String cannot be converted to URL by method invocation conversion)
    method ImageIO.read(InputStream) is not applicable
      (actual argument String cannot be converted to InputStream by method invocation conversion)
    method ImageIO.read(File) is not applicable
      (actual argument String cannot be converted to File by method invocation conversion)
4

1 に答える 1

2

問題はこの特定のコードにあります
ImageIO.read(Fname);
。cozFnameは、オーバーロードされたメソッドのいずれにおいても引数として受け取らない読み取りメソッドのAPIをStringチェックしています。String

このリファレンスはあなたを助けるかもしれません

于 2013-02-09T16:40:38.390 に答える