使用GDI +创建保留的图形 [英] Create retained graphics using GDI+

查看:83
本文介绍了使用GDI +创建保留的图形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是.NET的新手,我正在使用VS2008,C ++/CLI开发WinForm图形应用程序,并且需要有关GDI +的一些建议.

I'm fairly new to .NET and I'm developing a WinForm graphic diagram application using VS2008, C++/CLI and need some suggestions on GDI+.

应用程序需要显示简单的图表,文本等.图表和文本表示一些数据,这些数据会不时变化.图的总数应在1000左右.包含所有图和文本的整个画布"需要旋转和 缩放,画布在放大时也需要是可滚动和可拖动的(也就是说,当应用程序窗口小于画布区域时,用户可以使用鼠标拖动来移动画布并查看其不同部分).并且图/文本必须是可选的.

The application needs to display simple diagrams, text etc. The diagrams and text represent some data, which changes from time to time. Total count of diagrams should be around 1000. The entire 'canvas' containing all diagrams and text needs to rotate and zoom, also the canvas, when zoomed in, need to be scrollable and draggable(that is, when application window is smaller than canvas area, user can use mouse drag to move the canvas and see different parts of it). And the diagrams/text need to be selectable.

我简短地测试了覆盖的OnPaint并在那里绘制了图表,使用矩阵执行旋转和缩放,结果是使用鼠标移动画布时出现了闪烁,并且CPU使用率很高.围绕Google并使用SetStyle(ControlStyles :: OptimizedDoubleBuffer, 真的);只是有助于闪烁,但CPU使用率仍然很高.

I briefly tested overriding OnPaint and draw the diagrams there, using matrix to perform rotation and zooming, the result is some flickering and rather high CPU usage, when using mouse to move the canvas. Googled around and use SetStyle(ControlStyles::OptimizedDoubleBuffer, true); which only helped flicker but CPU usage is still high.

我的理解是CPU使用率很高是由于每次都重新绘制所有图表.所以现在的想法是要有一个缓冲区将图保留在某种缓冲区中,在画布移动时刷新整个内容,也只重画更新的 更改数据时的图表.

My understanding the high CPU usage is caused by redrawing all the diagrams each time. so now the idea is to have a buffer to retain the diagrams in a buffer of some kind, refresh the whole thing when canvas is moved around, also only redraw the updated diagrams when data changes.

我想问的问题:

  1. 这个想法可行吗,有什么建议吗?
  2. 是否有任何建议/指南来实现正确的方法?(即用作双缓冲区的正确类是什么?尝试创建位图并使用(不确定是正确的选择,缩放会使文本模糊)
  1. how feasible is the idea, any suggestion?
  2. any suggestion/guide for a proper way to do it? (i.e. what's the proper class to use as a double buffer? tried creating a bitmap and draw on that, not sure it's the right choice, zooming made text blur)

也欢迎您提出2个问题以外的任何建议.

Any suggestions outside scope of the 2 questions are also welcome.

预先感谢!

推荐答案

在我的理解下,您已经开发了一个图表模块,并且有效这个模块并不完美.

我猜想,CPU使用率过高可能是由错误引起的,例如我们认为我们绘制了一个矩形,但实际上程序会多次绘制该矩形 , 因此,当我们旋转和缩放时,CPU使用率将会增加.

I guess, the high CPU usage may be caused by mistakes, for example we think we draw a rectangle, but in fact the program draw the rectangle several times, so when we rotate and zoom the CPU usage will turn up.

如何在.NET Framework中使用图表控件?点击此链接

欢呼声

Skywalker

 


这篇关于使用GDI +创建保留的图形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆