zoukankan      html  css  js  c++  java
  • 上传图片 水印位置计算 记录一下

      //加图片水印
                        System.Drawing.Image image = System.Drawing.Image.FromFile(path + picName);
                        System.Drawing.Image watermakeImage = System.Drawing.Image.FromFile(CopyPicpath);
                        Graphics g = Graphics.FromImage(image);

                        int x = 0; //x坐标
                        int y = 0; //y坐标

                        switch (position)
                        {
                            case "0": //左上
                                x = 0;
                                y = 0;
                                break;
                            case "1": //右上
                                x = image.Width - watermakeImage .Width;
                                y = 0;
                                break;
                            case "2": //左下
                                x = 0;
                                y = image.Height - watermakeImage .Height;
                                break;
                            case "3": //右下
                                x = image.Width - watermakeImage .Width;
                                y = image.Height - watermakeImage .Height;
                                break;
                            default:
                                break;
                        }
                        g.DrawImage(watermakeImage , new Rectangle(x, y, watermakeImage .Width, watermakeImage .Height), 0, 0, watermakeImage .Width, watermakeImage .Height, GraphicsUnit.Pixel);
                        g.Dispose();

                        //保存加水印过后的图片,删除原始图片
                        string newPath = path + "New_" + picName; 

                        image.Save(newPath);
                        picNameWaterMack = "New_" + picName;
                        image.Dispose();
                        if (File.Exists(path + picName))
                        {
                            File.Delete(path + picName);
                        }

  • 相关阅读:
    Velocity的使用小记
    fastJson的SerializeFilter使用
    快捷的时间转化
    How to execute a Stored Procedure with Entity Framework Code First
    自定义 ASP.NET Identity Data Model with EF
    Asp.Net Core get client IP
    HTTP 请求头中的 X-Forwarded-For
    HttpRequest,WebRequest,HttpWebRequest,WebClient,HttpClient 之间的区别
    【逻辑】500桶酒,找毒酒
    Asp.Net Core 输出 Word
  • 原文地址:https://www.cnblogs.com/suneryong/p/1174213.html
Copyright © 2011-2022 走看看