/** * °´Â·¾¶±£´æ * * @param bufferImage * @param docNo * @throws Exception */ public static void saveImageToPriview( java.awt.image.BufferedImage bufferImage, String path, String docNo) throws Exception { StringBuffer temp = new StringBuffer(); java.io.File outFile = new java.io.File(path); if (!outFile.exists()) { outFile.mkdirs(); } java.io.File file = new java.io.File(outFile, temp.append(docNo).append(".png").toString()); if (!file.exists()) { java.io.FileOutputStream out = new java.io.FileOutputStream(file); javax.imageio.ImageIO.write(bufferImage, "png", out); out.close(); } }
private boolean CheckValidDir(String path) { java.io.File dir = new java.io.File(path); if (dir == null) { return false; } if (dir.isFile()) { return false; } if (!dir.exists()) { return false; } return true; }
public static java.awt.Image loadImageFromFile(String path) { java.io.File file = new java.io.File(path); if (file.exists()) { java.awt.Toolkit tk = java.awt.Toolkit.getDefaultToolkit(); java.awt.Image img = tk.createImage(path); try { java.awt.MediaTracker mt = new java.awt.MediaTracker(new javax.swing.JPanel()); mt.addImage(img, 0); mt.waitForID(0); } catch (Exception ex) { return null; } return img; } return null; }