if(System.IO.File.Exists(path))
{
goodsid+=dt.Rows[i]["goodsid"].ToString()+",";
// if(!System.IO.File.Exists(Picpath))
// {
System.Drawing.Image img=System.Drawing.Image.FromFile(path);
//生成中图
int w=img.Width; //当前图片的宽
int h=img.Height; //当前图片的高
int x=0; //设置生成图片的宽
int y=0; //设置生成图片的高
int curx=182;
int cury=122;
if(w>=curx && h<=cury)
{
x=curx ;
y=curx *h/w;
}
else if(h>=cury&& w<=curx )
{
y=cury;
x=cury*w/h;
}
else if(h>=cury&& w>=curx )
{
if(h/cury<w/curx )
{
x=curx ;
y=curx *h/w;
}
else
{
y=cury;
x=cury*w/h;
}
}
else if(h<=cury&& w<=curx )
{
x=img.Width;
y=img.Height;
}
System.Drawing.Image newimg=img.GetThumbnailImage(x,y,null,new System.IntPtr(0));
newimg.Save(Picpath,System.Drawing.Imaging.ImageFormat.Jpeg);
img.Dispose();
newimg.Dispose();
{
goodsid+=dt.Rows[i]["goodsid"].ToString()+",";
// if(!System.IO.File.Exists(Picpath))
// {
System.Drawing.Image img=System.Drawing.Image.FromFile(path);
//生成中图
int w=img.Width; //当前图片的宽
int h=img.Height; //当前图片的高
int x=0; //设置生成图片的宽
int y=0; //设置生成图片的高
int curx=182;
int cury=122;
if(w>=curx && h<=cury)
{
x=curx ;
y=curx *h/w;
}
else if(h>=cury&& w<=curx )
{
y=cury;
x=cury*w/h;
}
else if(h>=cury&& w>=curx )
{
if(h/cury<w/curx )
{
x=curx ;
y=curx *h/w;
}
else
{
y=cury;
x=cury*w/h;
}
}
else if(h<=cury&& w<=curx )
{
x=img.Width;
y=img.Height;
}
System.Drawing.Image newimg=img.GetThumbnailImage(x,y,null,new System.IntPtr(0));
newimg.Save(Picpath,System.Drawing.Imaging.ImageFormat.Jpeg);
img.Dispose();
newimg.Dispose();