本地WPF与自定义的DirectX用于显示图像的

本地WPF与自定义的DirectX用于显示图像的

本文介绍了本地WPF与自定义的DirectX用于显示图像的大的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要加快我的图像浏览器,并想知道如果我要寻找到创造我自己的DirectX控制这样做。

I need to speed up my image viewer, and wondering if I should be looking into creating my own DirectX control to do so.

我的图像浏览器显示医疗图像。他们可以是相当大的。我们谈论55MB,当谈到乳房X光检查。像素数据是存储在一个USHORT阵列16位的灰阶。没有进入的血淋淋的细节,我目前的做法是加载像素数据到的ImageSource,并使用WPF Image控件。

My image viewer displays medical images. They can be pretty large. We're talking 55mb when it comes to mammography. The pixel data is 16bit greyscale stored in a ushort array. Without getting into the gory details, my current approach is loading the pixel data into an ImageSource, and using the WPF Image control.

我从来没有做过与DirectX任何东西。它是值得深入探讨的呢?难道是任何比原生的WPF的东西更快?如果是的话怎么显著?或者,我应该忘掉DirectX和看看在那里我可以提高我目前的做法方面?

I've never done anything with DirectX. Is it worth diving into it? Would it be any faster than the native WPF stuff? If so how significantly? Or, should I just forget about DirectX and look into areas where I can improve my current approach?

在有人对你说的话,我知道WPF利用的DirectX。我想知道如果卸下WPF层,写了DirectX自己会提高性能。

Before somebody says so, I know WPF utilize DirectX. I'm wondering If removing the WPF layer and writing the DirectX myself will improve performance.

推荐答案

我有一些经验借鉴多技嘉卫星和图表图像。周围55MB影像工作或许应该没关系工作,即使没有试图去优化它太多。你还没有真正给予足够的细节来推荐一个替代比其他,所以我会给我的优点和缺点的意见。

I have some experience drawing multi-gigabyte satellite and chart imagery. Working with imagery around 55MB should probably work okay even without trying to optimize it too much. You haven't really given enough detail to recommend one alternative over the other, so I will give my opinion on the pros and cons.

使用2D的Windows API将是最简单的实现,应该永远是速度不够快,如果你不需要旋转,只是想显示图像和缩放和平移。如果你把它当作一个大的图像放大时,如果你与半色调绘制给一个很好的平滑图像的表现不会那么好。这是因为这将有效地在每次它绘制时间阅读图像的所有55MB。

Using 2D windows APIs will be the simplest to implement and should always be fast enough if you don't need to rotate and simply want to display an image and zoom and pan around. If you treat it as one large image the performance will not be as good when you zoom out if you are drawing with halftoning to give a nice smooth image. This is because it will effectively have to read all 55mb of image every time it draws.

要解决这个性能问题,你可以让多个位图,有效MIP映射你的图片。当你缩小你可以选择最接近你正在尝试绘制分辨率降低分辨率的图像。如果你不熟悉MIP映射这里是一个维基百科的链接:

To get around this performance issue you can make multiple bitmaps, effectively mip-mapping your image. As you zoom out you can pick the reduced resolution image closest to the resolution you are trying to draw . If you are not familiar with mip-mapping here is a Wikipedia link:

与DirectX实现这将是10倍的困难。不同的显卡硬件有不同的最大纹理尺寸。最有可能你会需要打破你的图像上到多个纹理绘制,你还必须跟踪渲染状态,查看矩阵等。

Implementing it with DirectX will be 10x as difficult. Different graphics hardware has different maximum texture sizes. Most likely you will need to break your image up in to multiple textures to draw and you will also have to keep track of render states, viewing matrices, etc.

不过,如果你不使用DirectX,您可以通过简单地调整视图矩阵实现大量的实时照片调整可以做到实时旋转。您可以在像素着色器轻松地做到实时对比度,亮度,伽玛和锐度。

However, if you do use DirectX, you can implement lots of real-time photo adjustments You can do real-time rotation by simply adjusting view matrices. You can do real-time contrast, brightness, gamma, and sharpness easily in a pixel shader.

有另外两个API的我可能会建议。如果你愿不愿意把自己限制在Vista或更高版本那么的Direct2D会比Direct3D的简单一些。此外,如果你以往任何时候都需要实现它在非Windows平台上,我建议使用OpenGL代替。我现在的项目是在Direct3D因为几年前,当我们开始它的OpenGL被落在后面,我没有预见的Android设备的普及。现在,我想我们已经使用了OpenGL的替代。

There are two other API's I might suggest. If you are willing to limit yourself to Vista or later then Direct2D would be a little simpler than Direct3D. Also if you ever will need to implement it on a non-windows platform I would suggest using OpenGL instead. My current project is in Direct3D because a few years ago when we started it OpenGL was falling behind and I didn't forsee the popularity of Android devices. I now wish we had used OpenGL instead.

这篇关于本地WPF与自定义的DirectX用于显示图像的大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 22:59