}
}
else { // PNG is the default
PNGEncodeParam param = PNGEncodeParam.getDefaultEncodeParam( bi );
ImageEncoder encoder = ImageCodec.createImageEncoder( "PNG", out, param ); //NON-NLS
try {
// Writes it to a file as a .png
encoder.encode( bi );
} catch (IOException e) {
throw new IllegalStateException("IOException error.", e);
} catch (NullPointerException npe) {
throw new IllegalStateException("Could not encode buffered image because it was null.", npe);
}