Java生成图片默认分辨率是72dpi,由于需要打印生成图片,要求图片分辨率至少300dpi,这个问题整了将近一天时间,最终得到解决,感谢网友的分享。在这里记录一下,已备后面使用。以下代码摘抄至https://my.oschina.net/osgit/blog/530283
/**
* 接口设计
*/
public interface ImageDPIProcessor {
/**
* 根据文件后缀扩展名判断是否能进行处理
*
* @param fileName
* @return
*/
public boolean canHandle(String fileName);
/**
*
* @param path
* @param dpi
* dot per inch
* @return
* @throws IOException
* @throws MalformedURLException
*/
public byte[] process(final BufferedImage srcimage, final int dpi) throws Exception;
PNG处理方式:
public class PngDPIProcessor implements ImageDPIProcessor {
//1英寸是2.54里面
private static final double INCH_2_CM = 2.54d;
@Override
public