Processing images via DirectX on WinRT - image-processing

My friend trying to find a best way for image processing(rotate, flip, zoom, crop) on WinRT, but WriteableBitmapEx too slow (testing on Surface and WP8).
I think, he must use WinRT C++ DirectX for writing library, which will process image via shaders and link it to main C# project, but we don't have any example and don't know how do that.

You can use SharpDX if you want to keep it in C#.
If you dont plan to go on windows phone, Direct2D would be suitable for image processing. Otherwise you have to use Direct3D.

Related

Can I use Direct3D to generate thumbnails?

I can use D3DXCreateTextureFromFile to load an image, and D3DXSaveTextureToFile to save it, but how can I resize it? Should I use IDirect3DDevice9::SetRenderTarget and render to a texture?
Is it slower than doing it on CPU?
Generally you 'resize' images with the GPU by drawing them as a 'fullscreen quad' onto a render target set to the target size. Depending on the size and the data involved, it's probably slower to ship it over the GPU and then rely on readback to get it to disk so doing it on the CPU is usually the better approach. I believe the legacy deprecated D3DX9 utility library you are using can do the resize with D3DXLoadSurfaceFromSurface.
You should not be using Direct3D 9 and/or the legacy D3DX9 library for new projects. See MSDN and Living without D3DX
A better solution is to use the Windows Imaging Component directly to load the image, resize it, and save a thumbnail. See DirectXTex for extensive example code using WIC.

Direct2D versus Direct3D for digital video rendering

I need to render video from multiple IP cameras into several controls within the client application.
On top of the video, I should be able to add some OSD such as timestamp and camera name.
What I'm trying to do has nothing to do with 3D since we're talking about digital video with some text on it.
Which API is more suitable for this purpose? Direct3D or Direct2D?
Performance should also be a consideration here.
It used to be that Direct2D was a poor choice for Windows Phone (if you care about that system) because it wasn't supported, but Win Phone 8.1 has it now, so less of an issue.
My experience with D2D was that it offered fast, high quality 2D rendering, and I would say it is a good choice.
You might want to take a look at this article on Code Project. That looks appropriate for your purposes.
If you are certain you only need MS system support, then you're all set.
Another way to go would be a cross platform system like nanovg, which offers nice 2D rendering and would work on a Mac. Of course, you'd need to figure out how to do the video part on non windows systems.
Regarding D3D, you could certainly do it that way, but my guess would be it would make some things trickier to do. Don't forget you can combine the two as well...

iOS graphics engines

I am new to iOS programming and am interested in working with images. Basically, I want to be able to obtain the (0,255) and RGB tuples of every pixel in a given image. What would be the best way of doing this? Would I need to use Open GL, or something similar?
Thanks
If you want to work with images, get a copy of Apple's 'Quartz 2D Programming Guide'. If you want even more detailed how-to, get a copy of the "Programming with Quartz" book on Amazon (its says Mac in the title as it predates iOS).
Essentially you are going to take images, draw them into bit map contexts, then determine the rgba layout by querying the image.
If you want to use system resources to assist you in making certain types of changes to images, there is a OSX framework recently moved to iOS called the Accelerate Framework. and it has a lot of functions in it for image manipulation (vImage).
For reading and writing images to the file system look at Apple's 'Image I/O Guide'. For advanced filtering there is Core Image, which allows you to apply filters to images.
EDIT: If you have any interest in really fast accellerated code that uses the GPU to perform some sophisticated filtering, you can checkout Brad Larson's GPU Image project on github.

iOS CGImageRef Pixel Shader

I am working on an image processing app for the iOS, and one of the various stages of my application is a vector based image posterization/color detection.
Now, I've written the code that can, per-pixel, determine the posterized color, but going through each and every pixel in an image, I imagine, would be quite difficult for the processor if the iOS. As such, I was wondering if it is possible to use the graphics processor instead;
I'd like to create a sort of "pixel shader" which uses OpenGL-ES, or some other rendering technology to process and posterize the image quickly. I have no idea where to start (I've written simple shaders for Unity3D, but never done the underlying programming for them).
Can anyone point me in the correct direction?
I'm going to come at this sideways and suggest you try out Brad Larson's GPUImage framework, which describes itself as "a BSD-licensed iOS library that lets you apply GPU-accelerated filters and other effects to images, live camera video, and movies". I haven't used it and assume you'll need to do some GL reading to add your own filtering but it'll handle so much of the boilerplate stuff and provides so many prepackaged filters that it's definitely worth looking into. It doesn't sound like you're otherwise particularly interested in OpenGL so there's no real reason to look into it.
I will add the sole consideration that under iOS 4 I found it often faster to do work on the CPU (using GCD to distribute it amongst cores) than on the GPU where I needed to be able to read the results back at the end for any sort of serial access. That's because OpenGL is generally designed so that you upload an image and then it converts it into whatever format it wants and if you want to read it back then it converts it back to the one format you expect to receive it in and copies it to where you want it. So what you save on the GPU you pay for because the GL driver has to shunt and rearrange memory. As of iOS 5 Apple have introduced a special mechanism that effectively gives you direct CPU access to OpenGL's texture store so that's probably not a concern any more.

What is the most efficent way to screen capture? Screen capturing using DirectX?

I've known about screen capture using Device Contexts and GDI, since windows XP. Is there a better way (i.e. DirectX?) now that the desktop is mostly Direct3D.
How can I screen capture using DirectX?
I want to know the most efficent way to user-mode screen capture. For a tech support program that needs frequent screen scrapes.
UPDATE: I don't want to resort to using kernel mode drivers.
I am unsure this will actually be faster than the algorithms you have in mind, but one way to do it would be to copy your buffer out using GetRenderTargetData.
GetRenderTargetData
Based upon vcsjones answer (above). See CodeProject http://www.codeproject.com/KB/dialog/screencap.aspx#And%20The%20DirectX%20way%20of%20doing%20it%20
An alternative method is using Spazzarama's application, which uses DirectX (based on SlimDx) and Easyhook to inject your capture dll into a running application's DirextX pipeline.

Resources