看你要嫁什么水印了, g.drawLine可以加上一条线....

解决方案 »

  1.   

    java加水印效果应该很复杂,你做什么呢?如果是web开发,为什么不用javascript呢?
      

  2.   

    貌似要用到java图片,给你几个链接参考下:
    http://www.blogjava.net/parable-myth/archive/2006/10/28/77766.htmlhttp://fanth.javaeye.com/blog/80623http://firecool.javaeye.com/blog/111781
      

  3.   

    // 加水印
    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();
      

  4.   

    我刚好做了一个图片加水印的效果!~!
    可以给楼主分享一下重要的代码:
    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();