<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

    搜索

    •  

    積分與排名

    • 積分 - 1267178
    • 排名 - 22

    最新評論

    閱讀排行榜

    主站蜘蛛池模板: 色吊丝永久在线观看最新免费| 亚洲动漫精品无码av天堂| 亚洲网站在线免费观看| a视频免费在线观看| 亚洲熟妇中文字幕五十中出| 岛国岛国免费V片在线观看| 亚洲美女高清一区二区三区 | 久久99国产亚洲高清观看首页| 亚洲欧洲日产专区| 羞羞漫画登录页面免费| 人妻无码一区二区三区免费| 亚洲av无码不卡| 亚洲一区二区在线免费观看| 亚洲高清在线mv| 最近中文字幕mv免费高清电影 | 91精品国产免费| 亚洲成人免费网址| 毛片在线免费视频| 亚洲Aⅴ在线无码播放毛片一线天| 免费在线看黄的网站| 久久久无码精品亚洲日韩蜜臀浪潮 | 亚洲不卡影院午夜在线观看| 免费毛片在线视频| 成人免费乱码大片A毛片| 亚洲AV无码不卡在线播放| 男女作爱免费网站| 国产精品亚洲片在线观看不卡| 亚洲AV无码成人精品区狼人影院| 久久免费看少妇高潮V片特黄| 亚洲成av人片天堂网老年人 | 无码天堂va亚洲va在线va| 亚洲毛片av日韩av无码| 久久大香伊焦在人线免费| 亚洲国产系列一区二区三区 | 亚洲综合无码AV一区二区 | 亚洲 无码 在线 专区| 免费毛片在线看不用播放器| 亚洲国产成人资源在线软件 | 香蕉高清免费永久在线视频| 免费无遮挡无码视频在线观看| 在线免费观看污网站|