<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

    最新評論

    閱讀排行榜

    主站蜘蛛池模板: 国产精品亚洲天堂| 亚洲精彩视频在线观看| 亚洲国产日韩a在线播放| 午夜视频在线免费观看| 99久久精品国产亚洲| 99视频在线看观免费| 免费在线看黄网站| 国产电影午夜成年免费视频| 亚洲AV成人精品日韩一区18p| 亚洲欧美日本韩国| 91香蕉在线观看免费高清| 亚洲精品国产精品乱码视色| 99在线视频免费观看| 亚洲爆乳无码一区二区三区| 免费一级毛片无毒不卡| 99亚洲精品高清一二区| 无人在线观看完整免费版视频| 在线精品亚洲一区二区| 久久免费国产精品一区二区| 久久精品7亚洲午夜a| 在线观看亚洲AV每日更新无码| 无码永久免费AV网站| 亚洲av无码成人精品国产| 中文字幕亚洲一区二区三区| 亚洲另类自拍丝袜第五页| 国产免费人视频在线观看免费| 亚洲视频免费播放| 最近中文字幕无吗免费高清| 91丁香亚洲综合社区| 国产成人免费a在线视频色戒| 四虎精品免费永久免费视频| 免费人成视频x8x8入口| 亚洲成AV人影片在线观看| 亚洲国产免费综合| 亚洲啪AV永久无码精品放毛片| 免费a级毛片无码av| 无码人妻一区二区三区免费看| 77777午夜亚洲| 国产啪亚洲国产精品无码| 日本h在线精品免费观看| 国产亚洲综合视频|