码迷,mamicode.com
首页 > Windows程序 > 详细

WPF C# 创建缩略图

时间:2019-08-19 19:31:53      阅读:141      评论:0      收藏:0      [点我收藏+]

标签:jpg   sharp   eth   ret   als   注意   oid   class   csharp   

不太精确的方法:

 public bool ThumbnailCallback()
        {
            return false;
        }

        private void CreateThumb(int toWidth)
        {
            System.Drawing.Image.GetThumbnailImageAbort myCallback =
            new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);
            Bitmap myBitmap = new Bitmap("D:\\img100.jpg");
            double rate = (double)((double)myBitmap.Width / myBitmap.Height );
            int  toHeight =(int)((double )toWidth / rate);
            System.Drawing.Image myThumbnail = myBitmap.GetThumbnailImage(toWidth , toHeight, myCallback, IntPtr.Zero);
            myThumbnail.Save("D:\\okThumb.jpg");
        }

  

注意:由于int 和double的问题 无法精确。。。。。。。。。。。。。。。。。

WPF C# 创建缩略图

标签:jpg   sharp   eth   ret   als   注意   oid   class   csharp   

原文地址:https://www.cnblogs.com/wgscd/p/11378699.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!