精华内容
下载资源
问答
  • Java后台生成图片并保存

    千次阅读 2019-01-11 23:07:33
    Java模拟ECG曲线,生成图片并进行保存步骤:①获取画板②获取画笔③获取坐标点 步骤: ①获取画板 ②获取画笔 ③获取坐标点 在这里插入代码片


    以波形信号为例
    步骤:
    ①获取画板
    ②获取画笔
    ③获取坐标点

    1、画板工具

    import java.awt.*;
    
    /**
     * 画板工具
     */
    
    public class MyPanel {
    
        public static final int XPOINT = 100;
        public static final int YPOINT = 100;
        private double[] dataSource ; //存放数据的数组
    
        public MyPanel(double[] dataSource,Graphics g) {
            this.dataSource = dataSource;
            paintComponent(g);
        }
    
        /**
         * 生成对应图片
         * @param g
         */
        public void paintComponent(Graphics g) {
            g.setColor(Color.black);
            g.fillRect(0, 0, ImageIOHandler.WIDTH, ImageIOHandler.HEIGHT);//设置图片尺寸
            g.setColor(Color.CYAN);
            g.drawLine(XPOINT, ImageIOHandler.HEIGHT - YPOINT, XPOINT, YPOINT);//画Y轴
            g.drawLine(XPOINT,ImageIOHandler.HEIGHT/2, ImageIOHandler.WIDTH - XPOINT, ImageIOHandler.HEIGHT/2);//画X轴
            //储存曲线上所有点的x坐标
            int[] xx = new int[dataSource.length];
            //储存曲线上所有点的y坐标
            int[] yy = new int[dataSource.length];
            //对坐标数据进行赋值
            for (int i = 0; i < dataSource.length; i++) {
                xx[i] = i+XPOINT;//x轴坐标
                yy[i] = round(dataSource[i]);//y轴坐标,电压值
            }
            Graphics2D g2d = (Graphics2D) g;
            g2d.setColor(Color.red);//设置曲线颜色
            g2d.drawPolyline(xx, yy, dataSource.length);//画曲线
            g.dispose();//绘制图形
        }
    
        //将double类型转换为int类型,并对生成曲线的位置进行校正
        public int round(double data) {
    		//先转化电压值,之后再对图像位置进行调整
            return ((int)(-data*500) + ImageIOHandler.HEIGHT/2);
        }
    
    }
    

    2、画笔工具类

    import javax.imageio.ImageIO;
    import java.awt.*;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;
    
    /**
     * 将心电数据在后台输出为png格式
     */
    public class ImageIOHandler {
    
        public static final int WIDTH = 5200;   //生成图片的宽度,单位是像素值
        public static final int HEIGHT = 1000;  //生成图片的高度,单位是像素值
    
        /**
         * 创建一个BufferedImage图片缓冲区对象并指定它宽高和类型 这样相当于创建一个画板,然后可以在上面画画
         */
        BufferedImage bi = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_BGR);
    
        /**
         * 要生成图片的类型,可以是JPG GIF JPEG PNG等...
         */
        final String picType = "png";
    
        /**
         * 成生成图片的保存路径和图片名称
         */
        final File file = new File("." + picType);
    
        /**
         * 通过指定参数写一个图片,并保存
         *
         * @param bi        图片缓冲流名称
         * @param picType   保存图片格式
         * @param file      保存图片的文件
         * @return boolean 如果失败返回一个布尔值
         */
        public static boolean writeImage(BufferedImage bi, String picType, File file) {
             //拿到画笔
            Graphics g = bi.getGraphics();
    
            //获取数据
            ECGData data = new ECGData();
    
            //实例化MyPanel对象,进行图片生成
            MyPanel myPanel = new MyPanel(data.getData(),g);
    
            boolean val = false;
    
            //输出为图片
            try {
                val = ImageIO.write(bi, picType, file);
            } catch (IOException e) {
                e.printStackTrace();
            }
            return val;
        }
    }
    

    3、模拟数据

    /**
     * 模拟心电数据,单位mv
     */
    public class ECGData {
    	/**
    	 * 心电数据数组
    	 */
        private double[] data = {0.0130192,0.0618412,0.144839,0.247365,0.360469,0.474387,0.581796,0.676185,0.7543,0.814514,0.85764,0.878796,0.878796,0.858454,0.822651,0.773829,0.715242,0.649333,0.579354,0.509376,0.440212,0.375116,0.315716,0.261198,0.214003,0.172504,0.135888,0.104154,0.0756741,0.0512631,0.0309206,0.0170877,0.0089507,0.0040685,0,-0.0056959,-0.0138329,-0.0227836,-0.0333617,-0.0439398,-0.0553316,-0.0675371,-0.0789289,-0.0886933,-0.0968303, -0.102526,-0.106595,-0.109849,-0.109849,
    		-0.105781,-0.0984577,-0.0870659,-0.0724193,-0.0545179,-0.0341754,-0.0146466,0,0.0089507,0.0113918,0.008137,0.0016274,-0.0065096,-0.0154603,-0.0227836,-0.0268521,-0.0292932,-0.0301069,-0.0317343,-0.0349891,0.0390576,-0.0423124,-0.0447535,-0.0439398,-0.040685,-0.0333617,-0.0235973,-0.0138329,-0.0065096,-0.0024411,-0.0008137,-0.0016274,-0.0065096,-0.0154603,-0.0284795,-0.0439398,-0.0610275,-0.0764878,-0.089507,-0.0984577,-0.10334,-0.106595,-0.109036,-0.111477,-0.113918,-0.117173,-0.124496,-0.135888,-0.152162,-0.171691,-0.192847,-0.211562,-0.226209,-0.236787,-0.243296,-0.244924,-0.241669,-0.234346,-0.226209,-0.219699,-0.216444,-0.216444,-0.219699,-0.227022,-0.240041,-0.255502,-0.273403,-0.290491,-0.304324,-0.311647,-0.312461,-0.306765,-0.297814,-0.285609,-0.275031,-0.268521,-0.26608,-0.266894,-0.267707,-0.268521,-0.267707,-0.262825,-0.253061,-0.238414,-0.221326,-0.205052,-0.193661,-0.187965,-0.187151,-0.187965,-0.190406,-0.192847,-0.195288,-0.197729,-0.20017,-0.20017,-0.197729,-0.192033,-0.183896,-0.171691,-0.15623,-0.139956,-0.124496,-0.112291,-0.104967,-0.104967,-0.109849,-0.116359,-0.123682,-0.131819,-0.141584,-0.149721,-0.154603,-0.15623,-0.153789,-0.149721,-0.142397,-0.135074,-0.129378,-0.129378,-0.136702,-0.148093,-0.159485,-0.166809,-0.16925,-0.166809,-0.16274,-0.158671,-0.15623,-0.154603,-0.152976,-0.152976,-0.154603,-0.157044,-0.157858,-0.15623,-0.153789,-0.149721,-0.146466,-0.143211,-0.139956,-0.141584,-0.148093,-0.157858,-0.167622,-0.174946,-0.176573,-0.173318,-0.166809,-0.15623,-0.146466,-0.136702,-0.129378,-0.124496,-0.12531,-0.129378,-0.133447,-0.138329,-0.142397,-0.142397,-0.137515,-0.126124,-0.112291,-0.101713,-0.0992714,-0.104154,-0.113104,-0.121241,-0.126937,-0.127751,-0.124496,-0.116359,-0.104154,-0.0935755,-0.0886933,-0.0903207,-0.0968303,-0.105781,-0.113918,-0.117987,
    		-0.117987,-0.113918,-0.104154,-0.0911344,-0.0781152,-0.0707919,-0.0699782,-0.0707919,-0.0724193,-0.0740467,-0.0789289,-0.0911344,-0.106595,-0.122055,-0.127751,-0.122055,-0.109036,-0.0935755,-0.0805563,-0.0699782,-0.0626549,-0.0594001,-0.0594001,-0.0634686,-0.0707919,-0.0805563,-0.0919481,-0.102526,-0.106595,-0.104154,-0.0968303,-0.0886933,-0.0805563,-0.073233,-0.0667234,-0.0610275,-0.0594001,-0.0602138,-0.0634686,-0.0667234,-0.073233,-0.0805563,-0.0838111,-0.0797426,-0.0667234,-0.0496357,-0.0341754,-0.0235973,-0.0170877,-0.0130192,-0.0089507,-0.008137,-0.0113918,-0.0146466,-0.016274,-0.0138329,-0.0065096,0.0056959,0.0219699,0.0374302,0.0512631,0.0634686,0.0748604,0.0805563,0.0764878,0.0642823,0.0504494,0.0414987,0.0382439,0.0414987,0.0504494,0.0626549,0.0748604,0.0838111,0.0870659,0.0870659,0.0878796,0.0903207,0.0935755,0.0968303,0.100085,0.102526,0.10334,0.100085,0.0960166,0.0935755,0.0935755,0.0927618,0.0911344,0.0870659,0.0821837,0.0773015,0.0716056,0.0659097,0.0626549,0.0618412,0.0618412,0.0618412,0.0626549,0.0618412,0.0594001,0.0545179,0.048822,0.0431261,0.0390576,0.0366165,0.0366165,0.0390576,0.0431261,0.0504494,0.0577727,0.0634686,0.0659097,0.0675371,0.0707919,0.0756741,0.0797426,0.0821837,0.0805563,0.0764878,0.0724193,0.0691645,0.0667234,0.065096,0.0618412,0.0594001,0.0602138,0.0659097,0.0781152,0.0992714,0.132633,0.180641,0.241669,0.31002,0.377557,0.439398,0.492289,0.534601,0.564708,0.577727,0.571217,0.542738,0.497984,0.445908,0.393017,0.345823,0.308392,0.28154,0.262825,0.25062,0.241669,0.233532,0.223768,0.211562,0.198543,0.183896,0.170063,0.154603,0.138329,0.122869,0.108222,0.097644,0.089507,0.0829974,0.0781152,0.0740467,0.0699782,0.0675371,0.0642823,0.0618412,0.0602138,0.0577727,0.0553316,0.0528905,0.0504494,0.048822,0.0480083,0.0480083,0.0471946,0.0463809,0.0439398,0.0431261,0.0423124,0.0431261,0.0439398,0.0463809,0.0471946,0.0471946,0.0447535,0.0423124,0.0390576,0.0374302,0.0366165,0.0366165,0.0374302,0.0374302,0.0366165,0.0349891,0.0333617,0.0309206,0.0268521,0.0235973,0.0211562,0.0187151,0.0179014,0.0179014,0.0187151,0.0187151,0.0187151,0.0195288,0.0203425,0.0211562,0.0227836,0.0252247,
    		0.0284795,0.0309206,0.0333617,0.0358028,0.0374302,0.0398713,0.0431261,0.0455672,0.048822,0.0512631,0.0528905,0.0553316,0.056959,0.0585864,0.0585864,0.0585864,0.0602138,0.0634686,0.0659097,0.0683508,0.0707919,0.073233,0.0748604,0.0756741,0.0764878,0.0756741,0.0748604,0.0748604,0.0756741,0.0781152,0.0805563,0.0821837,0.0821837,0.0805563,0.0781152,0.0748604,0.0716056,0.0691645,0.0683508,0.0667234,0.0659097,0.065096,0.0634686,0.0610275,0.0577727,0.0545179,0.0520768,0.0512631,0.0512631,0.0512631,0.0504494,0.048822,0.0463809,0.0431261,0.0398713,0.0349891,0.0301069,0.024411,0.0187151,0.0138329,0.0097644,0.0065096,0.0032548,0,-0.0032548,-0.008137,-0.0130192,-0.0170877,-0.0211562,-0.0252247,-0.0292932,-0.0333617,-0.0366165,-0.0390576,-0.0423124,-0.0471946,-0.0528905,-0.0577727,-0.0610275,-0.0626549,-0.065096,-0.0675371,-0.0707919,-0.0740467,-0.0764878,-0.0781152,-0.0781152,-0.0773015,-0.0764878,-0.0756741,-0.0764878,-0.0789289,-0.08137,-0.0838111,-0.0846248,-0.0838111,-0.08137,-0.0789289,-0.0773015,-0.0764878,-0.0764878,-0.0756741,-0.0748604,-0.0740467,-0.0724193,-0.0724193,-0.0724193,-0.073233,-0.0740467,-0.0764878,-0.0764878,-0.0756741,-0.073233,-0.0707919,-0.0691645,-0.0683508,-0.0675371,-0.0683508,-0.0691645,-0.0675371,-0.0667234,-0.065096,-0.0642823,-0.0634686,-0.0626549,-0.0610275,-0.0602138,-0.0602138,-0.0610275,-0.0634686,-0.0642823,-0.0626549,-0.0602138,-0.0585864,-0.056959,-0.0545179,-0.0520768,-0.0504494,-0.048822,-0.0480083,-0.0480083,-0.0471946,-0.0463809,-0.0447535,-0.0431261,-0.0414987,-0.0398713,-0.0374302,-0.0358028,-0.0333617,-0.0317343,-0.0292932,-0.0276658,-0.0252247,-0.0219699,-0.0179014,-0.0138329,-0.0105781,-0.0065096,-0.0016274,0.0016274,0.0048822,0.0073233,0.0089507,0.0097644,0.0089507,0.0073233,0.0065096,0.0065096,0.0065096,0.0056959,0.0040685,0.0040685,0.0048822,0.0056959,0.0073233,0.0105781,0.0154603,0.0203425,0.0235973,0.0260384,0.0276658,0.0268521,0.0252247,0.0235973,0.0219699,0.0211562,0.0195288,0.0170877,0.0146466,0.0122055,0.0105781,0.008137,0.0056959,0.0008137,-0.0040685,-0.0105781,-0.0170877,-0.0235973,-0.0301069,-0.0358028,-0.040685,-0.0455672,-0.0504494,-0.0537042,-0.0545179,-0.0545179,-0.0545179,-0.0545179,-0.0545179,-0.0553316,-0.0561453,-0.056959,-0.0577727,-0.056959,-0.056959,-0.0561453,-0.0545179,-0.0537042,-0.0528905,-0.0528905,-0.0537042,-0.0561453,-0.0577727,-0.0585864,-0.0585864,-0.0594001,-0.0626549,-0.0675371,-0.0699782,-0.0683508,-0.0594001,-0.0423124,-0.0138329,0.0268521,0.08137,0.14728,0.218885,0.289677,0.355587,0.412546,0.45974,0.491475,
    		0.506121,0.499612,0.468691,0.418242,0.357214,0.297,0.246551,0.207493,0.1782,0.155417,0.135888,0.117987,0.0984577,0.0797426,0.0610275,0.0447535,0.0301069,0.016274,0.0040685,-0.0056959,-0.0154603,-0.0235973,-0.0301069,-0.0341754,-0.0374302,-0.040685,-0.0447535,-0.0496357,-0.0537042,-0.0561453,-0.056959,-0.0577727,-0.056959,-0.056959,-0.056959,-0.056959,-0.0585864,-0.0594001,-0.0618412,-0.0634686,-0.0634686,-0.0626549,-0.0618412,-0.0602138,-0.0585864,-0.056959,-0.0553316,-0.0545179,-0.0537042,-0.0528905,-0.0512631,-0.048822,-0.0455672,-0.0431261,-0.0423124,-0.0414987,-0.040685,-0.0398713,-0.0390576,-0.0382439,-0.0374302,-0.0366165,-0.0358028,-0.0333617,-0.0309206,-0.0284795,-0.0252247,-0.024411,-0.024411,-0.0252247,-0.0252247,-0.0235973,-0.0211562,-0.0187151,-0.016274,-0.0138329,-0.0130192,-0.0122055,-0.0130192,-0.0138329,-0.0146466,-0.016274,-0.0170877,-0.0170877,-0.0179014,-0.0187151,-0.0195288,-0.0211562,-0.0211562,-0.0211562,-0.0203425,-0.0179014,-0.0154603,-0.0138329,-0.0122055,-0.0122055,-0.0122055,-0.0138329,-0.0154603,-0.0170877,-0.0179014,-0.0187151,-0.0187151,-0.0179014,-0.016274,-0.0146466,-0.0122055,-0.0105781,-0.0089507,-0.008137,-0.0073233,-0.0073233,-0.008137,-0.008137,-0.0073233,-0.0048822,-0.0016274,0.0008137,0.0040685,0.0056959,0.0073233,0.0073233,0.0065096,0.0048822,0.0040685,0.0032548,0.0032548,0.0032548,0.0048822,0.0056959,0.0065096,0.0056959,0.0048822,0.0032548,0.0008137,-0.0016274,-0.0040685,-0.0073233,-0.0097644,-0.0113918,-0.0122055,-0.0130192,-0.0146466,-0.0154603,-0.016274,-0.016274,-0.0170877,-0.0195288,-0.0219699,-0.0235973,-0.024411,-0.0260384,-0.0268521,-0.0276658,-0.0276658,-0.0284795,-0.0284795,-0.0284795,-0.0292932,-0.0309206,-0.0333617,-0.0358028,-0.0366165,-0.0358028,-0.0349891,-0.0358028,-0.0366165,-0.0374302,-0.0382439,
    		-0.0382439,-0.0374302,-0.0374302,-0.0374302,-0.0390576,-0.0414987,-0.0439398,-0.0447535,-0.0447535,-0.0447535,-0.0439398,-0.0439398,-0.0431261,-0.0439398,-0.0447535,-0.0463809,-0.0471946,-0.0471946,-0.0480083,-0.0480083,-0.0480083,-0.0480083,-0.0480083,-0.048822,-0.0496357,-0.0504494,-0.0520768,-0.0520768,-0.0520768,-0.0504494,-0.0480083,-0.0455672,-0.0431261,-0.0398713,-0.0366165,-0.0333617,-0.0292932,-0.024411,-0.0195288,-0.0146466,-0.0089507,-0.0032548,0.0024411,0.0065096,0.008137,0.0097644,0.0113918,0.0130192,0.0146466,0.0154603,0.016274,0.016274,0.0170877,0.0170877,0.016274,0.016274,0.016274,0.0170877,0.0195288,0.0227836,0.0252247,0.0276658,0.0292932,0.0309206,0.0333617,0.0349891,0.0358028,0.0349891,0.032548,0.0292932,0.0260384,0.0227836,0.0195288,0.016274,0.0138329,0.0113918,0.0089507,0.0056959,0,-0.0056959,-0.0122055,-0.0187151,-0.024411,-0.0284795,-0.0317343,-0.0349891,-0.0374302,-0.0382439,-0.0358028,-0.0317343,-0.0260384,-0.0179014,-0.0097644,-0.0008137,0.0056959,0.0105781,0.0138329,0.0146466,0.0138329,0.0097644,0.0040685,-0.0032548,-0.0130192,-0.0227836,-0.0341754,-0.0447535,-0.0528905,-0.0594001,-0.0634686,-0.0659097,-0.0683508,-0.0707919,-0.0716056,-0.0683508,-0.0585864,-0.0423124,-0.0170877,0.0187151,0.0675371,0.127751,0.193661,0.260384,0.323853,0.381625,0.433702,0.476828,0.506935,0.519141,0.509376,0.476828,0.427193,0.371861,0.320598,0.275844,0.2376,0.204239,0.174946,0.148907,0.12531,0.10334,0.0862522,0.0756741,0.0683508,0.0626549,0.056959,0.0504494,0.0423124,0.032548,0.0211562,0.0089507,-0.0024411,-0.0138329,-0.0235973,-0.0301069,-0.0333617,-0.032548,-0.0276658,-0.0203425,-0.0113918,-0.0040685,0,0.0016274,0.0008137,0,-0.0032548,-0.008137,-0.016274,-0.0276658,-0.0390576,-0.0496357,-0.056959,-0.0602138,-0.0577727,-0.0528905,-0.0447535,-0.0374302,-0.0309206,-0.0252247,-0.0211562,-0.0195288,-0.0195288,-0.0227836,-0.0284795,-0.0366165,-0.0439398,-0.048822,-0.0512631,-0.0512631,-0.048822,-0.0447535,-0.0414987,-0.040685,-0.0439398,-0.048822,-0.0545179,-0.0602138,-0.0634686,-0.0634686,-0.0594001,-0.0512631,-0.0414987,-0.032548,-0.0284795,-0.0301069,-0.0358028,-0.0414987,-0.0463809,-0.0496357,-0.0520768,-0.0512631,-0.0480083,-0.0414987,
    		-0.032548,-0.0219699,-0.0105781,-0.0032548,0,-0.0016274,-0.0073233,-0.016274,-0.0268521,-0.0349891,-0.0390576,-0.0390576,-0.0358028,-0.0284795,-0.0203425,-0.0130192,-0.0089507,-0.0073233,-0.0065096,-0.0073233,-0.008137,-0.0065096,-0.0016274,0.0024411,0.0073233,0.0122055,0.016274,0.0195288,0.0211562,0.0203425,0.0179014,0.0146466,0.0097644,0.0065096,0.0048822,0.0024411,0.0016274,0.0040685,0.0122055,0.0235973,0.0317343,0.0333617,0.0292932,0.0219699,0.016274,0.0138329,0.0154603,0.0195288,0.0292932,0.040685,0.0528905,0.0602138,0.0626549,0.0602138,0.0545179,0.0463809,0.0390576,0.032548,0.0252247,0.0170877,0.0113918,0.0073233,0.0048822,0.0008137,-0.0040685,-0.0089507,-0.0130192,-0.0146466,-0.0122055,-0.0097644,-0.0089507,-0.0097644,-0.0113918,-0.0138329,-0.0179014,-0.0211562,-0.0219699,-0.0203425,-0.0170877,-0.0122055,-0.0073233,-0.0024411,-0.0008137,-0.0008137,-0.0008137,0,0,0,-0.0008137,0.0008137,0.0048822,0.0089507,0.0122055,0.0146466,0.0179014,0.0235973,0.0349891,0.0537042,0.0773015,0.0984577,0.110663,0.112291,0.104967,0.0927618,0.0764878,0.0520768,0.0138329,-0.0431261,-0.120428,-0.207493,-0.289677,-0.357214,-0.40685,-0.437771,-0.449976,-0.445908,-0.429634,-0.406036,-0.379998,-0.358028,-0.338499,-0.323853,-0.315716,-0.314088,-0.318157,-0.32548,-0.332803,-0.339313,-0.343381,-0.345009,-0.344195,-0.340127,-0.332803,-0.32548,-0.317343,-0.304324,-0.283981,-0.257129,-0.227836,-0.197729,-0.167622,-0.136702,-0.104154,-0.0724193,-0.0455672,-0.0276658,-0.0203425,-0.0203425,-0.0252247,-0.0284795,-0.0301069,-0.0292932,-0.0268521,-0.0227836,-0.0203425,
    		-0.0179014,-0.0146466,-0.0113918,-0.0089507,-0.0097644,-0.0122055,-0.0138329,-0.0130192,-0.0113918,-0.0089507,-0.0056959,-0.0032548,-0.0024411,-0.0016274,-0.0008137,0,0,0.0016274,0.0048822,0.0073233,0.0089507,0.0097644,0.0097644,0.0122055,0.0170877,0.0252247,0.0349891,0.0447535,0.0528905,0.056959,0.0561453,0.0512631,0.0455672,0.0398713,0.0366165,0.0382439,0.0447535,0.0545179,0.0659097,0.0781152,0.0878796,0.0935755,0.097644,0.101713,0.108222,0.115545,0.122869,0.129378,0.136702,0.146466,0.157044,0.165995,0.170877,0.174132,0.1782,0.182269,0.18471,0.18471,0.183083,0.180641,0.179828,0.181455,0.187151,0.195288,0.205866,0.215631,0.225395,0.235973,0.247365,0.255502,0.25957,0.257943,0.252247,0.242483,0.232718,0.223768,0.218072,0.211562,0.204239,0.196102,0.189592,0.186337,0.183896,0.182269,0.1782,0.16925,0.15623,0.139956,0.122869,0.108222,0.0960166,0.0878796,0.0829974,0.0781152,0.0724193,0.065096,0.056959,0.0496357,0.0423124,0.0374302,0.0341754,0.0341754,0.0333617,0.0301069,0.0260384,0.0195288,0.0122055,0.0040685,-0.0016274,-0.0065096,-0.0105781,-0.0138329,-0.0170877,-0.0195288,-0.0227836,-0.0260384,-0.0284795,-0.0309206,-0.0333617,-0.0358028,-0.0374302,-0.0390576,-0.040685,-0.0414987,-0.0423124,-0.0414987,-0.040685,-0.0398713,-0.0390576,-0.0382439,-0.0374302,-0.0358028,-0.0341754,-0.0333617,-0.0317343,-0.0309206,-0.0301069,-0.0292932,-0.0292932,-0.0292932,-0.0292932,-0.0309206,-0.0333617,-0.0349891,-0.0374302,-0.040685,-0.0423124,-0.0447535,-0.0463809,-0.048822,-0.048822,-0.0471946,-0.0447535,-0.0423124,
    		-0.040685,-0.0398713,-0.0398713,-0.0414987,-0.0423124,-0.0431261,-0.0439398,-0.0439398,-0.0455672,-0.0471946,-0.048822,-0.0504494,-0.0512631,-0.0520768,-0.0528905,-0.0537042,-0.0545179,-0.0545179,-0.0545179,-0.0537042,-0.0528905,-0.0528905,-0.0553316,-0.0585864,-0.0610275,-0.0626549,-0.0634686,-0.0634686,-0.0634686,-0.0618412,-0.0602138,-0.0585864,-0.056959,-0.056959,-0.0561453,-0.056959,-0.0594001,-0.0626549,-0.0659097,-0.0675371,-0.0683508,-0.0667234,-0.0626549,-0.0577727,-0.0520768,-0.0480083,-0.0431261,-0.0390576,-0.0349891,-0.0317343,-0.0292932,-0.0292932,-0.0301069,-0.0309206,-0.0309206,-0.0284795,-0.0252247,-0.0211562,-0.016274,-0.0113918,-0.0065096,-0.0024411,0,0.0008137,0,-0.0008137,-0.0040685,-0.0089507,-0.0146466,-0.0203425,-0.0268521,-0.0333617,-0.0390576,-0.0431261,-0.0447535,-0.0455672,-0.0447535,-0.0463809,-0.048822,-0.0528905,-0.0577727,-0.0626549,-0.0659097,-0.0699782,-0.0740467,-0.0805563,-0.0870659,-0.0919481,-0.0927618,-0.0878796,-0.0748604,-0.0520768,-0.0154603,0.0349891,0.0984577,0.167622,0.235159,0.297814,0.353146,0.398713,0.432888,0.45079,0.449976,0.428006,0.386508,0.333617,0.279099,0.231091,0.192847,0.164367,0.143211,0.126937,0.112291,0.0968303,0.0789289,0.0602138,
    		0.0423124,0.0252247,0.0089507,-0.0048822,-0.0179014,-0.0301069,-0.040685,-0.048822,-0.0561453,-0.0610275,-0.0659097,-0.0707919,-0.0748604,-0.0781152,-0.0797426,-0.08137,-0.0829974,-0.0829974,-0.08137,-0.0789289,-0.0764878,-0.0764878,-0.0781152,-0.0797426,-0.0821837,-0.0838111,-0.0846248,-0.0846248,-0.0838111,-0.0821837,-0.0797426,-0.0781152,-0.0764878,-0.0756741,-0.0748604,-0.073233,-0.0716056,-0.0699782,-0.0691645,-0.0675371,-0.0667234,-0.0659097,-0.065096,-0.065096,-0.065096,-0.065096,-0.065096,-0.065096,-0.0634686,-0.0618412,-0.0594001,-0.0585864,-0.0577727,-0.0577727,-0.0561453,-0.0553316,-0.0545179,-0.0545179,-0.0553316,-0.0553316,-0.0528905,-0.0504494,-0.048822,-0.0463809,-0.0431261,-0.0398713,-0.0366165,-0.0341754,-0.0317343,-0.0284795,-0.0260384,-0.0235973,-0.0211562,-0.0195288,-0.0195288,-0.0195288,-0.0195288,-0.0187151,-0.0179014,-0.016274,-0.0138329,-0.0122055,-0.0105781,-0.0089507,-0.008137,-0.008137,-0.008137,-0.008137,-0.008137,-0.0073233,-0.0065096,-0.0056959,-0.0056959,-0.0056959,-0.0065096,-0.0065096,-0.0065096,-0.0056959,-0.0056959,-0.0065096,-0.008137,-0.0097644,-0.0097644,-0.008137,-0.0073233,-0.0073233,-0.0073233,-0.0056959,-0.0048822,-0.0040685,-0.0040685,-0.0048822,-0.0048822,-0.0040685,
    		-0.0040685,-0.0048822,-0.0073233,-0.0097644,-0.0113918,-0.0113918,-0.0122055,-0.0130192,-0.0138329,-0.0146466,-0.0154603,-0.0170877,-0.0179014,-0.0195288,-0.0211562,-0.0211562,-0.0211562,-0.0211562,-0.0219699,-0.0227836,-0.0235973,-0.0252247,-0.0260384,-0.0268521,-0.0268521,-0.0268521,-0.0268521,-0.0276658,-0.0292932,-0.0309206,-0.0301069,-0.0276658,-0.0252247,-0.0235973,-0.0235973,-0.024411,-0.0252247,-0.0260384,-0.0276658,-0.0301069,-0.0317343,-0.0317343,-0.0309206,-0.0309206,-0.0309206,-0.0317343,-0.0333617,-0.0341754,-0.0349891,-0.0349891,-0.0358028,-0.0366165,-0.0374302,-0.0374302,-0.0366165,-0.0358028,-0.0358028,-0.0374302,-0.0390576,-0.0414987,-0.0439398,-0.0463809,-0.0480083,-0.0496357,-0.0504494,-0.0520768,-0.0512631,-0.0504494,-0.0496357,-0.048822,-0.048822,-0.0480083,-0.0480083,-0.0480083,-0.048822,-0.0504494,-0.0512631,-0.0504494,-0.048822,-0.0480083,-0.0471946,-0.0471946,-0.0463809,-0.0455672};
    
    
        public double[] getData() {
            return data;
        }
    }
    
    

    4、测试类

    /**
     * 模拟心电图的生成
     */
    public class Test {
        public static void main(String[] args) {
            ImageIOHandler image = new ImageIOHandler();
            image.writeImage(image.bi, image.picType, image.file);
        }
    }
    

    5、最终效果图(简易)

    ecg图

    展开全文
  • Java生成图片

    千次阅读 2019-02-22 10:46:35
    今天项目中需要用到Java后台生成图片,于是研究了一下 需求图片: Java代码(原谅我的变量取名都是汉语拼音,我这里只是一个demo): public class Demo01 { public static void main(String[] args) throws ...

    今天项目中需要用到Java后台生成图片,于是研究了一下

    需求图片:

     

    Java代码(原谅我的变量取名都是汉语拼音,我这里只是一个demo):

    public class Demo01 {
    
    	public static void main(String[] args) throws FileNotFoundException, IOException {
    
    		int width = 820; // 图片宽
    		int height = 600;// 图片高
    		String titleStr = "公司测试点";
    		String zhangdanzhouqiStr = "2019年2月1日至2019年2月28日"; // 账单周期
    		String zhangdantianshuStr = "85天"; // 账单天数
    		String bengedinggonglvStr = "1000KW";// 泵额定功率
    		String bengbianpingjienengyunxingyongdianliangStr = "100度"; // 泵变频节能运行用电量
    		String dianjiaStr = "100元/度"; // 电价
    		String pingjunjienenglvStr = "50%";// 平均节能率
    		String daizhifujingeStr = "1000元"; // 待支付金额
    		String bengyunxingzongshichangStr = "200小时"; // 泵运行总时长
    		String benggongping运行yongdianliangStr = "99度"; // 泵工频运行用电量
    		String jieshengdianliangStr = "100度"; // 节省电量
    		String jieshengjineStr = "1000元"; // 节省金额
    
    		// 得到图片缓冲区
    		BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);// INT精确度达到一定,RGB三原色,高度70,宽度150
    
    		// 得到它的绘制环境(这张图片的笔)
    		Graphics2D g2 = (Graphics2D) bi.getGraphics();
    		g2.setColor(Color.WHITE); // 设置背景颜色
    		g2.fillRect(0, 0, width, height);// 填充整张图片(其实就是设置背景颜色)
    		g2.setColor(Color.black);// 设置字体颜色
    		g2.setStroke(new BasicStroke(2.0f)); // 边框加粗
    		g2.drawRect(1, 1, width - 2, height - 2); // 画边框就是黑边框
    
    		g2.drawLine(0, 80, 820, 80); // 从上到下第二个横线(标题下面横线)
    		g2.setStroke(new BasicStroke(0.0f)); // 边框不需要加粗
    		g2.drawLine(0, 154, 820, 154); // 从上到下第三个横线(账单周期下面横线)
    		g2.drawLine(0, 228, 820, 228); // 从上到下第四个横线(账单天数下面横线)
    		g2.drawLine(0, 302, 820, 302); // 从上到下第5个横线(泵额定功率下面横线)
    		g2.drawLine(0, 376, 820, 376); // 从上到下第6个横线(泵变频节能运行用电量下面横线)
    		g2.drawLine(0, 451, 820, 451); // 从上到下第7个横线(电价下面横线)
    		g2.drawLine(0, 525, 820, 525); // 从上到下第8个横线(平均节能率下面横线)
    
    		g2.drawLine(180, 80, 180, 600); // 从左到右第二个竖线
    		g2.drawLine(390, 154, 390, 451); // 从左到右第三个竖线
    		g2.drawLine(574, 154, 574, 451); // 从左到右第四个竖线
    
    		// 设置标题的字体,字号,大小
    		Font titleFont = new Font("宋体", Font.BOLD, 30);
    		g2.setFont(titleFont);
    		String markNameStr = titleStr;
    		g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // 抗锯齿
    		// 计算文字长度,计算居中的X点坐标
    		FontMetrics fm = g2.getFontMetrics(titleFont);
    		int titleWidth = fm.stringWidth(markNameStr);
    		int titleWidthX = (width - titleWidth) / 2 - 35;// 感觉不居中,向左移动35个单位
    		g2.drawString(markNameStr + "节能账单", titleWidthX, 45);
    
    		// 账单周期
    		g2.setFont(new Font("宋体", Font.BOLD, 20));
    		g2.drawString("账单周期", 33, 125);
    		// 账单周期的值
    		g2.drawString(zhangdanzhouqiStr, 230, 125);
    
    		// 账单天数
    		g2.drawString("账单天数", 33, 200);
    		// 账单天数的值
    		g2.drawString(zhangdantianshuStr, 230, 200);
    
    		// 泵额定功率
    		g2.drawString("泵额定功率", 33, 274);
    		// 泵额定功率
    		g2.drawString(bengedinggonglvStr, 230, 274);
    
    		// 泵变频节能运行用电量
    		g2.drawString("泵变频节能运", 33, 338);
    		g2.drawString("行用电量", 33, 360);
    		// // 泵变频节能运行用电量的值
    		g2.drawString(bengbianpingjienengyunxingyongdianliangStr, 230, 345);
    
    		// 电价
    		g2.drawString("电价", 33, 423);
    		// 电价的值
    		g2.drawString(dianjiaStr, 230, 423);
    
    		// 平均节能率
    		g2.drawString("平均节能率", 33, 496);
    		// 平均节能率
    		g2.drawString(pingjunjienenglvStr, 230, 496);
    
    		// 待支付金额
    		g2.drawString("待支付金额", 33, 568);
    		// 待支付金额的值
    		g2.drawString(daizhifujingeStr, 230, 568);
    
    		// 泵运行总时长
    		g2.drawString("泵运行总时长", 420, 200);
    		// 泵运行总时长的值
    		g2.drawString(bengyunxingzongshichangStr, 630, 200);
    
    		// 泵工频运行用电量
    		g2.drawString("泵工频运行用", 420, 265);
    		g2.drawString("电量", 420, 287);
    		// 泵工频运行用电量的值
    		g2.drawString(benggongping运行yongdianliangStr, 630, 274);
    
    		// 节省电量
    		g2.drawString("节省电量", 420, 348);
    		// 节省电量的值
    		g2.drawString(jieshengdianliangStr, 630, 345);
    
    		// 节省金额
    		g2.drawString("节省金额", 420, 423);
    		// 节省金额的值
    		g2.drawString(jieshengjineStr, 630, 423);
    
    		g2.dispose(); // 释放对象
    		ImageIO.write(bi, "JPEG", new FileOutputStream("D:/a.jpg"));// 保存图片 JPEG表示保存格式
    	}

    运行结果:

     

     

     

    展开全文
  • java后台生成echarts图表并保存图片

    万次阅读 热门讨论 2018-08-22 14:46:08
    需求:每天,每个月1号定时给用户发送邮件,邮件的内容是echarts的图片,这些全部都是定时器触发的,在后台生成echarts图片并保存到服务器,然后在发送邮件 网上其实已经有很多很多案例和方案解释,但有些是错误,...
    需求:每天,每个月1号定时给用户发送邮件,邮件的内容是echarts的图片,这些全部都是定时器触发的,在后台生成echarts图片并保存到服务器,然后在发送邮件

      网上其实已经有很多很多案例和方案解释,但有些是错误,或者不能满足我的需求.

       1,支持echart4.0最新版本.

       2,  支持上万条数据.网上只能查询几百条 然后拼接在cmd 命令中 而我采用java生成的optons  json数据写成文件.把文件地址拼装在cmd中

    js去读文件.

     

     3.下面会给出完整源码

     

    4.效果图

     

     

    第一步:java后台拼接option

     

     第二步:使用Java传cmd命令调用 PhantomJS生成echarts图片  (测试方法中option 是写死.)

    贴出部分源码:


    public class EchartGenerate {
    
        private static final String JSpath = "C:\\echarts-convert\\echarts-convert1.js";
        private static final Logger logger = Logger.getLogger(ReportUtils.class);
    
    
        public static void main(String[] args) {
            String imgName = "E:/temp/Echart/tes" + UUID.randomUUID().toString().substring(0, 4) + ".png ";
            String optiona = "{\"title\":{\"text\":\"电流图\",\"subtext\":\"电流图\",\"x\":\"left\"},\"toolbox\":{\"feature\":{\"saveAsImage\":{\"show\":true,\"title\":\"保存为图片\",\"type\":\"png\",\"lang\":[\"点击保存\"]}},\"show\":true},\"tooltip\":{\"trigger\":\"axis\"},\"legend\":{\"data\":[\"邮件营销\",\"联盟广告\",\"视频广告\"]},\"xAxis\":[{\"type\":\"category\",\"boundaryGap\":false,\"data\":[\"周一\",\"周二\",\"周三\",\"周四\",\"周五\",\"周六\",\"周日\"]}],\"yAxis\":[{\"type\":\"value\"}],\"series\":[{\"name\":\"邮件营销\",\"type\":\"line\",\"stack\":\"总量\",\"data\":[120,132,101,134,90,230,210]},{\"name\":\"联盟广告\",\"type\":\"line\",\"stack\":\"总量\",\"data\":[220,182,191,234,290,330,310]},{\"name\":\"视频广告\",\"type\":\"line\",\"stack\":\"总量\",\"data\":[150,232,201,154,190,330,410]}]}";
            //String options = "test";
            Map<String,Object> resultMap=new HashMap<>();
    
            generateEChart(optiona, resultMap);
    
        }
    
    
        public static String generateEChart(String options, Map<String,Object> resultMap) {
            String dataPath = writeFile(options);
            String fileName= "test-"+UUID.randomUUID().toString().substring(0, 8) + ".png";
            String path = "D:/temp/Echart/" +fileName;
            try {
                File file = new File(path);     //文件路径(路径+文件名)
                if (!file.exists()) {   //文件不存在则创建文件,先创建目录
                    File dir = new File(file.getParent());
                    dir.mkdirs();
                    file.createNewFile();
                }
                String cmd = "phantomjs " + JSpath + " -infile " + dataPath + " -outfile " + path;
                Process process = Runtime.getRuntime().exec(cmd);
                BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream()));
                String line = "";
                while ((line = input.readLine()) != null) {
                    logger.info(line);
                }
                input.close();
    
            } catch (IOException e) {
                e.printStackTrace();
            }finally{
                return path;
            }
        }
    
        public static String writeFile(String options) {
            String dataPath="D:\\chartData\\data"+ UUID.randomUUID().toString().substring(0, 8) +".json";
            try {
                /* 写入Txt文件 */
                File writename = new File(dataPath); // 相对路径,如果没有则要建立一个新的output.txt文件
                if (!writename.exists()) {   //文件不存在则创建文件,先创建目录
                    File dir = new File(writename.getParent());
                    dir.mkdirs();
                    writename.createNewFile(); // 创建新文件
                }
                BufferedWriter out = new BufferedWriter(new FileWriter(writename));
                out.write(options); // \r\n即为换行
                out.flush(); // 把缓存区内容压入文件
                out.close(); // 最后记得关闭文件
            } catch (IOException e) {
                e.printStackTrace();
            }
            return dataPath;
        }
    }

    第三部分 echarts-convert.js

    PhantomJS工具

     

     链接:https://pan.baidu.com/s/1NX9pf77SlEtU_QdKMn3_Ow 
    提取码:wli7 
     

    如有疑问,可以加群快速交流.929090540

     

     

    展开全文
  • // 生成二维码 文件地址 是否存在不存在则新增 File outputFile = new File(path); if(!outputFile.getParentFile().exists()){ outputFile.getParentFile().mkdirs(); } if(!outputFile.exists()){ output...

    需要引用的jar:

    <dependency>
        <groupId>com.google.zxing</groupId>
        <artifactId>core</artifactId>
        <version>3.3.0</version>
    </dependency>

    直接上代码类文件如下:

     

    package com.guardlbt.common.util;
    
    import com.google.zxing.BarcodeFormat;
    import com.google.zxing.EncodeHintType;
    import com.google.zxing.MultiFormatWriter;
    import com.google.zxing.common.BitMatrix;
    
    import javax.imageio.ImageIO;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.io.OutputStream;
    import java.util.Hashtable;
    
    public class MatrixToImageWriter {
    
        private static final int BLACK = 0xFF000000;
        private static final int WHITE = 0xFFFFFFFF;
        String rootPath = this.getClass().getResource("../../../../").getPath();
    
        private MatrixToImageWriter() {
        }
    
        public static BufferedImage toBufferedImage(BitMatrix matrix) {
            int width = matrix.getWidth();
            int height = matrix.getHeight();
            BufferedImage image = new BufferedImage(width, height,
                    BufferedImage.TYPE_INT_RGB);
            for (int x = 0; x < width; x++) {
                for (int y = 0; y < height; y++) {
                    image.setRGB(x, y, matrix.get(x, y) ? BLACK : WHITE);
                }
            }
            return image;
        }
    
        public static void writeToFile(BitMatrix matrix, String format, File file)
                throws IOException {
            BufferedImage image = toBufferedImage(matrix);
            if (!ImageIO.write(image, format, file)) {
                throw new IOException("Could not write an image of format "
                        + format + " to " + file);
            }
        }
    
        public static void writeToStream(BitMatrix matrix, String format,
                                         OutputStream stream) throws IOException {
            BufferedImage image = toBufferedImage(matrix);
            if (!ImageIO.write(image, format, stream)) {
                throw new IOException("Could not write an image of format " + format);
            }
        }
    
        public  static void  writePng(String path,String couponBatchCode) throws Exception{
            String text = couponBatchCode; // 二维码内容
            int width = 300; // 二维码图片宽度
            int height = 300; // 二维码图片高度
            String format = "png";// 二维码的图片格式
    
            Hashtable<EncodeHintType, String> hints = new Hashtable<EncodeHintType, String>();
            hints.put(EncodeHintType.CHARACTER_SET, "utf-8"); // 内容所使用字符集编码
    
            BitMatrix bitMatrix = new MultiFormatWriter().encode(text,
                    BarcodeFormat.QR_CODE, width, height, hints);
            // 生成二维码 文件地址 是否存在不存在则新增
            File outputFile = new File(path);
            if(!outputFile.getParentFile().exists()){
                outputFile.getParentFile().mkdirs();
            }
            if(!outputFile.exists()){
                outputFile.createNewFile();
            }
            MatrixToImageWriter.writeToFile(bitMatrix, format, outputFile);
        }
        public static void  writeTxt(String path,String couponBatchCode) throws Exception{
            String text = couponBatchCode; // 二维码内容
            File outputFile = new File(path);
            if(!outputFile.getParentFile().exists()){
                outputFile.getParentFile().mkdirs();
            }
            if(!outputFile.exists()){
                outputFile.createNewFile();
            }
            FileWriter fw=new FileWriter(outputFile);
            fw.write(text);
            fw.close();
        }
    
        public static void main(String[] args) throws Exception {
            String text="310055227524767";
            String path=new MatrixToImageWriter().rootPath+ File.separator +"31005"+File.separator+"QR"+File.separator+"31005_QR_"+text+".png";
            writePng(path,text);
            String path2=new MatrixToImageWriter().rootPath+ File.separator +"31005"+File.separator+"TXT"+File.separator+"31005_TXT_"+text+".txt";
            writeTxt(path2,text);
        }
    }
    
    展开全文
  • java html生成图片保存

    千次阅读 2016-05-06 15:54:15
    ...// Dimension d = new Dimension(Toolkit.getDefaultToolkit().getScreenSize());... (设置生成图片大小) 转载自:http://blog.csdn.net/luohaobubu/article/details/7414554 资源在百度云上~~~
  • java代码生成图片保存到本地

    千次阅读 2019-02-16 14:41:45
    图片写到实体图片里 try { ImageIO.write(bufferedImage, "jpg", file); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } // 2.将图片写到流里 ...
  • 开始生成 PosterUtils   public class PosterUtils { private static final String ACCESS_TOKEN = "微信小程序token"; public static String createPoster(String posterTitle, Long scene, String...
  • Java生成图片二维码下载

    千次阅读 2019-03-05 17:08:53
    // 使用比特矩阵画并保存图像 graphics.setColor(Color.BLACK); for (int i = 0; i ; i++){ for (int j = 0; j ; j++){ if (byteMatrix.get(i, j)){ graphics.fillRect(i, j, 1, 1); } } } /** * 将...
  • Java-生成验证码并保存到硬盘

    千次阅读 2020-03-31 05:15:15
    做课设时候,选择是做“图书借阅管理系统”。 在写登陆界面时候,想把前段时间学的web中生成验证码的知识用上... ,前者是生成,后者是读取,均可以在控制台打印验证码值 checkValue 。 CheckCode1234567891011121...
  • 前言: 最近公司有这样一个需求,对公司的统计数据使用图表进行展示,并且支持word导出,word文档中需要包含 思路分析: 首先看到图表,第一步就想到echarts或highcharts,但是我们一般使用...使用java生成echar...
  • java生成图片验证码

    千次阅读 2014-09-30 22:36:30
    package com.tantuls.login.controller; import java.awt.Color; import java.awt.Font; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java.io.IOException; import java.util.Random
  • 方法一、使用Graphics import java.awt.*; import java.awt.image.*; import javax.imageio.*; import java.io.*; public static void main(String[] args) { ...//图片的宽度 int imageHei
  • java读取、生成图片

    千次阅读 2017-10-03 13:09:10
    全栈工程师开发手册 (作者:栾鹏) ...java读取、生成图片测试代码 public static void main(String[] args) { BufferedImage bi=file2img("test.jpg"); //读取图片 img2file(bi,"jpg","test1.jpg"); //生成图片 }
  • 一般在生成验证码,有两种形式:...其实验证码也没有绝对的安全,只能说后端的处理方式比前端好一些而已,所以这个示例是利用java后台生成二维码图片返回给前端base64格式,展示给用户,后台将二维码真值保存在sess
  • 1.生成二维码 //生成二维码 @RequestMapping("/genTDC") public ModelAndView genTDC(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setDateHeader("Expires", 0); ...
  • Java生成图片红色问题

    2018-11-10 16:10:00
    Java上传图片时,对某些图片进行缩放、裁剪或者生成缩略图时会蒙上一层红色, 经过检查只要经过ImageIO.read()方法读取后再保存,该图片便已经变成红图。 因此,可以推测直接原因在于ImageIO.read()方法加载图片的...
  • import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; import java.net.URL; import java.net.URLConnection; public class DownloadImage { publi...
  • import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import jp.sourceforge.qrcode.QRCodeDecoder; import jp.so...
  • 前端 该插件使用方法很简单,直接...如果不出意外,那么你前端的签名应该会生成图片到后台相应到路径中来,值得一提的是后台代码用到了一个开源的库, apache batik ,使用之前别忘记引入哦,这里把地址也奉上吧: ...
  • 实现文章:... 博主就是使用了echarts-convert1.js和phantomjs-2.1.1通过cmd调用生成echarts再进行下载,里面使用了PhantomJS工具和echarts-convert.js 下载链接: 链接:https://pan.baidu.com/s...
  • java文字生成图片

    千次阅读 2016-06-24 18:04:30
    1.应用一 //测试生成图片 public void test01(){ int width = 100; int height = 100; String s = "你好"; File fi
  • 关于java生成图片验证码的问题

    千次阅读 2018-02-06 16:57:19
    今天在做图片验证码的时候出现了一个问题,在本地的环境上测试图片显示正常,验证码显示正常,但是部署到linux环境上,验证码图片中数字显示不出来,出现乱码情况,经过一天的研究发现问题出在以下: 在后台生成...
  • Java生成验证码进行验证

    万次阅读 多人点赞 2016-04-06 22:11:42
    使用Graphics来进行验证码图片的绘制,将绘制在图片上的验证码存放到session中用于后续验证 最后通过ImageIO将生成图片进行输出 通过页面提交的验证码和存放在session中的验证码对比来进行校验 二、生成验证码...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 118,921
精华内容 47,568
关键字:

java生成图片并保存

java 订阅