首页 > 技术文章 > C# CAD DWG 预览 缩列图

shangdishijiao 2021-11-02 16:00 原文

  /// <summary>
        /// 加载文件图片
        /// </summary>
        /// <param name="path"></param>
        public void LoadImg(string path)
        {
            var bitmap = get_image_of_file(path);
            picImg.Image = bitmap;
        }

        public System.Drawing.Bitmap get_image_of_file(string filename)
        {
            //create a new database instance and load the dwg file into it.
            Database dbb = new Database(false, true);
            dbb.ReadDwgFile(filename, FileShare.Read, false, "");

            //grab the thumbnail bitmap and get rid of the white background
            System.Drawing.Bitmap preview = dbb.ThumbnailBitmap;
            preview.MakeTransparent(System.Drawing.Color.White);

            return preview;
        }

  

 

推荐阅读