C1Gauge 导出到图片

许多用户曾经咨询过我们是否可以将 C1Gauge 导出到 Image。目前我们没有我们没有提供把 C1Gauge 导出到 Image 接口。但是我们可以使用 .NET 标准方法去捕捉 Image 从而 保存它。

发布于 2012/11/15 00:00

ComponentOne Enterprise

C1Gauge 导出到图片

许多用户曾经咨询过我们是否可以将 C1Gauge 导出到 Image。目前我们没有我们没有提供把 C1Gauge 导出到 Image 接口。
但是我们可以使用 .NET 标准方法去捕捉 Image 从而 保存它。

使用该方法我们可以保存 C1Gauge 为 Image。

 
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
        private static extern bool BitBlt(
        IntPtr hdcDest,
        int nXDest,
        int nYDest,
        int nWidth,
        int nHeight,
        IntPtr hdcSrc,
        int nXSrc,
        int nYSrc,
        int dwRop);
        public Bitmap CaptureControl(Control control)
        {
            Bitmap controlBmp;
            using (Graphics g1 = control.CreateGraphics())
            {
                controlBmp = new Bitmap(control.Width, control.Height, g1);
                using (Graphics g2 = Graphics.FromImage(controlBmp))
                {
                    IntPtr dc1 = g1.GetHdc();
                    IntPtr dc2 = g2.GetHdc();
                    BitBlt(dc2, 0, 0, control.Width, control.Height, dc1, 0, 0, 13369376);
                    g1.ReleaseHdc(dc1);
                    g2.ReleaseHdc(dc2);
                }
            }
            return controlBmp;
        }
复制代码

环境:C1 Studio for Windows && VS 2010

ComponentOne Enterprise | 下载试用

ComponentOne 是一套专注于企业 .NET开发、支持 .NET Core 平台,并完美集成于 Visual Studio 的第三方控件集,包含 300 多种 .NET开发控件,提供表格数据管理、数据可视化、报表和文档、日程安排、输入和编辑、导航和布局、系统提升工具等七大功能,被誉为“.NET开发的‘瑞士军刀’”。

ComponentOne 为您提供专业的产品咨询服务,并由技术支持工程师为您1对1解答。>> 发帖提问

相关产品
推荐相关案例
关注微信
葡萄城社区二维码

关注“葡萄城社区”

加微信获取技术资讯

加微信获取技术资讯

想了解更多信息,请联系我们, 随时掌握技术资源和产品动态