熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> JSP教程 >> 正文

將form保存到圖片中

2013-11-15 11:48:29  來源: JSP教程 

   public void OnSaveJPG() {
  Rectangle rect = getBounds();
  BufferedImage image =
  (BufferedImage)createImage(rectwidth rectheight);
  Graphics g = imagegetGraphics();
  paint(g);
  gdispose();
  try {
  FileOutputStream fileStream =
  new FileOutputStream(E:\\Testjpg);
  JPEGImageEncoder encoder =
  JPEGCodeccreateJPEGEncoder(fileStream);
  encoderencode(image);
  fileStreamclose();
  } catch (Exception e) {
  Systemoutprintln(Error saving JPEG file!);
  }
  }
  
  
  

From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19655.html
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.