コード例 #1
0
ファイル: A_LoadUserPhoto.cs プロジェクト: q446328246/Nechj
        protected void btn_Image_Click(object sender, EventArgs e)
        {
            int    imageWidth       = int.Parse(txt_width.Text);
            int    imageHeight      = int.Parse(txt_height.Text);
            int    pOrigStartPointY = int.Parse(txt_top.Text);
            int    pOrigStartPointX = int.Parse(txt_left.Text);
            int    pPartWidth       = int.Parse(txt_DropWidth.Text);
            int    pPartHeight      = int.Parse(txt_DropHeight.Text);
            string str = CutPhotoHelp.SaveCutPic(Page.Server.MapPath(ImageIcon.ImageUrl),
                                                 Page.Server.MapPath(string_1), 0, 0, pPartWidth, pPartHeight,
                                                 pOrigStartPointX, pOrigStartPointY, imageWidth, imageHeight);

            imgphoto.ImageUrl = string_1 + str;
            var    action = (ShopNum1_Member_Action)LogicFactory.CreateShopNum1_Member_Action();
            string path   = action.SearchByMemLoginID(base.MemLoginID).Rows[0]["Photo"].ToString();

            try
            {
                if (path != "")
                {
                    File.Delete(Page.Server.MapPath(path));
                }
            }
            catch
            {
            }
            finally
            {
                action.UpdatePhoto(base.MemLoginID, string_1 + str);
                File.Delete(Page.Server.MapPath(hid_imgValue.Value));
                Page.ClientScript.RegisterStartupScript(typeof(A_LoadUserPhoto), "setPic",
                                                        "<script type='text/javascript'>setPic('" +
                                                        imgphoto.ImageUrl + "');</script>");
            }
        }
コード例 #2
0
        /// <summary>
        /// 保存头像
        /// </summary>
        /// <param name="picname"></param>
        /// <param name="txt_width"></param>
        /// <param name="txt_height"></param>
        /// <param name="txt_top"></param>
        /// <param name="txt_left"></param>
        /// <param name="txt_DropWidth"></param>
        /// <param name="txt_DropHeight"></param>
        /// <returns></returns>
        public JsonResult SavePhoto(string picname, float z, int t, int l, int w, int h)
        {
            float zoomLevel = Convert.ToSingle(z);
            int   top       = Convert.ToInt32(t);
            int   left      = Convert.ToInt32(l);
            int   width     = Convert.ToInt32(w);
            int   height    = Convert.ToInt32(h);

            string picurl    = ConfigurationManager.AppSettings["OLDphotoUrl"] + picname;
            string folderNew = ConfigurationManager.AppSettings["NEWphotoUrl"];

            try
            {
                string filename = CutPhotoHelp.Crop(Server.MapPath(picurl), Server.MapPath(folderNew), zoomLevel, top, left, width, height);
                int    uid      = CurrentUser == null ? 0 : CurrentUser.UserId;
                string PhotoUrl = folderNew + filename;
                bool   re       = userBL.UpdatePhoto(PhotoUrl, uid);
                if (re)
                {
                    return(Json(new
                    {
                        result = 1,
                        content = filename
                    }, "text/html", JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new
                    {
                        result = 0,
                        content = "保存失败"
                    }, "text/html", JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(new
                {
                    result = 0,
                    content = "保存失败"
                }, "text/html", JsonRequestBehavior.AllowGet));
            }
        }
コード例 #3
0
ファイル: cut.aspx.cs プロジェクト: lianghf2000/powerway
    protected void Button1_Click(object sender, EventArgs e)
    {
        int w = int.Parse(this.realWidth.Value);
        int h = int.Parse(this.realHeight.Value);
        int top = int.Parse(this.top.Value.Replace("px", "").Trim()) * -1;
        int left = int.Parse(this.left.Value.Replace("px", "").Trim()) * -1;

        //Response.Write("W:" + w.ToString());
        //Response.Write("H:" + h.ToString());
        //Response.Write("T:" + top.ToString());
        //Response.Write("L:" + left.ToString());
        string imgurl = Request.QueryString["path"];
        string savepath = Server.MapPath("~/uploads/CutSmall/");

        string file = CutPhotoHelp.SaveCutPic(Server.MapPath("../uploads/"+imgurl), savepath, 0, 0, needWidth, needHeight, left, top, w, h);
        //Response.Write("<br>"+file);
        this.script.Text = "<script>setImg('CutSmall/" + file + "')</script>";
        //Response.End();
    }