Direct2D的 - preserve现有内容和覆盖新价值 [英] Direct2D - preserve the existing content and overwrite the new values

查看:304
本文介绍了Direct2D的 - preserve现有内容和覆盖新价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我计划建立一个XY绘图仪为我的申请。为了让一些基本的想法,它应该是什么样子(当然的实施将是不同的),请参阅的这里这里

I am planning to develop a XY Plotter for my application. To give some basic idea, how it should look like (of course the implementation would be different), please refer here and here.

在模拟过程中(我们假设,它需要4小时以完成模拟),在一个固定的X轴,新的Y值应(过)编写的。

During the simulation (let's assume, it takes 4 hours to complete the simulation), on a fixed X axis, the new Y values should be (over)written.

不过,与Direct2D的问题是,每一次 prenderTarget-> BeginDraw()被调用时,现有的绘图(/剧情/位图/图片等)被删除,新的图像正在绘制。因此,我就失去了旧的价值观念。

But, the problem with Direct2D is that, every time pRenderTarget->BeginDraw() is called, the existing Drawing(/Plot/BitMap/Image, etc) is deleted and a new image is being drawn. Therefore I would lose the old values.

,我总能缓冲老Y值在缓冲区/变量,并使用它的下一个图形中。但是,模拟运行4小时,不幸的是我不能保存所有的Y值。这就是为什么,我需要渲染/借鉴现有目标图像/绘制新的Y值的/ etc。

Of course, I can always buffer the old Y values in a buffer/variable and use it in the next drawing. But, the simulation runs for 4 hours and unfortunately I can't afford to save all the Y values. That's why, I need to render/draw the new Y values on the existing target-image/plot/etc.

和,如果不叫 prenderTarget-> EndDraw()在规定时间内一定量,我的应用程序会崩溃,由于资源的限制

And, If don't call pRenderTarget->EndDraw() within a definite amount of time, my application would crash due to resource constraints.

我如何prevent这个问题,并达到要求?

How do I prevent this problem and achieve the requirement?

推荐答案

什么你问的是一个相当复杂的需求 - 这是比看起来更困难! Direct2D的是href="http://msdn.microsoft.com/en-gb/library/windows/desktop/ff684178(v=vs.85).aspx" rel="nofollow">直接模式绘图API的。没有国家维护你所吸引到在即时模式图形屏幕或持久性。

What you're asking is quite a complex requirement - it's more difficult than it appears! Direct2D is an Immediate-Mode drawing API. There is no state maintenance or persistence of what you have drawn to the screen in immediate mode graphics.

在最直接模式的图形API,还有剪裁和肮脏rects的概念。在Direct2D中,你可以使用这三种技术绘制到屏幕的一个子集。渲染屏幕外的位图和双缓冲可能是一个很好的技术尝试。例如你的过程就变成了:

In most immediate-mode graphics APIs, there is the concept of clipping and dirty rects. In Direct2D you can use one of these three techniques to draw to a subset of the screen. Rendering offscreen to bitmap and double-buffering might be a good technique to try. e.g. your process becomes:

  • 在画到离屏位图
  • BLIT位图筛选
  • 在新的数据,得出了一个新的位图/结合现有的位图

此技术将只工作,如果你的阴谋没有滚动或规模改变,因为你添加新的数据/平局。

This technique will only work if your plot is not scrolling or changing in scale as you append new data / draw.

这篇关于Direct2D的 - preserve现有内容和覆盖新价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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