自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

在服務器端動態(tài)生成gif或jpg示例

開發(fā) 后端
下面這段Java代碼可以實現(xiàn)在服務器端動態(tài)生成gif或jpg的功能。

本段代碼實現(xiàn)了在服務器端動態(tài)生成gif或jpg的功能:

package web.images;

/**
* 此處插入類型描述。
* @author:Administrator
*/
import java.io.*;

import java.util.*;

import com.sun.image.codec.jpeg.*;

import java.awt.image.*;

import java.awt.*;


public class ChartGraphics {

BufferedImage image;

public void createImage(String fileLocation) {

try {

FileOutputStream fos = new FileOutputStream(fileLocation);

BufferedOutputStream bos = new BufferedOutputStream(fos);

JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(bos);

encoder.encode(image);

bos.close();

} catch(Exception e) {

System.out.println(e);

}

}


public void graphicsGeneration(int h1,int h2,int h3,int h4,int h5) {


final int X=10;

int imageWidth = 800;//圖片的寬度

int imageHeight =900;//圖片的高度

int columnWidth=70;//柱的寬度

int columnHeight=800;//柱的最大高度


ChartGraphics chartGraphics = new ChartGraphics();

chartGraphics.image = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);

Graphics graphics = chartGraphics.image.getGraphics();

graphics.setColor(Color.white);

graphics.fillRect(0,0,imageWidth,imageHeight);

graphics.setColor(Color.black);
//graphics.setXORMode(Color.blue);
graphics.drawLine(columnWidth+X,columnHeight-h5-50,columnWidth+X,columnHeight);//Y軸

graphics.drawLine(columnWidth+X,columnHeight-h5-50,columnWidth+X-10,columnHeight-h5-40);//Y軸箭頭左

graphics.drawLine(columnWidth+X,columnHeight-h5-50,columnWidth+X+10,columnHeight-h5-40);//Y軸箭頭右

graphics.drawLine(750,columnHeight,columnWidth+X,columnHeight);//X軸

graphics.drawLine(750,columnHeight,740,columnHeight-10);//X軸

graphics.drawLine(750,columnHeight,740,columnHeight+10);//X軸

graphics.setColor(Color.yellow);

graphics.fillRect(X+1*columnWidth+10, columnHeight-h1, columnWidth, h1);

graphics.fillRect(X+2*columnWidth+20, columnHeight-h2, columnWidth, h2);

graphics.fillRect(X+3*columnWidth+30, columnHeight-h3, columnWidth, h3);

graphics.fillRect(X+4*columnWidth+40, columnHeight-h4, columnWidth, h4);

graphics.fillRect(X+5*columnWidth+50, columnHeight-h5, columnWidth, h5);

//graphics.drawString()

chartGraphics.createImage("D:\\leaderquery\\leaderqueryWeb\\web800\\images\\chart.jpg");

}

}

 

【編輯推薦】

  1. JavaOne 2009第三天:微軟與Sun/Oracle攜手并進
  2. 開發(fā)高可移植性J2ME的軟件
  3. Java虛擬機(JVM)中的內(nèi)存設(shè)置詳解
  4. JavaFX重裝上陣 加強Web領(lǐng)域開發(fā)
  5. 51CTO獨家報道:JavaFX即將帶來的感官之變
責任編輯:王觀 來源: 百家編程
相關(guān)推薦

2012-10-15 13:40:15

IBMdw

2013-12-25 11:01:16

JavaScript

2018-07-09 10:01:56

2014-01-15 10:06:30

vFlash

2014-11-14 11:03:56

微軟.NET

2023-06-30 08:00:00

漏洞網(wǎng)絡安全SSTI

2017-12-06 22:29:53

2011-06-07 16:01:46

Android 服務器 數(shù)據(jù)交互

2015-11-04 14:14:56

HTTP網(wǎng)絡協(xié)議

2010-01-08 13:48:51

JSON 形式

2009-02-16 16:30:23

OperaTurbo服務器

2010-04-21 13:18:33

RAC負載均衡配置

2010-05-27 18:49:38

SVN入門

2010-08-27 10:23:26

DHCP服務器

2021-07-27 06:14:32

服務器端移動端性能測試

2012-05-21 10:52:43

2009-07-27 12:56:27

控件CheckBoxLASP.NET服務器

2009-10-20 17:28:02

VB.NET服務器端

2010-10-15 08:57:15

PHP多進程

2009-07-06 17:22:54

JSP服務器
點贊
收藏

51CTO技術(shù)棧公眾號