My C# application uses DirectShow and requires DirectX to run. I would like check that DirectX is enabled at start-up, can anyone advise the correct method to do so?
Thanks
DirectShow is not a part of DirectX. There is only some intersection in video renderer using DirectDraw and Direct3D, and wrappers over audio APIs which are in fact no longer independent but wrappers over other APIs. I would say there is nothing to check for and DirectShow is already an OS core component, but if you have some specific concerns then what are they? Maybe you could attempt to create some DirectX object directly on app startup and see if this attempt is successful.
I think I'm right in saying if the DirectX DLLs aren't installed on the host machine, your application wont even start. Beyond that, you should always be checking that creation of DirectX objects succeeds before attempting to use them.
Related
I am making a C# app to capture graphic from an avermedia pcie capture card.
But it seems that there are no out of box tools to do so.
So I made a C++ directshow app to do the capture, which is a console app and opens a capture window when running.
How can I redirect the output to a C# app? for example, to a CaptureElement?
So you want to have XAML CaptureElement connected to AverMedia PCIe capture card. This sounds like a well-understood challenge overall, however every other piece of technology you mentioned is eventually a bad choice: DirectShow, multiple apps with piping, redirection and fitting of cutsom code to XAML CaptureElement control.
Microsoft has intentionally been limited ways you can integrate different APIs and so there are not so many ways to get everything together.
Let us go over the supposed integration path. The capture card is supposed to be shipped with a compatible driver:
Video capture devices are supported through the UVC class driver and must be compatible with UVC 1.1
When this is the case, such devices are visible to Media Foundation API handling video capture among tasks. XAML CaptureElement would be able to see a video capture device through this API and this way everything is supposed to work without need to fit anything from your end.
If this is not happening, it suggests you are dealing with an unsupported device coming without suitable or compatible driver.
Previous media API in Windows was DirectShow but its days are gone. It remains perfectly working as a legacy framework, a lot of applications out there are still relying on it. Specifically it will not integrate with new technology like XAML and UWP. More to that, even Media Foundation itself, the current media API, in its public offering is lagging behind when it comes to fitting with most recent technology. Having said that it is a good idea to stay well clear of DirectShow here if this is at all possible.
I see no need for cross-process design with video travelling between process through piping. There is no good reason for such design and even though this can work efficiently (Windows itself proves it can work great in terms of performance by having so called Frame Server service in it), this is not to be built on piping. In your case it is unlikely to be have to be built on multiple processes either. Instead you can develop a native code DLL project that takes care of video acquisition and connects to managed code via suitable glue layer: C++/CLI, COM, C++/WinRT and such.
Then next thing is fitting to XAML CaptureElement. The control is designed to work with Windows.Media.Capture.MediaCapture class that talks to hardware and you don't have suitable hardware as you plan to implement your own acquisition layer. Long story short you are not supposed to forward external data to CaptureElement and you would have hard time doing this. Your best strategy is to upload externally obtained data to Windows.Graphics.Imaging.SoftwareBitmap or alike and take involved performance impact as acceptable. That is, you will be dealing with video frames as images.
An alternative way is to upload acquired video frames into Direct 3D 11 textures and it would open you a more performant way of integration with video related controls, such as Windows.UI.Xaml.Controls.SwapChainPanel however it would also require that you put much more development effort in there.
I need to rotate an image clockwise only just once after a certain operation. I felt so lazy to include rotating logic to my current image operations class then I come with this idea. What I need is already built within windows explorer, so is it possible to trigger windows explorer's rotate operations within a c# application for a valid file specified?
I have doubts that I can't access to that kind of functionality but I wanted to ask to make sure.
Thanks!
You're better off not relying on the feature since it is not part of the API and can disappear at any time. You should just do your own image rotation.
I don't think its possible to do it with Windows Explorer's integrated photo rotating, but you should check out the awesome image editing/processing library called ImageMagick. The original API is a native windows (dll) API, but there is a good .NET wrapper that is easy to use.
Here it is:
http://imagemagick.codeplex.com/
There are also wrappers for two dozen or so other languages, linked at ImageMagick's site:
http://www.imagemagick.org/
I am not able to apply 3D effects on WPF's built-in WebBrowser, because it is just a thin wrapper around the native ActiveX-Webbrowser, which isn't based on WPF. I saw most of the places people suggested about one Link ,but I m not able to make it work in my application and it is having so many dlls which I don't want. Can anybody suggest me any other good alternative solution present then?
Maybe you forget to copy the needed awesomium.dll & AwesomiumProcess.exe with your executing assembly (which are not .Net assemblies).
I also have some difficulties to run with awesomium but it's not impossible.
I can recommand you the Troymium/TroymiumNet which is actively maintain by its developers.
I use it on Microsoft Surface to connect people to their facebook account.
I've never used it, but you could try Berkelium with berkelium-sharp.
Can anyone tell me how to hook/overlay a DirectX game in C#?
I've tried getting a fullscreen C# window to overlap a game, however it wont.
After researching a little, I found out that I need to hook the game and then display the C# window.
Can anyone explain how I would do this?
Would I be able to display a C# form over a DirectX game?
You can try my example on hooking the Direct3D 9 API using C#. This utilizes EasyHook an open source .NET assembly that allows you to install hooks from managed code into unmanaged functions.
SlimDX is also used - this is an open source managed wrapper around the Direct3D libraries.
The tricky part of the hooking is determining the addresses of a COM objects' virtual functions. This is done in the above example using a small C++ helper DLL that finds the addresses from the VTable. [Update: there is a comment posted that show's how to get the function pointers from the VTable in C# also - given a IntPtr to the com object]
The example hooks the EndScene method of an IDirect3DDevice9, which is also where you would want to draw any overlays. As to displaying a form in the overlay I'm not so sure that will be so easy - I mean you can render the image easily enough, but you will have to capture inputs and manually respond/pass-thru the events to the form in question appropriately. Good luck!
(disclosure: I work for this company)
You can try our Deviare API, it has functionality to hook COM objects from C#.
It's a set of COM objects that can be used from any programming language (supporting COM). An article with source code showing how to capture video and add an overlay is available: instrumenting Direct3D applications to capture video and calculate FPS
COM Spy Console and Direct Sound Capture are two examples that implements a console to hook COM objects like DirectX.
Hope it helps.
Since you don't have direct DirectX Access from C# this may be tricky.
From my limited understanding of the concept:
DirectX Hooks consist of attaching to a DirectX Context and manipulating it, this may/may not require messing with another program's memory, something that's best suited to C/C++
I may be wrong though, however this is an advanced topic and my gut tells me you may have issues under .NET
Using ExternalInterface in AS3 is it possible to call OS (C#?) functions within XP?
Example: Set the desktop background to a image supplied by a flash app?
If it is possible would it be different calls when applied to different OS. And what about cross over the Mac?
Any information would be great
Thanks
If you're launching the swf from within a C# app, external interface will do just fine. Nothing will change on the flash side, but you'll need to go through a couple hoops to get it to work in C#. It's not as simple as AMF or External Interface to JS.
All the communications to C# get converted to XML describing the data, and you've gotta write XML to send back to flash. Other than that though, its relativly simple.
Here's some info on how to do it. The AS portion is Flash 8/AS2, but the C# portion should say the same.
When working with Flash from a webpage or as a desktop app, you are limited to a small security sandbox and you will not be able to make any relevant OS call. I thought that switching to AIR would give the developper more flexibility but it doesn't seem correct either. From "The Pros and Cons of Adobe Air":
AIR apps have
file access, clipboard access, support
multiple windows, support drag and
drop, and can trigger notifications
(toast in Windows). If you app needs
to interact with the desktop in other
ways, the chances are that AIR is not
suitable. For example, there is no
access to COM automation, and no way
to execute external applications. The
reason is to maintain cross-platform
compatibility. That's a worthy goal,
but it would be good to have a way out
of the sandbox. Unlike Java or .NET,
you cannot extend AIR with custom
native code libraries. Nor can you
call operating system APIs.
As Alex Jillard commented, if your swf is called inside a C# desktop application, you should be able to access more OS funcionalities although I'm not sure how.
You could use as already mentioned AIR. Another idea would be to use HippoHX (I haven't written this, the similarity with my username is just coincidence). It runs on top of the NekoVM and gives you unrestricted (so no limitations like in AIR ) access to the system.