All pastes #177767 Raw Edit

Untitled

public java v1 · immutable
#177767 ·published 2006-09-20 17:27 UTC
rendered paste body
public void savePicture(int id) {		if ( picture == null)			return;				String picName = getPicName(id);		File im = new File(picName);				BufferedImage bm = new BufferedImage(picture.getIconWidth(), picture.getIconHeight(), BufferedImage.TYPE_INT_RGB);		Graphics2D g =(Graphics2D) bm.createGraphics();		g.drawImage(picture.getImage(), 0,0,null);				try{			if ( ! im.canWrite() && im.exists())				throw new IOException("image file is not writable!");			else				ImageIO.write(bm, "JPG_IMG", im);					}catch( IOException e){			JOptionPane.showConfirmDialog(pP,"could not save picture", "error", JOptionPane.CANCEL_OPTION, JOptionPane.ERROR_MESSAGE);			e.printStackTrace();		}	}