HI,
How to change the DPI of a image? (And how to check the DPI is chnaged?)
I tried with JPEGImageEncoder, but can't see any effect even if I chnage DPI value.
Please see the bellow method,
public void saveBufferedImageAsJPEG(BufferedImage bi, int dpi,
String fileName)
{
FileOutputStream out = null;
try
{
out = new FileOutputStream(fileName+".jpg");
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bi);
param.setQuality(1f, false);
param.setDensityUnit(JPEGEncodeParam.DENSITY_UNIT_DOTS_INCH);
param.setXDensity(dpi);
param.setYDensity(dpi);
encoder.setJPEGEncodeParam(param);
try
{
encoder.encode(bi);
out.close();
}
catch (IOException io)
{
System.out.println(io);
}
}
catch (FileNotFoundException fnf)
{
System.out.println("File Not Found");
}
}
I read that if i change the DPI value, the size of imaage changes,
i.e. if increase DPI value the image's height and width increases.
But I can not see any effect in resultant image here.
Please let me know if anyone has any information on this.
Thnaks.