显示派生图像的最佳方法? [英] Best method to display a derived image?

查看:68
本文介绍了显示派生图像的最佳方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在试图找出显示从大量数据中获取的图像部分的最佳和最快的方法。



目前我有一个带滚动条的图片框,应用程序只计算和绘制图片框尺寸所需的图像。为了提高速度,我在图像构造中使用Lockbits和并行For循环。它的工作原理非常好,但如果用户拖动滚动条,程序会重新绘制时会有一些延迟。



我过去使用的应用程序更多响应。我猜他们必须巧妙地重复使用已知的图像部分,如果他们拖动滚动条,也可以为用户准备好预先制作的平铺图像。



我想要尽可能实现类似的东西,但我不确定最好的方法。



请问是否有人可以提供任何好的建议非常感谢。

Hi,

I am trying to figure out the best and fastest way to display image parts which are derived from a large set of data.

Currently I have a picturebox with scrollbars and the application calculates and plots only the image needed within the picturebox dimensions. For additional speed I am using Lockbits and a parallel For loop in the image construction. It works very well as-is, but there is some lag while the program redraws if the user drags the scrollbars.

I have used applications in the past that are more responsive. I guess they must cleverly re-use known image parts and also may have pre-made tiled images ready for the user if they drag the scrollbars.

I'd like to implement something similar if possible but I'm not sure of the best way to go about it.

Could I ask if anyone can kindly offer any suggestions on a good method ?

Many thanks.

推荐答案

这是一个提示:



要将图像的一部分复制到另一个图像上,请使用 System.Drawing.Graphics.DrawImage

https://msdn.microsoft.com/en-us/library/system。 drawing.graphics.drawimage.aspx [ ^ ]。



请注意,接受目标矩形的方法将执行重新采样要复制的图像,如果源和目标矩形大小不同,这是一个相当大的性能损失;并且图像质量可能会受到影响。避免他们。例如,使用这些方法:

https:// msdn。 microsoft.com/en-us/library/ms142038.aspx [ ^ ],

https:// msdn.microsoft.com/en-us/library/ms142039.aspx [ ^ ]。



获取的实例System.Drawing.Graphics 要绘制位图,请使用 https ://msdn.microsoft.com/en-us/library/system.drawing.graphics.fromimage(v = vs.110).aspx [ ^ ]。



你ee,没有 LockBits 或类似的东西。 LockBits 只有你必须在比特级别进行操作,想要转换像素类型等事情才需要。



这就是全部。



并且不要使用 System.Windows.Forms.PictureBox 进行操作。即使您想使用这种纯冗余控件类型(在某些简单情况下也很方便),使用图像进行所有计算,使用 System.Drawing.Bitmap 作为目标你的计算,并在完成后,将此图像分配给 PictureBox.Image
Here is a hint:

To copy a part of the image onto another image, use System.Drawing.Graphics.DrawImage:
https://msdn.microsoft.com/en-us/library/system.drawing.graphics.drawimage.aspx[^].

Note that the methods which accept the target rectangle will perform re-sampling of the image to be copied, if source and target rectangles sizes are different, which is a considerable performance hit; and the image quality may be compromised. Avoid them. Use, for, example, these methods instead:
https://msdn.microsoft.com/en-us/library/ms142038.aspx[^],
https://msdn.microsoft.com/en-us/library/ms142039.aspx[^].

To get an instance of System.Drawing.Graphics to draw on a bitmap, use https://msdn.microsoft.com/en-us/library/system.drawing.graphics.fromimage(v=vs.110).aspx[^].

You see, no LockBits or anything like that. LockBits is only needed if you have to manipulate at the level of bits, want to convert pixel types, things like that.

That's all.

And don't manipulate with System.Windows.Forms.PictureBox. Even if you want to use this purely redundant control type (which can be convenient in some simple cases), do all calculations with images, use System.Drawing.Bitmap as a target of your calculations, and, when they are done, assign this image to PictureBox.Image.


这篇关于显示派生图像的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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