使用BufferedImage挖空图片某个区域
作者:互联网
摘要:BufferedImage RGBA Transparent 挖图 抠图
先看看效果
代码
@Test
public void getAlphaImage2() throws IOException{
String imagePath = "D:\\TSBrowserDownloads\\baozhen.png";
BufferedImage img=ImageIO.read(new File(imagePath));
for (int w = 0; w < img.getWidth(); w++) {
for (int h = 0; h < img.getHeight(); h++) {
if((w>=210 && w<= 380) && (h>=150 && h<= 360)){
img.setRGB(w, h, 16777215);
}
}
}
ImageIO.write(img, "png", new File("D:\\TSBrowserDownloads\\target.png"));
}
解释
-
16777215
-
不能用透明图片画到抱枕上,那样是没效果的,只能重新rgb值
标签:imagePath,img,int,BufferedImage,++,&&,某个,挖空 来源: https://blog.csdn.net/Kesa_Wu/article/details/120471148