Ejemplo n.º 1
0
        public static Image AddWater(Image img)
        {
            if (!WaterModuleConfig.WaterConfig.IsUsed)
            {
                return(img);
            }
            if (IsPixelFormatIndexed(img.PixelFormat))
            {
                Bitmap bmp = new Bitmap(img.Width, img.Height, PixelFormat.Format32bppArgb);
                using (Graphics g = Graphics.FromImage(bmp))
                {
                    g.InterpolationMode  = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                    g.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                    g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
                    g.DrawImage(img, 0, 0);
                }
                img = bmp;
            }
            //-----开始处理水印
            WaterImages water = new WaterImages();

            if (WaterModuleConfig.WaterConfig.WaterClass.Equals("1"))
            {
                string waterPath = function.VToP(WaterModuleConfig.WaterConfig.imgLogo);
                if (File.Exists(waterPath))
                {
                    img = water.DrawImage(img, waterPath);
                }
                else
                {
                    ZLLog.L("[" + WaterModuleConfig.WaterConfig.imgLogo + "]水印图片不存在");
                }
            }
            else
            {
                img = water.DrawFont(img);
            }
            return(img);
        }
Ejemplo n.º 2
0
        protected void BtnUpload_Click(object sender, EventArgs e)
        {
            long size = FupFile.FileContent.Length;

            if (!this.FupFile.HasFile)
            {
                this.ReturnManage("请指定一个上传文件");
            }
            else
            {
                if (!SiteConfig.SiteOption.EnableUploadFiles)
                {
                    this.ReturnManage("本站不允许上传文件!");
                }
                else
                {
                    string str2 = Path.GetExtension(this.FupFile.FileName).ToLower();
                    if (!SafeSC.IsImage(str2))
                    {
                        this.ReturnManage("上传的文件不是符合扩展名" + this.m_FileExtArr + "格式的文件");
                    }
                    else
                    {
                        this.m_FileExtArr  = SiteConfig.SiteOption.UploadFileExts;
                        this.m_MaxFileSize = SiteConfig.SiteOption.UploadPicMaxSize;//DataConverter.CLng(this.ViewState["MaxFileSize"].ToString());
                        if (string.IsNullOrEmpty(this.m_FileExtArr))
                        {
                            this.ReturnManage("要上传文件的字段没有指定上传文件类型");
                        }
                        else
                        {
                            if (((int)this.FupFile.FileContent.Length) > (this.m_MaxFileSize * 0x400))
                            {
                                this.ReturnManage("上传的文件超过限制的" + this.m_MaxFileSize + "KB大小");
                                return;
                            }
                            string str3       = DataSecurity.MakeFileRndName();
                            string foldername = base.Request.PhysicalApplicationPath + (VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.UploadDir) + this.FileSavePath()).Replace("/", @"\");
                            foldername = foldername.Replace(@"\\", @"\");

                            string filename = FileSystemObject.CreateFileFolder(foldername, HttpContext.Current) + str3 + str2;


                            if (WaterModuleConfig.WaterConfig.IsUsed && (str2 == ".jpg" || str2 == ".png") && HiddenNodeDir.Value != null && HiddenNodeDir.Value != "")
                            {
                                string Testfoldername = "";
                                if (NodeID <= 0)
                                {
                                    Testfoldername = foldername.Replace("UserUpload", "test");
                                }
                                else
                                {
                                    Testfoldername = foldername.Replace(HiddenNodeDir.Value, "test");
                                }
                                string Testfilename = FileSystemObject.CreateFileFolder(Testfoldername, HttpContext.Current) + str3 + str2;
                                this.FupFile.SaveAs(Testfilename);

                                WaterImages dd = new WaterImages();
                                if (WaterModuleConfig.WaterConfig.WaterClass == "1")
                                {
                                    string imgurl = Server.MapPath(WaterModuleConfig.WaterConfig.imgLogo);
                                    int    post   = DataConverter.CLng(WaterModuleConfig.WaterConfig.lopostion);
                                    dd.DrawImage(Testfilename, imgurl, filename);
                                }
                                else
                                {
                                    string waterword = WaterModuleConfig.WaterConfig.WaterWord;
                                    string ziti      = WaterModuleConfig.WaterConfig.WaterWordType;
                                    dd.DrawFont(Testfilename, filename);
                                }
                            }
                            else
                            {
                                this.FupFile.SaveAs(filename);
                            }
                            int    sizes         = (int)this.FupFile.FileContent.Length;
                            string thumbnailPath = "";
                            thumbnailPath = this.m_ShowPath + str3 + str2;
                            this.GetScriptByModuleName(thumbnailPath, sizes);
                            this.ReturnManage("文件上传成功");
                        }
                    }
                }
            }
        }