Image WPF and DirectX SurfaceFormat

I have a 16-bit grayscale image that I want to display using WPF in .NET 3.5 sp1. I am currently displaying this image using the built-in winform that uses OpenGL to set the image display format in Luminance 16.

DirectX has a similar property, SurfaceFormat .

I want to be able to display an image in WPF and install SurfaceFormat on Luminance16. How to do it?

Note. Currently, although WPF natively supports Gray16, it does not display Gray16 properly.

Edit: The real answer is that WPF is not doing what it says. Gray16, supported mainly, actually divides by 256 to fit into a 16-bit display. Thus, the Gray16 format is a lie that burns like acid in the eyes.

+3
source share
2 answers

You do not need to do this in WPF.

WPF supports 16bpp grayscale images . I believe that they can be downloaded from a TIF file using the built-in TIFF decoder.


Edit in response to comment:

If you are unhappy with the default rendering in WPF, you can also use DirectX to directly display the surface. This (in this way) is best done using C ++ / CLI, but you can fully use C # using SlimDX.

A better approach is to use D3DImage . There is an introduction to using CodeProject . You should be able to directly port your OpenGL code, given the differences in DX. However, the good thing about D3DImage is that you no longer need to place a common control - you can put it directly in the WPF brush and use it anywhere in WPF.

+2
source

WPF is not a real problem - most screens do not support 16-bit output, so you need to compress 16-bit gray levels to 8 bits.

This can be done by dividing by 256 or using a histogram-based algorithm to immerse the 2 ^ 16 gray level in 256 bins in another way.

This requires image processing, and there are many articles on different approaches (search for images with high dynamic range). You can use HLSL shaders to help.

0
source

All Articles