真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

圖片生成java代碼 java編程代碼圖片

高分求java代碼,用來生成圖片文件!!

//defaultSuffix是jpg

創(chuàng)新互聯(lián)主要從事成都網(wǎng)站建設(shè)、成都網(wǎng)站制作、網(wǎng)頁設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)永興,十余年網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):18980820575

public static final boolean resizeImage(String fileName, String suffix) throws Exception {

boolean uploaded = false;

BufferedImage input;

if(suffix.equalsIgnoreCase("tif")||suffix.equalsIgnoreCase("tiff")||suffix.equalsIgnoreCase("png")) {

RenderedImage image = JAI.create("fileload", TurbineServlet.getRealPath(imageRoot + fileName+"."+suffix));

WritableRaster raster = image.copyData(null);

BufferedImage bi = new BufferedImage( image.getColorModel(), raster, true, null);

BufferedImage bi2 = new BufferedImage( maxResizeDimension, bi.getHeight()*maxResizeDimension/bi.getWidth(), BufferedImage.TYPE_INT_RGB);

Graphics2D g2 = bi2.createGraphics();

g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);

g2.setBackground(java.awt.Color.WHITE);//把tiff和png轉(zhuǎn)換后的背景設(shè)置為白色

g2.fillRect(0, 0, maxResizeDimension, bi.getHeight()*maxResizeDimension/bi.getWidth());

g2.drawImage(bi, 0, 0, maxResizeDimension, bi.getHeight()*maxResizeDimension/bi.getWidth(), null);

PlanarImage pi = PlanarImage.wrapRenderedImage(bi2);

JAI.create("FileStore", pi, TurbineServlet.getRealPath(resizeRoot + fileName+"."+defaultSuffix).replaceAll("\\\\","\\\\\\\\"), "JPEG", new JPEGEncodeParam());

input = pi.getAsBufferedImage();

int w = maxThumbDimension, h = maxThumbDimension;

BufferedImage output = new BufferedImage(w, h, BufferedImage.TYPE_3BYTE_BGR);

Graphics2D g = output.createGraphics();

g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);

g.drawImage(input,0,0,w,h, null);

ImageIO.write(output, defaultSuffix, new File(TurbineServlet.getRealPath(thumbRoot + fileName+"."+defaultSuffix)));

}

else {

input = ImageIO.read(new File(TurbineServlet.getRealPath(imageRoot + fileName+"."+suffix)));

int w = maxThumbDimension, h = maxThumbDimension;

BufferedImage output = new BufferedImage(w, h, BufferedImage.TYPE_3BYTE_BGR);

Graphics2D g = output.createGraphics();

g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);

g.drawImage(input,0,0,w,h, null);

ImageIO.write(output, defaultSuffix, new File(TurbineServlet.getRealPath(thumbRoot + fileName+"."+defaultSuffix)));

BufferedImage output2 = new BufferedImage(maxResizeDimension, input.getHeight()*maxResizeDimension/input.getWidth(), BufferedImage.TYPE_3BYTE_BGR);

Graphics2D g2 = output2.createGraphics();

g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);

g2.drawImage(input,0,0,maxResizeDimension, input.getHeight()*maxResizeDimension/input.getWidth(), null);

ImageIO.write(output2, defaultSuffix, new File(TurbineServlet.getRealPath(resizeRoot + fileName+"."+defaultSuffix)));

}

uploaded = true;

return uploaded;

}

跪求圖片生成器java全代碼,要求可以畫圖和獲取屏幕并且能保存。拜托各位大神了

正好寫了一個(gè),給你看看哈

import?java.awt.*;

import?java.awt.image.BufferedImage;

import?java.io.File;

import?java.util.Date;

import?javax.imageio.ImageIO;

public?class?ScreenCapturer?{

public?static?void?main(String[]?args)?throws?Exception{

Date?date?=?new?Date();

Robot?rbt?=?new?Robot();

BufferedImage?bf?=??rbt.createScreenCapture(new?Rectangle(1440,900));??//這是屏幕分辨率??可以根據(jù)自己的屏幕修改

File?file?=?new?File("d://"+?date.toString().replace("?","").replace(":","")+".jpg");??//這是保存路徑D盤根目錄

ImageIO.write(bf,"jpg",file);

System.out.println("截圖成功!保存于D盤根目錄下!時(shí)間:"?+?date.toString());

}

}

解析下這個(gè)生成圖片的Java代碼

1.調(diào)用"images"文件夾里的文件放在ImageIcon里顯示2.在windows下面顯示正常Java在圖形處理時(shí)調(diào)用了本地的圖形處理庫。在利用Java作圖形處理(比如:圖片縮放,圖片簽名,生成報(bào)表)時(shí),如果運(yùn)行在windows上不會(huì)出問題。如果將程序移植到Linux/Unix上的時(shí)候有可能出現(xiàn)圖形不能顯示的錯(cuò)誤。3.提示信息:"Can'tconnecttoX11windowserver"這是由于Linux的圖形處理需要一個(gè)XServer服務(wù)器。(關(guān)于Linux的圖形處理模式參考Tomcat的修改如下:打開%Tomcat_home%/bin/catalina.sh文件在文件的86%處,啟動(dòng)Tomcat的腳本中加上:-Djava.awt.headless=true/參考:"$_RUNJAVA"$JAVA_OPTS$CATALINA_OPTS/-Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS"-classpath"$CLASSPATH"/-Dcatalina.base="$CATALINA_BASE"/-Dcatalina.home="$CATALINA_HOME"/-Djava.io.tmpdir="$CATALINA_TMPDIR"/-Djava.awt.headless=true/org.apache.catalina.startup.Bootstrap"$@"start/"$CATALINA_BASE"/logs/catalina.out21if[!-z"$CATALINA_PID"];thenecho$!$CATALINA_PIDfifielif["$1"="stop"];then保存后,重新啟動(dòng)就可以處理圖形了。

有沒有通過UML圖自動(dòng)生成Java代碼的工具

常用的是StarUML,其他一些UML軟件,如Rational Rose都是可以的,即可正向生成,也可以逆向生成

從文件中讀取圖片和寫入圖片到文件里的java代碼是什么?

首先導(dǎo)入各種需要的包:

import java.awt.Image;

import javax.imageio.ImageIO;

import java.io.*;

讀取圖片的方法如下:

Image[] array = new Image[10];

Image image = ImageIO.read(new File("d:\\source.gif"));//根據(jù)你實(shí)際情況改文件路徑吧

array[0] = image;

圖片讀出來了。

如果你有一個(gè)Image對(duì)象,想把它寫入文件可以這樣做:

BufferedImage image = ImageIO.read(new File("d:\\source.gif"));

//要想保存這個(gè)對(duì)象的話你要把image聲明為BufferedImage 類型

ImageIO.write(image, "png", new File("f:\\test.png"));


本文題目:圖片生成java代碼 java編程代碼圖片
文章源于:http://weahome.cn/article/hghjps.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部