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);
                        }

  • 相关阅读:
    CSS布局设计
    Gulp自动化构建工具的简单使用
    雅虎前端优化的35条军规
    CSS预编译器less简单用法
    java 数据相除
    idea 配置文件中文显示问题
    postgresql 表触发器
    postgresql 自定义函数
    postgresql 自定义聚合函数
    CentOS 6.5 yum安装mysql5.6或其他版本【默认yum只能安装mysql 5.1】 by jason
  • 原文地址:https://www.cnblogs.com/suneryong/p/1174213.html
Copyright © 2011-2022 走看看