@{
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. SQL Server 2008R2的安装

    一.安装前的准备工作:SQL Server 200R2安装包 二.SQL Server2008R2的安装 1.打开SQL Server2008R2的安装包,找到setup.exe 2.双击sql se ...

  2. 关于Docker中的Images与Containers

    Docker engine提供了启动Images和containers核心的技术的支持.当你运行docker run hello-world 命令时,实际上可分为三个部分: 告诉你操作系统你正在使用的 ...

  3. 数位dp模板 [dp][数位dp]

    现在才想到要学数位dp,我是不是很弱 答案是肯定的 以一道自己瞎掰的题为模板 //题: //输入数字n //从0枚举到n,计算这n+1个数中含有两位数a的数的个数 //如12930含有两位数93 #i ...

  4. 史上最易懂——ReactNative分组列表SectionList使用详情及示例详解

    React Native系列 <逻辑性最强的React Native环境搭建与调试> <ReactNative开发工具有这一篇足矣> <解决React Native un ...

  5. 【CSS】整屏大背景

    1. 利用div的层次,设置底层div充满屏幕,并给div设置背景图 <div id="Layer1" style="position:absolute;top:0 ...

  6. AtCoder Beginner Contest 068

    A - ABCxxx 题意: 给出n,输出“ABCn”就可以了,纯水题. B - Break Number 题意: 给出n,找出从1到n的闭区间内能够被2整除最多次的数. 思路: 直接模拟. 代码: ...

  7. ajax-jquery方法-初步入门01(整理)

    -----------------------------------2017.07.21写----------------------------------------- 相比较原生javascr ...

  8. Jenkins发布MVC应用程序

    一个大的项目一般都会进行模块化.层次化分隔,每个模块.每个层次都可能是一个或多个工程文件组成,而且各个模块都有依赖关系,有先后顺序,先build哪个然后再build哪个都是有顺序的,如果想build一 ...

  9. CSS样式----浮动(图文详解)

    标准文档流 宏观地讲,我们的web页面和photoshop等设计软件有本质的区别:web页面的制作,是个"流",必须从上而下,像"织毛衣".而设计软件,想往哪里 ...

  10. java大数取余

    java大数取余: 类方法:BigInteger.divideAndRemainder() 返回一个数组,key = 0为商key = 1为余数 import java.util.*; import ...