java技術(shù)研究
導(dǎo)航
BlogJava
首頁
新隨筆
聯(lián)系
聚合
管理
<
2012年4月
>
日
一
二
三
四
五
六
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
4
5
隨筆分類
java架構(gòu)(2)
(rss)
webwork(3)
(rss)
心情隨筆(4)
(rss)
軟件工程(1)
(rss)
隨筆檔案
2018年8月 (1)
2016年6月 (1)
2016年4月 (1)
2016年1月 (1)
2015年10月 (3)
2015年4月 (2)
2015年3月 (1)
2014年10月 (8)
2014年8月 (1)
2014年3月 (8)
2014年2月 (3)
2013年12月 (4)
2013年9月 (1)
2013年8月 (2)
2013年7月 (1)
2013年6月 (3)
2013年4月 (3)
2013年2月 (1)
2012年9月 (1)
2012年8月 (6)
2012年7月 (4)
2012年6月 (6)
2012年5月 (8)
2012年4月 (11)
2012年3月 (1)
2012年2月 (3)
2011年10月 (1)
2009年7月 (1)
2009年5月 (1)
2007年11月 (1)
2007年6月 (4)
2007年5月 (2)
2007年4月 (1)
2007年3月 (1)
2007年2月 (1)
2007年1月 (1)
2006年12月 (1)
2006年11月 (1)
2006年10月 (1)
2006年9月 (2)
2006年8月 (2)
2006年7月 (4)
統(tǒng)計(jì)
隨筆 - 150
文章 - 1
評(píng)論 - 44
引用 - 0
留言簿
(3)
給我留言
查看公開留言
查看私人留言
閱讀排行榜
1.?搭建Nginx+Java環(huán)境(轉(zhuǎn))(31747)
2.?安裝VMware tools 時(shí)vmware-install.pl無法安裝的問題解決辦法(9178)
3.?spring quartz使用多線程并發(fā)“陷阱”(轉(zhuǎn))(8123)
4.?什么是PV 什么是UV 什么是PR(7989)
5.?oracle驅(qū)動(dòng)錯(cuò)誤引起違反協(xié)議,類型長度大于最大值(7104)
評(píng)論排行榜
1.?什么是PV 什么是UV 什么是PR(13)
2.?關(guān)于tomcat總是內(nèi)存溢出(6)
3.?webwork的ui標(biāo)簽(3)
4.?fck上傳中文名文件亂碼問題(2)
5.?小心firefox的緩存(2)
將白色背景圖片變透明(轉(zhuǎn)自csdn)
[java:showcolumns]
view plain
copy
·········10········20········30········40········50········60········70········80········90········100·······110·······120·······130·······140·······150
package
com.picture;
import
java.awt.Graphics2D;
import
java.awt.image.BufferedImage;
import
java.io.File;
import
java.io.IOException;
import
java.util.regex.Pattern;
import
javax.imageio.ImageIO;
import
javax.swing.ImageIcon;
import
javax.swing.JOptionPane;
public
class
Picture {
public
static
void
convert(String path) {
// TODO Auto-generated constructor stub
try
{
BufferedImage image = ImageIO.read(
new
File(path));
ImageIcon imageIcon =
new
ImageIcon(image);
BufferedImage bufferedImage =
new
BufferedImage(
imageIcon.getIconWidth(), imageIcon.getIconHeight(),
BufferedImage.TYPE_4BYTE_ABGR);
Graphics2D g2D = (Graphics2D) bufferedImage.getGraphics();
g2D.drawImage(imageIcon.getImage(),
0
,
0
,
imageIcon.getImageObserver());
int
alpha =
0
;
for
(
int
j1 = bufferedImage.getMinY(); j1 < bufferedImage
.getHeight(); j1++) {
for
(
int
j2 = bufferedImage.getMinX(); j2 < bufferedImage
.getWidth(); j2++) {
int
rgb = bufferedImage.getRGB(j2, j1);
if
(colorInRange(rgb))
alpha =
0
;
else
alpha =
255
;
rgb = (alpha <<
24
) | (rgb &
0x00ffffff
);
bufferedImage.setRGB(j2, j1, rgb);
}
}
g2D.drawImage(bufferedImage,
0
,
0
, imageIcon.getImageObserver());
// 生成圖片為PNG
String outFile = path.substring(
0
, path.lastIndexOf(
"."
));
ImageIO.write(bufferedImage,
"png"
,
new
File(outFile +
".png"
));
}
catch
(IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public
static
boolean
colorInRange(
int
color) {
int
red = (color &
0xff0000
) >>
16
;
int
green = (color &
0x00ff00
) >>
8
;
int
blue = (color &
0x0000ff
);
if
(red >= color_range && green >= color_range && blue >= color_range)
return
true
;
return
false
;
}
public
static
int
color_range =
210
;
public
static
Pattern pattern = Pattern.compile(
"[0-9]*"
);
public
static
boolean
isNo(String str) {
return
pattern.matcher(str).matches();
}
/**
* @param args
*/
public
static
void
main(String[] args) {
// TODO Auto-generated method stub
String path = JOptionPane.showInputDialog(
null
,
"請(qǐng)輸入圖片目錄"
);
if
(path ==
null
|| !
new
File(path).isDirectory()) {
JOptionPane.showMessageDialog(
null
,
"輸入目錄有誤!"
);
return
;
}
String color = JOptionPane.showInputDialog(
null
,
"請(qǐng)輸入色差范圍0~255(建議10~50)"
);
if
(isNo(color)) {
color_range =
255
- Integer.parseInt(color);
File file =
new
File(path);
String[] files = file.list();
for
(
int
i =
0
; i < files.length; i++) {
String ext = files[i].substring(files[i].lastIndexOf(
"."
) +
1
);
if
(ext.equals(
"jpg"
)) {
convert(path +
"http://"
+ files[i]);
}
}
JOptionPane.showMessageDialog(
null
,
"轉(zhuǎn)換完成!"
);
}
else
{
JOptionPane.showMessageDialog(
null
,
"輸入的數(shù)字有誤!"
);
}
}
}
posted on 2012-04-28 09:50
小秦
閱讀(1402)
評(píng)論(0)
編輯
收藏
新用戶注冊(cè)
刷新評(píng)論列表
只有注冊(cè)用戶
登錄
后才能發(fā)表評(píng)論。
網(wǎng)站導(dǎo)航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
Powered by:
BlogJava
Copyright © 小秦
主站蜘蛛池模板:
亚洲中文字幕无码一区
|
亚洲AV色欲色欲WWW
|
人人揉揉香蕉大免费不卡
|
亚洲人成人网站在线观看
|
人人狠狠综合久久亚洲
|
91在线视频免费91
|
亚洲欧洲日本国产
|
久久久久久毛片免费播放
|
亚洲AV无码久久精品蜜桃
|
最近免费中文字幕中文高清
|
亚洲日本中文字幕一区二区三区
|
美美女高清毛片视频黄的一免费
|
四虎免费大片aⅴ入口
|
亚洲国产成人无码av在线播放
|
97青青草原国产免费观看
|
亚洲av无码专区在线播放
|
成人自慰女黄网站免费大全
|
自拍偷自拍亚洲精品情侣
|
亚洲免费一区二区
|
久久精品国产亚洲AV不卡
|
九九综合VA免费看
|
久久亚洲国产成人影院网站
|
人妻巨大乳hd免费看
|
精品国产香蕉伊思人在线在线亚洲一区二区
|
吃奶摸下高潮60分钟免费视频
|
亚洲国产无线乱码在线观看
|
午夜私人影院免费体验区
|
亚洲中文字幕无码久久2020
|
大香人蕉免费视频75
|
亚洲欧美日韩一区二区三区
|
亚洲日本在线免费观看
|
天天影视色香欲综合免费
|
亚洲人成人77777在线播放
|
99爱在线精品免费观看
|
亚洲一日韩欧美中文字幕在线
|
a级毛片无码免费真人
|
亚洲国产精品成人综合色在线
|
免费大香伊蕉在人线国产
|
日韩免费在线观看视频
|
亚洲视频一区调教
|
国产成人精品免费视频动漫
|