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);
}
}
查看全文
相关阅读:
分组排序并显示序号
power-design--tables-export-usage
cache implement
get system properties
jbpm
JVM内存管理机制和垃圾回收机制
java读取excel
Java编程中“为了性能”尽量要做到的一些地方
json串与java对象互转
apidoc的使用
原文地址:https://www.cnblogs.com/yiki/p/884343.html
最新文章
selinux 策略使用到的宏
centos selinux minidlna
netbsd 的 manual 报错
screen 打开串口
无线命令行启动
xen 记录
vue vux 使用 vux的理解 (下)
element 上传 Upload 上传同时下载文件
vue vux 使用 vux的理解 (上)
数据可视化 图表 大屏图表 echarts图表
热门文章
v-model的实现原理 vue
对object.defineproperty 的深入理解
Animate Css动画
热力图 vue 项目中使用热力图插件 “heatmap.js”(保姆式教程)
ps 安装 ps 2021版 2017版 下载 及教程(保姆式教程)
collections.sort method
file--in Unix system ,getting file encoding
Java-key-words
同包名同类名的加载优先解疑
shell-script-make
Copyright © 2011-2022 走看看