901018-鬼像在哪里? [英] 901018 - where's the ghost image?

查看:71
本文介绍了901018-鬼像在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 在由表单中的图片框组成的简单表单应用程序中,我想知道是否存储了图片框内容.作为描述,假定未分配图片框的图像,并且其表面由代码渲染,该代码计算花费大量时间的复杂公式.在这样的应用程序中,它是如此好,以至于任务切换导致应用程序被隐藏并再次显示,而不会导致图片框的表面被重新粉刷.由于未进行任何更改,因此不会生成paint事件,并且无需调用复杂代码即可自动绘制表面.
在不需要再次渲染的情况下,似乎使用Image来存储图片框表面.
我的问题是我想要这个Image对象!"
为了什么?例如将我通过代码绘制的内容保存到文件中.也用于通过鼠标等模拟平移.
我希望你能得到我的想法和问题.
有什么办法,线索等吗?
thx

解决方案

如果看不到该应用程序,则不可能确定,但​​我将为BitviewBox分配一个位图,然后在BackgroundWorker线程中绘制该位图.这样,如果将应用程序最小化,绘图仍会继续,但是代码不会阻止paint事件(这会严重破坏您的应用程序!)当工作线程完成时,我将使PictureBox无效并导致重新绘制方式.

我不知道-我还没有尝试这样做,以及是否有必要在后台任务进行处理时锁定位图,但这是我第一次尝试的方法.如果出现问题,那么我仍然会在后台线程中绘制一个位图,但可能会定期将其复制到另一个位图中,并使用Progress事件来更新PictureBox.


hi in a simple form application consisting of a picture box in the form, i like to know whether the picture box content is stored. as a description, assume that Image of the picture box is not assigned and its surface is rendered by a code which calculates a complex formula taking so much time. in such an application, it''s so good that task switching which causes the application to get hidden and shown again doesn''t cause the surface of the picture box to be repainted. since nothing is changed, the paint event is not generated and the surface is painted automatically without recalling the complex code.
it seems that an Image is used for storing the picture box surface for such cases which rendering again is not required.
my problem is that "i want this Image object!"
for what? for eg. saving what i have drawn by the code into a file. also for simulating pan by mouse, etc.
i hope u could get my idea and question.
is there any way, clue, etc.?
thx

解决方案

Without seeing the app, it if not possible to be definitive, but I would assign an Bitmap to the PictureBox, then draw into that bitmap in a BackgroundWorker thread. That way, if the app is minimized the drawing still continues, but the code is not blocking the paint event (which would seriously mess up your application!) When teh worker thread finished, I would Invalidate the PictureBox and cause a re-paint that way.

I don''t know - I haven''t tried to do that, and whether it would be necessary to lock the bitmap while the background task works on it or not, but that is what I would try as a first attempt. If there were problems, then I would still draw into a bitmap in a background thread, but possibly copy it out into a different Bitmap at intervals and use the Progress event to update the PictureBox.


这篇关于901018-鬼像在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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