如何正确管理图片预览
我正在开发一个能够显示文件预览的 C# 软件。基本上,左侧有一棵树显示磁盘文件系统条目,右侧有一个面板将显示树中所选文件的预览,在一个可调整大小的面板中包含一个停靠的PictureBox 。最初我只显示图像文件的预览。
这个软件是为游戏开发者设计的,所以我需要支持所有的图像格式,我将使用伟大的 ImageMagick 库用于此目的。关键是有些图像文件可能很大,非常大,所以我有几个关于性能和内存消耗的问题。
- 我需要线程加载图片吗?总是,或者仅当图片很大时?
- 如果我直接在
Picturebox
中加载图片,这将是正确的,或者我应该计算较小尺寸的图像(如缩略图或类似的东西),将其保存到磁盘,然后显示它? - 有人知道我在哪里可以下载大图片文件来测试我的预览与非常大的文件。
I'm developing a C# software that is able to show previews for files. Basically, there is a tree at the left that shows the disk filesystem entries, and a panel on the right that will show a preview of files selected in the tree, in a resizable panel that contains a docked PictureBox
. Initially I only show preview for image files.
This software is designed for game developers, so I need to support all the image formats, I will use the great ImageMagick library for this purpose. The key is that some image files could be big, very big so, I have several questions, about performance and memory consumption.
- Do I need to thread the load of the picture? Always, or only if the picture is very big?
- Would be a correct if I load the picture directly in the
Picturebox
, or should I calculate a smaller size image (like a thumbnail or something similar), save it to disk, and then, show it? - Someone knows where can I download big picture files to test my preview with really very large files.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我总是把这样的作品串联起来,试图决定什么是大的没有什么意义;对于正在谈论的图像,我认为大多数就足够了,在错误的条件下(计算机将资源花费在其他进程上,而不仅仅是您的进程上),它可能会导致 UI 线程中明显的暂停。
在不了解更多信息的情况下,我只会在执行基本操作时测试您的实现并做出判断。还有用户所需的质量和桌面分辨率的问题 - 所以也许这应该以某种方式进行配置。
在我看来,没有比 PolyCount 更好的地方了,具体请查看以下论坛:
http://www.polycount.com/forum/forumdisplay.php?f=42 &
http://www.polycount.com/forum/forumdisplay.php?f=60
Imo always thread a work like this, there is little point in trying to decide what is big; for images that of are talking about I would of thought most would be enough that under the wrong conditions (computer is spending resources on other processes, not just yours) it could cause a perceivable pause in the UI thread.
Without knowing more, I would just test your implementation when it does the basic stuff and make a judgement call. There is also the question of required quality and desktop resolution of the user - so perhaps this should be configurable in some way.
Imo there could be no better place than PolyCount, specifically look in these forums:
http://www.polycount.com/forum/forumdisplay.php?f=42 &
http://www.polycount.com/forum/forumdisplay.php?f=60