@{
Layout = null;
} <html>
<head>
<script type="text/javascript" src="~/scripts/jquery-1.10.2.min.js"></script>
<meta name="viewport" content="width=device-width,height=device-height, minimum-scale=0.1">
<style>
img {
text-align: center;
position: absolute;
margin: auto;
top: ;
right: ;
bottom: ;
left: ;
} .overflowingVertical {
cursor: zoom-out;
} .shrinkToFit {
cursor: zoom-in;
} body {
background-color: #;
color: #eee;
margin: ;
}
</style>
</head>
<body>
<img src="@ViewBag.PicURL" alt="@ViewBag.PicURL" onload="initImg();" />
<script>
function initImg() {
drawImage($("img"), document.body.clientWidth, document.body.clientHeight);
}
function drawImage(ImgD, FitWidth, FitHeight) {
var image = new Image();
image.src = ImgD.attr("src");
if (image.width > && image.height > ) {
if (image.width / image.height >= FitWidth / FitHeight) {
if (image.width > FitWidth) {
ImgD.css("width", FitWidth);
ImgD.css("height", (image.height * FitWidth) / image.width);
$("img").attr("class", "shrinkToFit");
ImgD.css("margin-top", );
} else {
ImgD.css("width", image.width);
ImgD.css("height", image.height);
}
} else {
if (image.height > FitHeight) {
ImgD.css("height", FitHeight);
ImgD.css("width", (image.width * FitHeight) / image.height);
$("img").attr("class", "shrinkToFit");
ImgD.css("margin-top", ); } else {
ImgD.css("width", image.width);
ImgD.css("height", image.height);
}
}
}
}
$("img").mousedown(function () {
if (typeof $(this).attr("class") != "undefined") {
$(this).toggleClass("shrinkToFit overflowingVertical");
if ($(this).hasClass("overflowingVertical")) {
var img = new Image();
img.src = $(this).attr("src");
var imgWidth = img.width; //图片实际宽度
var imgHeight = img.height; //图片实际高度
drawImage($(this), imgWidth, imgHeight);
}
if ($(this).hasClass("shrinkToFit")) {
drawImage($("img"), document.body.clientWidth, document.body.clientHeight);
}
}
});
</script>
</body>
</html>

后台:

/// <summary>
/// 图片自适应居中打开,非图片浏览器下载
/// </summary>
/// <param name="dirRelativePath">文件路径,包含文件名</param>
/// <param name="fileName">文件名</param>
/// <returns></returns>
public ActionResult OpenPicture(string dirRelativePath, string fileName)
{
Regex regex = new Regex(@"\.jpg|\.bmp|\.png|\.gif|\.tiff");
fileName = fileName.ToLower();
var isMatch = regex.IsMatch(fileName);
//图片
if (isMatch)
{
ViewBag.PicURL = "/Home/DownLoad?dirRelativePath=" + dirRelativePath + "&fileName=" + fileName;
}
else
{
return RedirectToAction("DownLoad", "Home", new { dirRelativePath = dirRelativePath, fileName = fileName });
}
return View();
}
/// <summary>
/// 下载附件
/// </summary>
/// <param name="dirRelativePath"></param>
/// <param name="fileName"></param>
/// <returns></returns>
public ActionResult DownLoad(string dirRelativePath, string fileName)
{ string uploadPath = System.Configuration.ConfigurationManager.AppSettings["BPMAttachments"];
string dirAbsolutePath = uploadPath + dirRelativePath; if (!System.IO.File.Exists(dirAbsolutePath))
{
return Content("提示:文件在磁盘上不存在");
}
//HttpContext.Response.AddHeader("content-disposition", "attachment;filename=" + fileName);
//return File(dirAbsolutePath, "application/octet-stream");
var contentType = MimeMapping.GetMimeMapping(fileName);
HttpContext.Response.AddHeader("content-disposition", "inline;filename=" + fileName);
return File(dirAbsolutePath, contentType);
}

图片浏览 h5的更多相关文章

  1. 图片浏览(CATransition)转场动画

    Main.storyboard ViewController.m // //  ViewController.m //  8A04.图片浏览(转场动画) // //  Created by huan ...

  2. Android 高级UI设计笔记14:Gallery(画廊控件)之 3D图片浏览

    1. 利用Gallery组件实现 3D图片浏览器的功能,如下: 2. 下面是详细的实现过程如下: (1)这里我是测试性代码,我的图片是自己添加到res/drawable/目录下的,如下: 但是开发中不 ...

  3. 用CSS和第三方库来提升图片浏览体验

    你是否关注过浏览.点击图片这个微妙的过程,不同的图片展现.交互方式各带来什么样的观感?本文聚焦于图片浏览这个过程以及如何使用CSS3和第三方库来提升体验. 先看下Pinterest.Flickr等时下 ...

  4. 第17讲- UI常用组件之ImageView图片浏览

    第17讲 UI常用组件之ImageView图片浏览 二.图片浏览ImageView ImageView就是一个用来显示图片的视图: ImageView常见属性 常见属性 对应方法 说明 android ...

  5. [置顶] ios 一个不错的图片浏览分享框架demo

    demo功能:一个不错的图片浏览分享框架demo.iphone6.1 测试通过.可以浏览图片,保存,微博分享到新浪,腾讯,网易,人人等. 注:(由于各个微博的接口有时候会有调整,不一定能分享成功.只看 ...

  6. WPF 图片浏览 伪3D效果

    原文:WPF 图片浏览 伪3D效果 首先上效果图: 因项目要求,需要把图片以"好看"."炫"的效果展示出来,特地研究了一下WPF关于3D方面的制作,奈何最终成果 ...

  7. Ubuntu下几个命令行方式使用的图片浏览工具

    想找几个Ubuntu下可以以命令行方式使用的图片浏览工具. Google了一些资料,找到下面几个web: 1.pho:轻巧的命令行图片查看器 其中介绍了工具pho,其功能特点,见下面的转帖内容: ph ...

  8. 【MVC】快速构建一个图片浏览网站

    当抄完MusicStore时,你应该对MVC有一个比较清晰的认识了.接下来就需要做个网站来继续增加自己的知识了.那么,该做个什么网站呢.做个图片浏览网站吧,简单而实用. 简单设计 1.首先,页面中间是 ...

  9. iOS Swift WisdomScanKit二维码扫码SDK,自定义全屏拍照SDK,系统相册图片浏览,编辑SDK

    iOS Swift WisdomScanKit 是一款强大的集二维码扫码,自定义全屏拍照,系统相册图片编辑多选和系统相册图片浏览功能于一身的 Framework SDK [1]前言:    今天给大家 ...

随机推荐

  1. centos7 安装elasticsearch

    [root@localhost local]# tar xzvf elasticsearch-2.3.5.tar.gz [root@localhost elasticsearch-2.3.5]# bi ...

  2. 剖析touch事件在View中的传递

    话不多说,直奔主题,先来看一张图 版权申明:这是csdn上别人的图,我觉得有用,就拿过来了, 然后简单说明下: 总的来说,触摸事件是从最外层的ViewGroup,一级一级传递进来的 和这相关的每个Vi ...

  3. zepto.js 的tap事件中点击一次触发两次事件

    html代码: <div class="xh-lxx-cart-count1"> <span class="minus">-</s ...

  4. QuartusII 13.0 PLL IP Core调用及仿真

    有一个多月没用用Quartus II了,都快忘了IP 是怎么用调用的了,还好有之前做的笔记,现在整理出来,终于体会到做笔记的好处. 一.  QuartusII的pll的调用 打开软件界面 Tool—— ...

  5. (转)每天一个linux命令(8):cp 命令,复制文件和文件夹

    场景:自动部署脚本中为了部署方便,将配置文件放在服务器端,每次部署都使用服务端的配置文件覆盖上传上去的配置文件. cp命令用来复制文件或者目录,是Linux系统中最常用的命令之一. 一般情况下,she ...

  6. iOS imageio nsurlsession 渐进式图片下载

    一.图片常用加载格式分两种 一般线性式 和交错/渐进式 自上而下线性式 先模糊再清晰 就概率上而言线性式使用最多,应为他所占空间普片比渐进式小.而这两种方式对于app端开发人员无需关心,这种图片存储格 ...

  7. 代理(Proxy)和反射(Reflection)

    前面的话 ES5和ES6致力于为开发者提供JS已有却不可调用的功能.例如在ES5出现以前,JS环境中的对象包含许多不可枚举和不可写的属性,但开发者不能定义自己的不可枚举或不可写属性,于是ES5引入了O ...

  8. <EffectiveJava>读书笔记--02泛型数组

    1, java中可以申明泛型类型的数组引用; 2, 但是不能实例化一个泛型数组对象; 3, 针对第二点, 可以曲线救国, 实例化一个Object数组, 再进行类型强转; 见代码如下: public c ...

  9. Redis-aof持久化

    什么是redis的aof? aof 是 appendonly file 的缩写, 是redis系统提供的一种记录redis操作的持久化方案, 在aof生成的文件中, 将记录发生在redis的操作, 从 ...

  10. Linux(1)目录

    Linux目录 / :根目录, 一般只存放目录, 在Linux下只有一个根目录. 所有的东西都是从这里开始 /bin, /usr/bin :可执行的二进制文件目录, 如常用的ls, tar, mv, ...