看你要嫁什么水印了, g.drawLine可以加上一条线....
解决方案 »
- 如何用最简单的java程序获得 3个 可用的端口?
- struts2 标签 <s:select /> 使用问题,高手进!
- j2ee初级问题
- 生活很无奈,找工作很渺茫,大家指点迷津,十分感谢大家。
- rmi 连接时好时坏
- sqlserver2000中的text类型的字段如何映射?
- 请问用JDBC 中的ResultSet.getDouble(String),数据库中的数据是0.001,为什么返回的是0.0010?
- 不知道算不算难题:两台主机上的不同网站如果共享使用同一客户端cookie?
- JAVA代码中访问DB2的问题
- 各位大虾,100分强烈求救!!!再线等待!!!
- 关于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();