{
/**
* 图像面板类
*/
....................................
String st = "水印"
BufferedImage image = null
public void paintComponent(Graphics g)
{
super.paintComponent(g)
Graphics2D g2 = (Graphics2D) g
if (image != null)
{
g2.drawImage(image, 0, 0, this)
g2.setColor(Color.green)//设置水印颜色
g2.drawString(st, 10, 10)//绘制水印,具体水印绘制方式根据自己的需求修改
}
.........
}
.................
}
/**
*保存添加水印后的图片
*
*/
......
BufferedImage bi = new BufferedImage(ImagePanel2a.getWidth(), ImagePanel2a.getHeight(), BufferedImage.TYPE_INT_ARGB)
Graphics2D g2d = bi.createGraphics()
ImagePanel2a.paint(g2d)
ImageIO.write(bi, "PNG", new File("路径"))
....
public class exp2{ public static void main(String args[]){ int i=0math mymath = new math()for(i=2i<=200i++) if(mymath.iszhishu(i)==true)
System.out.println(i)
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)