outputStream = new ByteArrayOutputStream();
if (lowFormat.startsWith("png")) {
PNGEncodeParam pngParam = PNGEncodeParam
.getDefaultEncodeParam(image);
pngParam.setPhysicalDimension(dpi * 3937, dpi * 3937, 100);
PNGImageEncoder pngEncoder = new PNGImageEncoder(outputStream,
pngParam);
pngEncoder.encode(image);
} else if ("jpg".equals(lowFormat) || "jpeg".equals(lowFormat)) {
JPEGEncodeParam jpgParam = JPEGCodec
.getDefaultJPEGEncodeParam(image);
jpgParam.setXDensity(dpi);
jpgParam.setYDensity(dpi);