重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

java代码图片的生成 java 图片生成

高分求java代码,用来生成图片文件!!

//defaultSuffix是jpg

创新互联公司是一家专注于成都网站制作、成都做网站与策划设计,东至网站建设哪家好?创新互联公司做网站,专注于网站建设10年,网设计领域的专业建站公司;建站业务涵盖:东至等地区。东至做网站价格咨询:028-86922220

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转换后的背景设置为白色

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;

}

powerdesigner怎么用java代码生成类图

使用PowerDesigner软件逆向生成java类图的方法、步骤:1、打开PowerDesiger软件,点击文件-建立新模型,新建Obect-OrientedModel2、点击语言-ReverseEngineerJava,弹出反向生成类图设置窗口;3、在反向生成类图设置窗口中,选择ReverseEngineer,可以选择JavaFiles或JavaDirectories等,在这里我选择JavaDirectories;4、然后点击Add按钮添加目录,在这里我选择一个java源文件目录;5、点击确定,PowerDesigner会显示生成进度窗口,完成以后在PowerDesigner工作空间下会显示类图目录结构;6、到此便将选中的Java目录下的Java类文件生成了静态类结构,

解析下这个生成图片的Java代码

1.调用"images"文件夹里的文件放在ImageIcon里显示2.在windows下面显示正常Java在图形处理时调用了本地的图形处理库。在利用Java作图形处理(比如:图片缩放,图片签名,生成报表)时,如果运行在windows上不会出问题。如果将程序移植到Linux/Unix上的时候有可能出现图形不能显示的错误。3.提示信息:"Can'tconnecttoX11windowserver"这是由于Linux的图形处理需要一个XServer服务器。(关于Linux的图形处理模式参考Tomcat的修改如下:打开%Tomcat_home%/bin/catalina.sh文件在文件的86%处,启动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保存后,重新启动就可以处理图形了。


网页标题:java代码图片的生成 java 图片生成
文章网址:http://cqcxhl.cn/article/ddccpjj.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP