zoukankan
html css js c++ java
图片处理
HttpFileCollection MyFileColl
=
HttpContext.Current.Request.Files;
HttpPostedFile MyPostedFile
=
MyFileColl[
0
];
if
(MyPostedFile.ContentType.ToString().ToLower().IndexOf(
"
image
"
)
<
0
)
{
Response.Write(
"
无效的图形格式。
"
);
return
;
}
GetThumbNail(MyPostedFile.FileName,
100
,
100
,
MyPostedFile.ContentType.ToString(),
false
, MyPostedFile.InputStream);
}
private
System.Drawing.Imaging.ImageFormat GetImageType(
object
strContentType)
{
if
((strContentType.ToString().ToLower())
==
"
image/pjpeg
"
)
{
return
System.Drawing.Imaging.ImageFormat.Jpeg;
}
else
if
((strContentType.ToString().ToLower())
==
"
image/gif
"
)
{
return
System.Drawing.Imaging.ImageFormat.Gif;
}
else
if
((strContentType.ToString().ToLower())
==
"
image/bmp
"
)
{
return
System.Drawing.Imaging.ImageFormat.Bmp;
}
else
if
((strContentType.ToString().ToLower())
==
"
image/tiff
"
)
{
return
System.Drawing.Imaging.ImageFormat.Tiff;
}
else
if
((strContentType.ToString().ToLower())
==
"
image/x-icon
"
)
{
return
System.Drawing.Imaging.ImageFormat.Icon;
}
else
if
((strContentType.ToString().ToLower())
==
"
image/x-png
"
)
{
return
System.Drawing.Imaging.ImageFormat.Png;
}
else
if
((strContentType.ToString().ToLower())
==
"
image/x-emf
"
)
{
return
System.Drawing.Imaging.ImageFormat.Emf;
}
else
if
((strContentType.ToString().ToLower())
==
"
image/x-exif
"
)
{
return
System.Drawing.Imaging.ImageFormat.Exif;
}
else
if
((strContentType.ToString().ToLower())
==
"
image/x-wmf
"
)
{
return
System.Drawing.Imaging.ImageFormat.Wmf;
}
else
{
return
System.Drawing.Imaging.ImageFormat.MemoryBmp;
}
}
private
void
GetThumbNail(
string
strFileName,
int
iWidth,
int
iheight,
string
strContentType,
bool
blnGetFromFile, System.IO.Stream ImgStream)
{
System.Drawing.Image oImg;
if
(blnGetFromFile)
{
oImg
=
System.Drawing.Image.FromFile(strFileName);
}
else
{
oImg
=
System.Drawing.Image.FromStream(ImgStream);
}
oImg
=
oImg.GetThumbnailImage(iWidth, iheight,
null
, IntPtr.Zero);
string
strGuid
=
System.Guid.NewGuid().ToString().ToUpper();
string
strFileExt
=
strFileName.Substring(strFileName.LastIndexOf(
"
.
"
));
Response.ContentType
=
strContentType;
MemoryStream MemStream
=
new
MemoryStream();
oImg.Save(MemStream, GetImageType(strContentType));
MemStream.WriteTo(Response.OutputStream);
}
}
查看全文
相关阅读:
delete 用法总结
js数组去重的常用方法总结
学习中 常用到的string内置对象方法的总结
Array 对象常用的方法总结
javascript中运算符有哪些? 他们的优先级 呢?
那些年前端经典面试题
HHVM 3.0 发布,执行 PHP 的虚拟机
【问底】徐汉彬:PHP7和HHVM的性能之争 (真是学到了很多)
mysql 简单sql语句
【问底】王帅:深入PHP内核(一)——弱类型变量原理探究
原文地址:https://www.cnblogs.com/yiki/p/884343.html
最新文章
把.html转换成.jsp中jqplot画图表不能正常显示,出错的心得
使用eclipse svn塔建(配置)时的一点点心得
javascript元素绑定事件
github 使用
程序员如何承接软件外包项目(转)
ORACLE 数据库选择性导出表中数据&导入已存在表数据
数组共同体
构造函数与析构函数的调用顺序
随笔
ORA-01658: 无法为表空间 YJXT 中的段创建 INITIAL 区
热门文章
使用Gulp压缩IMG
使用Gulp压缩HTML和CSS
Bootstrap拟态框+支付宝首页
Grunt压缩HTML和CSS
Grunt压缩图片和JS
CSS 简单了解(二)
css简单了解
HTML 简单了解
Javascript 面向对象编程-封装
C#线程调用
Copyright © 2011-2022 走看看