zoukankan      html  css  js  c++  java
  • 水印图片和文字

    --控制器

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using System.IO;
    using System.Drawing;
    namespace 水印1.Controllers
    {
    public class HomeController : Controller
    {
    //
    // GET: /Home/

    public ActionResult Index()
    {
    if(Session["img"]!=null)ViewBag.img = Session["img"].ToString();
    return View();
    }
    [HttpPost]
    public ActionResult uploadfile(HttpPostedFileBase pic)
    {
    string filename = Path.Combine(Request.MapPath("~/images/"), Path.GetFileName(pic.FileName));
    pic.SaveAs(filename);
    WaterImageManage shui = new WaterImageManage();
    string aFirstName = pic.FileName.Substring(pic.FileName.LastIndexOf("\") + 1);
    string shuiming = "127252_n.jpg";
    float tou =Convert.ToSingle(0.5);
    ImagePosition s = ImagePosition.Center;
    string weizhi = @"D:练习水印1水印1images";
    string c = shui.DrawImage(aFirstName, shuiming, tou, s, weizhi);
    Session["img"] = "/images/" + c;
    return RedirectToAction("Index");
    }
    }
    }

    --前台

    @{
    Layout = null;
    }

    <!DOCTYPE html>

    <html>
    <head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
    </head>
    <body>
    <div>
    <form action="/Home/uploadfile" method="post" enctype="multipart/form-data">
    <input type="file" name="pic" id="pic" />
    <input type="submit" value="提交" />
    </form>
    <!--原始图片展示 move:此光标指示某对象可被移动-->
    <img id="photo" style="cursor:move" src="@ViewBag.img" />


    </div>
    </body>
    </html>

  • 相关阅读:
    搭建本地yum仓库
    linux下查看http 并发和 tcp连接数
    MySQL用户管理及SQL语句详解
    API开发之接口安全(一)----生成sign
    TP5使用API时不可预知的内部异常
    TP5通用化API接口数据封装
    根据指定日期获取近一周,及该月起止时间戳
    14-Promise
    4-字符串扩展与新增方法
    换行
  • 原文地址:https://www.cnblogs.com/xing-xing/p/7884346.html
Copyright © 2011-2022 走看看