在从BufferedImage中捕获图像之后,我在java中使用了JFrame。,我需要一些方法来锐化图像,当它被放大时,它看起来不会像像素一样。,这是它必须保持相同图像大小的东西。
这是我用来捕捉图像的代码。
private void grabScreenShot() throws Exception
{
BufferedImage image = (BufferedImage)createImage(getSize().width, getSize().height);
paint(image.getGraphics());
try{
//ImageIO.write(image, "jpg", new File(TimeTable.path+"\\TimeLine.jpg"));
ImageIO.write(image, "jpg", new File("C:\\Users\\"+TimeTable.user+"\\AppData\\TimeLineMacroProgram\\TimeLine.jpg"));
//ImageIO.write(image, "jpg", new File("C:\\ProgramData\\TimeLineMacroProgram\\TimeLine.jpg"));
System.out.println("Image was created");
}
catch (IOException e){
System.out.println("Had trouble writing the image.");
throw e;
}
}这是它所创造的图像

发布于 2011-06-10 22:36:32
JPG不适合截图。它是为复杂和彩色的图片而设计的,压缩过程中的信息丢失几乎可以忽略不计,比如照片。对于截图,您应该使用GIF或者更好的PNG。
ImageIO.write(image, "png", new File("C:\\Users\\"+TimeTable.user+"\\AppData\\TimeLineMacroProgram\\TimeLine.png"));你只得到一个更大的文件,但你得到像素完美的锐度和细节,这是根本不可能的JPG。
发布于 2011-06-10 20:56:33
我想是因为你把它写成了JPEG文件。
我会将格式更改为非有损的格式,或者通过访问和更改其ImageWriteParam来迫使作者不要使用压缩。
https://stackoverflow.com/questions/6311964
复制相似问题