只是想编辑一些代码,以便输出 jpg 质量不是默认的低质量设置
try
{
ImageIO.write(var6, "jpg", var7);
}
......目前正在使用。
我查看了其他一些设置质量的 Java 示例,但对 Java 不是很熟悉,我无法理解如何插入内容并重新编写一些示例,这些示例是我在使用 Java 设置图像质量时看到的。
ImageWriteParam iwparam = new JPEGImageWriteParam(Locale.getDefault());
iwparam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
iwparam.setCompressionQuality(quality);
writer.write(null, new IIOImage(image, null, null), iwparam);
这是我正在尝试工作的代码......
public static String func_74292_a(File par0File, String par1Str, int par2, int par3)
{
File var4 = new File(par0File, "screenshots");
var4.mkdir();
int var5 = par2 * par3;
if (field_74293_b == null || field_74293_b.capacity() < var5)
{
field_74293_b = BufferUtils.createIntBuffer(var5);
field_74294_c = new int[var5];
}
GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1);
GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
field_74293_b.clear();
GL11.glReadPixels(0, 0, par2, par3, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, field_74293_b);
field_74293_b.get(field_74294_c);
func_74289_a(field_74294_c, par2, par3);
BufferedImage var6 = new BufferedImage(par2, par3, 1);
var6.setRGB(0, 0, par2, par3, field_74294_c, 0, par2);
if (par1Str == null)
{
var7 = func_74290_a(var4);
}
else
{
var7 = new File(var4, par1Str);
}
try
{
ImageIO.write(var6, "jpg", var7);
}
catch (IOException var8)
{
;
}
Thread var7x = new Thread(new ScreenShotHelper$1());
var7x.start();
return "\u00a7aUploading Screenshot....";
}
private static File func_74290_a(File par0File)
{
String var1 = dateFormat.format(new Date()).toString();
int var2 = 1;
while (true)
{
File var3 = new File(par0File, var1 + (var2 == 1 ? "" : "_" + var2) + ".jpg");
if (!var3.exists())
{
return var3;
}
++var2;
}
}