File outfile = new File(filename);
OutputStream fos = createFile(outfile);
if (fos == null) {
return;
}
PNGEncodeParam param = PNGEncodeParam.getDefaultEncodeParam(image);
PNGImageEncoder encoder = new PNGImageEncoder(fos, param);
try {
encoder.encode(image);
} catch (IOException e) {
JMeterUtils.reportErrorToUser("PNGImageEncoder reported: "+e.getMessage(), "Problem creating image file");