zoukankan
html css js c++ java
How to make a mask on a image
Code
1
import
java.awt.Color;
2
import
java.awt.Font;
3
import
java.awt.Graphics;
4
import
java.awt.Image;
5
import
java.awt.image.BufferedImage;
6
import
java.io.File;
7
import
java.io.FileOutputStream;
8
import
javax.imageio.ImageIO;
9
import
com.sun.image.codec.jpeg.JPEGCodec;
10
import
com.sun.image.codec.jpeg.JPEGImageEncoder;
11
{
/
codecitation}
12
{codecitation
class
=
"
java; gutter: true;
"
}
13
14
pressText(
"
www.ceapet.com
"
,fileName,
"
Arial
"
,
14
,
12
);
15
16
{
/
codecitation}
17
{codecitation
class
=
"
java; gutter: true;
"
}
18
public
static
void
pressText(String pressText, String targetImg,String fontName,
int
fontStyle,
int
fontSize)
19
{
20
try
{
21
File _file
=
new
File(targetImg);
22
Image src
=
ImageIO.read(_file);
23
int
width
=
src.getWidth(
null
);
24
int
height
=
src.getHeight(
null
);
25
BufferedImage image
=
new
BufferedImage(width, height,BufferedImage.TYPE_INT_RGB);
26
Graphics g
=
image.createGraphics();
27
g.drawImage(src,
0
,
0
, width, height,
null
);
28
//
String s="www.ceapet.com";
29
g.setColor(Color.BLACK);
30
g.setFont(
new
Font(fontName, fontStyle, fontSize));
31
g.drawString(pressText, width
-
100
, height
-
1
);
32
g.dispose();
33
FileOutputStream out
=
new
FileOutputStream(targetImg);
34
JPEGImageEncoder encoder
=
JPEGCodec.createJPEGEncoder(out);
35
encoder.encode(image);
36
out.close();
37
}
catch
(Exception ex)
{ex.printStackTrace();}
38
}
查看全文
相关阅读:
关于<form:select>
关于AJAX
关于Listener
分页显示数据----前端(将数据库中的信息分页显示到网页)
分页显示数据----后台(将数据库中的信息分页显示到网页)
关于Filter
Myeclise下tomcat启动报错,启动超时
启动tomcat一闪而过问题调试并解决
MyEclipse快捷键大全【转】
JSON和JS对象之间的互转【转】
原文地址:https://www.cnblogs.com/liuzhengdao/p/1579997.html
最新文章
nginx: [emerg] the "ssl" parameter requires ngx_http_ssl_module in /usr/local/nginx//conf/nginx.conf:117
nginx: [emerg] directive "location" has no opening "{" in /usr/local/nginx//conf/nginx.conf:75
时间复杂度
线性表
数据结构和算法的区别
顺序存储元素储存扩充
LTE学习之路(19)——HARQ Timing
LTE学习之路(18)——ACK/NACK Repetition
LTE学习之路(17)——TTI BUndling
LTE学习之路(16)——UL Grant
热门文章
LTE学习之路(15)——QCI
通信原理系列(2)——信道的概念
通信原理系列(1)——通信系统模型
通信原理系列(0)——开篇
LTE学习之路(14)——上下行调度
通信人必知的一些事
JSP的四个作用域
AOP 面向切面的编程
SpringMVC的REST风格的四种请求方式
使用SpringMVC实现文件上传和下载
Copyright © 2011-2022 走看看