<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 61,  comments - 2033,  trackbacks - 0

     

    package demo;

    import java.io.File;
    import org.jfree.chart.JFreeChart;
    import java.io.IOException;
    import java.io.OutputStream;
    import java.io.BufferedOutputStream;
    import java.io.FileOutputStream;
    import java.awt.image.BufferedImage;
    import org.jfree.chart.encoders.ImageFormat;
    import java.awt.Graphics2D;
    import java.awt.*;
    import java.awt.*;
    import org.jfree.chart.encoders.ImageEncoder;
    import org.jfree.chart.encoders.ImageEncoderFactory;
    import javax.swing.JFrame;
    import javax.imageio.ImageIO;

    public class ToImg {
      
    public ToImg() {
      }



      
    /**
       * Saves a chart to a file in JPEG format.
       *
       * 
    @param file  the file (<code>null</code> not permitted).
       * 
    @param quality  the JPEG quality setting.
       * 
    @param chart  the chart (<code>null</code> not permitted).
       * 
    @param width  the image width.
       * 
    @param height  the image height.
       *
       * 
    @throws IOException if there are any I/O errors.
       
    */

      
    public static void saveChartAsJPEG(File file,
                                         
    float quality,
                                         JFreeChart chart,
                                         
    int width,
                                         
    int height) throws IOException {

        
    if (file == null{
            
    throw new IllegalArgumentException("Null 'file' argument.");
        }

        
    if (chart == null{
            
    throw new IllegalArgumentException("Null 'chart' argument.");
        }

        OutputStream out 
    = new BufferedOutputStream(new FileOutputStream(file));

        BufferedImage images 
    = chart.createBufferedImage(width, height, null);
        BufferedImage image 
    = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 
    = image.createGraphics();
    //    draw(g2, new Rectangle2D.Double(0, 0, width, height), null, info);
        g2.dispose();

        writeBufferedImage(image, ImageFormat.JPEG, out, quality);
        out.close();
      }


      
    public static void writeBufferedImage(BufferedImage image, String format,
          OutputStream outputStream, 
    float quality)
          
    throws IOException {
        ImageEncoder imageEncoder
            
    = ImageEncoderFactory.newInstance(format, quality);
        imageEncoder.encode(image, outputStream);

      }


      
    public static void main(String[] args) {
        Robot robot 
    = null;
        
    try {
          
          JFrame f 
    = new Frame1(); 
          f.setSize(
    500,600);
          f.setVisible(
    true);
          f.setDefaultCloseOperation(
    2);
          BufferedImage image 
    = new BufferedImage(500600, BufferedImage.TYPE_INT_RGB);
          f.getContentPane().paint(image.getGraphics());
          FileOutputStream out 
    = new FileOutputStream("d:\\b.jpg");
          ImageIO.write(image, 
    "jpeg" , out);
          out.close();

    /**    
         抓圖  
          Robot robot = new java.awt.Robot();
          BufferedImage image = robot.createScreenCapture(new Rectangle(100, 100));
          ImageEncoder imageEncoder
              = ImageEncoderFactory.newInstance(ImageFormat.JPEG, 100);
          FileOutputStream out = new FileOutputStream("d:\\a.jpg");
          imageEncoder.encode(taget, out);
     }
    */


       }

        
    catch (Exception ex) {
          ex.printStackTrace();
        }


      }


    }

    posted on 2005-12-20 17:16 魚上游 閱讀(758) 評論(0)  編輯  收藏 所屬分類: 爪哇風景欣賞爪哇世界探險
    <2005年12月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    常用鏈接

    留言簿(82)

    隨筆分類(59)

    文章分類(21)

    相冊

    收藏夾(40)

    GoodSites

    搜索

    •  

    積分與排名

    • 積分 - 1267277
    • 排名 - 22

    最新評論

    閱讀排行榜

    主站蜘蛛池模板: 一个人看的免费高清视频日本| a级毛片免费观看在线| 99re6在线视频精品免费| 亚洲免费在线观看视频| 国产伦精品一区二区三区免费迷| 国产精品亚洲аv无码播放| 亚洲人成网站色在线观看| yellow视频免费在线观看| 成人免费大片免费观看网站| 免费一级一片一毛片| 自怕偷自怕亚洲精品| 日本一区二区三区免费高清在线| 最近中文字幕大全免费视频| 亚洲AⅤ视频一区二区三区| 亚洲精品国产手机| 五级黄18以上免费看| 青青青国产在线观看免费| 色噜噜亚洲精品中文字幕| 亚洲永久网址在线观看| 日本免费中文视频| 免费a级毛片无码av| 亚洲国产日产无码精品| 中文在线免费不卡视频| 免费毛片在线播放| 亚洲精品无码久久毛片波多野吉衣 | 亚洲无码视频在线| 亚洲色大成网站www永久男同| 久久国产乱子伦精品免费看| 亚洲成A∨人片天堂网无码| 亚洲人成网站日本片| 人人玩人人添人人澡免费| 亚洲人午夜射精精品日韩| 亚洲欧美日韩自偷自拍| 亚洲视频在线免费看| 亚洲AV日韩AV天堂久久| av网站免费线看| 亚洲精品视频免费| 国产偷国产偷亚洲高清在线| 成人无码区免费A片视频WWW| 亚洲自偷自偷精品| 日韩视频免费在线观看|