看你要嫁什么水印了, g.drawLine可以加上一条线....
解决方案 »
- 请问JavaEE中当Session超时之后,服务器如何处理?
- JSF框架问题
- jsp页面上用js导出excel出错
- 关于JavaService引入多个jar问题
- Hibernate 发出这个异常HibernateQueryException: could not resolve property: 请教各位高手怎末办
- 这个@XmlType是?与具体的数据库绑带的么?与Hibernate和Ejb的annotation有什么不同?
- struts刷新提交传参问题
- 小妹先散分了,请问怎样设置tomcat5使他自动加载类而不需要重新启动,等待中。。
- 关于finally的问题
- 到哪儿下载J2EE及其API文档?
- 关于form表格中action如何调用servlet类
- HttpClient 中的https应该怎么办!!!!(高分顶着有分)
http://www.blogjava.net/parable-myth/archive/2006/10/28/77766.htmlhttp://fanth.javaeye.com/blog/80623http://firecool.javaeye.com/blog/111781
Graphics g = sourceImage.getGraphics();
if (srcWidth > 300 && srcHeight > 300) {
File _filebiao = new File("D://make.png");
Image src_biao = ImageIO.read(_filebiao);
int wideth_biao = src_biao.getWidth(null);
int height_biao = src_biao.getHeight(null);
g.drawImage(src_biao, srcWidth - wideth_biao - 0, srcHeight- height_biao - 0, wideth_biao, height_biao, null);
}
g.dispose();
可以给楼主分享一下重要的代码:
string converUrl = string.Format(context.Request.PhysicalPath);
//加载封面图片的对象
image = DRImage.FromFile(converUrl);
//加载水印图像对象
DRImage waterImage = DRImage.FromFile(context.Server.MapPath(WATERMARKURL));
//目标水印的宽和高
//int waterWidth = image.Width * 2 / 3;
int waterWidth = Convert.ToInt32(Math.Sqrt((Math.Pow(image.Width * 1 / 2, 2) + Math.Pow(image.Height * 1 / 3, 2))));
int waterHeight = image.Height * 1 / 10;
//水印的起始点
//Point p = new Point(image.Width - waterWidth, image.Height - waterHeight);
Point p = new Point(0, 0);
//水印目标的矩形
Rectangle rect = new Rectangle(p, new Size(waterWidth, waterHeight));
//水印原始矩形
Rectangle srcRect = new Rectangle(new Point(0, 0), new Size(waterImage.Width ,waterImage.Height));
//画板
grap = Graphics.FromImage(image);
// Then to translate, prepending to world transform.
//设置一个原点,让水印图片围绕着转
grap.TranslateTransform(image.Width * 0.4F, image.Height - waterHeight);
//然后让图片旋转
grap.RotateTransform(-45.0F);
//画图
grap.DrawImage(waterImage, rect, srcRect, GraphicsUnit.Pixel);
//释放画板
grap.Dispose();
//释放水印图片
waterImage.Dispose();