<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

    最新評論

    閱讀排行榜

    主站蜘蛛池模板: 亚洲美女高清一区二区三区| 久久午夜免费视频| 四虎影在线永久免费四虎地址8848aa | 成人免费男女视频网站慢动作| 国产国产人免费人成成免视频| 99视频在线免费| 黄网址在线永久免费观看| 久久精品国产精品亚洲艾草网美妙| 亚洲色四在线视频观看| 亚洲国产精品精华液| 免费一级毛片无毒不卡| 亚洲AV无码精品色午夜果冻不卡| 久久99免费视频| 亚洲无砖砖区免费| 无码少妇一区二区浪潮免费| 国产精品亚洲精品日韩已满| 野花香高清视频在线观看免费 | 中文字幕一精品亚洲无线一区| 精品久久久久久国产免费了| 国产精品亚洲аv无码播放| 日本免费中文字幕| 亚洲人成影院午夜网站| 成年女人色毛片免费看| 亚洲av无码日韩av无码网站冲| 91精品免费久久久久久久久| 亚洲AV无码精品蜜桃| 四虎永久免费地址在线观看| 一区二区三区免费精品视频| 亚洲四虎永久在线播放| 免费电影在线观看网站| 亚洲欧洲自拍拍偷午夜色| 日本免费xxxx| 色欲aⅴ亚洲情无码AV| 精品亚洲综合在线第一区| jizz免费观看| 亚洲视频在线不卡| 免费观看在线禁片| 亚洲卡一卡二卡乱码新区| 久久精品国产精品亚洲下载| 1000部拍拍拍18免费网站| 香港一级毛片免费看|