16 bit grayscale image display in WPF - c#

I am developing an application that displays 16 bit grayscale images. The UI for the application was originally created using Win Forms and since Win Forms does not support 16 bit grayscale I wrote a custom openGL control to display the image. Within the last few months we have convert the UI to WPF, but continued to use the openGL image display via a WindowsFormsHost.
WPF is DirectX based so it would make sense to try and get away from the openGL, but does WPF natively support 16 bit grayscale images? or will I have to create a DirectX control?
Also, the openGL control isn't only used to display the image data. The contol allows the user to manipulate the image in various ways (Flip, rotate, Zoom, pan, crop, etc); as well as annotate the image (draw lines, rectangles, measurement angles, etc). If I'm simply using WPF to display the image, how can I also manipulate and annotate using WPF? Plus, I am using a shader to do some color mapping on the image texture. Is something like this possible with WPF or will I have to color map the image data manually before displaying?
I have never used DirectX, so if writing a DirectX control is necessary how difficult will it be to learn and implement what I need?

As for the shaders parts, WPF have access to the HW shaders (and it can emulated them in SW if needed) they are called bitmap effects.
Greg Schechter's covered how to write a custom effect in his blog

Related

WPF - Specialized image display for 16 bit depth grayscale monitors

I am currently developing an application to display 16 bit grayscale images to a 16 bit grayscale compatible monitor.
Most of my experience in software development has been in WPF. However I am reading that even though WPF can accept Gray16 type images, they are internally converted to 32 bit color.
In pursuit of this, I have been using the WPFDXInterop https://github.com/microsoft/WPFDXInterop/ to try and output the image as I want though a DirectX 11 based custom control, and use CUDA and OpenCV at times for image processing.
Am I out of luck in using WPF for this situation? Do I need to change coding environments?
It has been important to me to be able to continue using CUDA and OpenCV for the image processing, but I can change from DirectX to OpenGL is I have to, and learn something other than WPF.

Does drawing icons have better performance than using an image in WPF?

I am working with a WPF application and I came from web development background where I used to use images to show all kind of icons. But in this wpf project I found my senior developer draws them using wpf shapes.
So, it occurred to me is there a well known reason to do that? I mean does it enhance the performance somehow if I draw the icons instead of using images?
So, it occurred to me is there a well known reason to do that?
WPF has vector graphics. They stretch infinitely without losing resolution / quality.
In contrast, bitmaps (such as PNG or JPG) have a specific pixel resolution and they look bad when enlarged too much.
In terms of performance, displaying a bitmap is much cheaper than drawing a vector icon.

OnRender equivalent in Windows Phone

I'd like to implement my own control for Windows Phone. The catch is, that I want to draw it myself - in regular WPF I'd simply override OnRender method and provide my own implementation. However, there is no OnRender method available on Windows Phone. What other options do I have?
What is not acceptable in my case is:
Drawing on bitmap in background and displaying it
Using vector shapes instead of raster drawing
Since Windows.UI.Xaml doesn't have a raster graphics API the only options are to use vector graphics, to render into a bitmap and display that, or to interop to DirectX.
Microsoft's Win2D library at http://microsoft.github.io/Win2D (also see http://blogs.msdn.com/b/win2d/ ) exposes Direct2D through C# and is probably the best match for what you are looking for. It is a work in progress and provides most basic features, but if you need more you'll need to do the interop yourself.
The closest other option is to use a 3rd party library such as WriteableBitmapEx for a high level API to draw into a WriteableBitmap. You could extract the generated bitmap into an ImageBrush for display without an explicit Image control.

How to make a nice overlay with variable transparency using WinForms?

I'm looking for a way to make a WinForm transparent and allow to use semi-transparent images on it.
The common solutions are:
Changing the total opacity of the form and all of its content;
Make only a certain color fully transparent, while the rest will have to be fully opaque;
Use multiple forms to make only some controls transparent.
None of these ways allow to display images or controls which have variable per-pixel transparency value. And I'd like to achieve a cool interface like Steam does with its in-game overlay.
Is there maybe some video game technique that can be used to draw a nice overlay for the whole screen? It's okay if it will have to use 3D graphics drawing libraries and whatnot.

Vector Graphics in C# WinForms - should I interoperate with WPF?

I have a video camera that I'm interfacing with a C# app. The camera actually comes with a .NET WinForms control. It supports drawing on it with GDI+ functions.
When I zoom in, I need <1 pixel accuracy i.e. I want to draw a circle with a radius of less than two pixels. How can I draw vector graphics in WinForms? Is my best bet to overlay a WPF Canvas? I know I can use WPF controls in WinForm apps, but is it possible to make the background of a ElementHost/WPF canvas transparent and overlay it onto my video feed? Am I better off creating a WPF app, and only using this video control on the WindowsFormsHost provider?
Any other solutions of drawing vector graphics in C# apps?
Thanks in advance.
Well, unfortunately you won't be able to use WPF to overlay anything on your WinForms control due to airspace issues. Winforms and WPF content is not allowed to overlap inside the same window. You're stuck using vanilla GDI or another custom Winforms vector library.
MSDN Link to explanation of interoperability issues.

Categories

Resources