asp获取post asp.net如何获取图片的分辨率
asp.net如何获取图片的分辨率
public void formatImage()
{
//格式化后的图片大小
int _WIDTH = ;
int _HEIGHT = ;
System Drawing Image GetThumbnailImageAbort myCallback = new System Drawing Image GetThumbnailImageAbort(ThumbnailCallback);
System Drawing Image img = System Drawing Image FromFile(@ d: png );
//制作缩略图

int width = img Width;
int height = img Height;
double divide = (double)height / (double)width;
if (width > _WIDTH || height > _HEIGHT)
{
if (width > _WIDTH)
{
height = Convert ToInt (Math Floor(_WIDTH * divide));
width = _WIDTH;
}
if (height > _HEIGHT)
{
width = Convert ToInt (Math Floor(_HEIGHT / divide));
height = _HEIGHT;
}
System Drawing Image timg = img GetThumbnailImage(width height myCallback System IntPtr Zero);
timg Save(@ d: jpg System Drawing Imaging ImageFormat Jpeg);
//下面的是保存到流中
//MemoryStream ms = new MemoryStream();
//timg Save(ms System Drawing Imaging ImageFormat Jpeg);
//ms Close();
}
}
public bool ThumbnailCallback()
{
return false;
lishixinzhi/Article/program/net/201311/13712