创建缩略图

情到浓时终转凉″ 提交于 2020-01-11 00:53:44
 string file = files[i];
                Image img 
= Image.FromFile(file);
                
int width = img.Width;
                
int height = img.Height;
                
if (width > height)
                {
                    width 
= 800;
                    height 
= width * img.Height / img.Width;
                }
                
else
                {
                    height 
= 800;
                    width 
= height * img.Width / img.Height;
                }
                Bitmap bt 
= new Bitmap(width, height);
                Graphics g 
= Graphics.FromImage(bt);
                g.DrawImage(img, 
00, width, height);
                
//g.Save(
                
//Image small = img.GetThumbnailImage(width, height, null, IntPtr.Zero);

                bt.Save(
string.Format("{0}m{1}.jpg", topath, i.ToString("0000")), ImageFormat.Jpeg);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!