Direct3DHook
Direct3DHook copied to clipboard
When creating an ImageElement with the "Bitmap bitmap" override, DXHookD3D11 throws an exception
Hi!
So I'm trying to create an ImageElement from a Bitmap... until now, I was using the ImageElement's "Image" property, and converting my bitmap into a byte[] and using that to construct a new ImageElement, and this was and is working fine...
My problem however, is I'm trying to make the update loop as fast as possible, and converting an 1920x1080 bitmap to a byte[] takes more than 16ms, which is way to long for my purposes... I'm trying to use the "correct" method, and constructing the ImageElement with the Bitmap override to save some time, but for some reason, it always throws an error, and I can't seem to figure out what the issue is... Below I attached some additional context :)
Exception message:
Debug: DXHookD3D11: PresentHook: Exeception: System.ArgumentException: System.ArgumentException: Parameter is not valid.
Server stack trace:
at System.Drawing.Image.get_Width()
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at System.Drawing.Image.get_Width()
at RenderHookAPI.Hook.DX11.DXImage.Initialise(Bitmap bitmap) in D:\source\repos\DamnOverSharp\RenderHookAPI\Hook\DX11\DXImage.cs:line 55
at RenderHookAPI.Hook.DX11.DXOverlayEngine.GetImageForImageElement(ImageElement element) in D:\source\repos\DamnOverSharp\RenderHookAPI\Hook\DX11\DXOverlayEngine.cs:line 199
at RenderHookAPI.Hook.DX11.DXOverlayEngine.InitialiseElementResources() in D:\source\repos\DamnOverSharp\RenderHookAPI\Hook\DX11\DXOverlayEngine.cs:line 108
at RenderHookAPI.Hook.DX11.DXOverlayEngine.Initialise(Device device, Texture2D renderTarget) in D:\source\repos\DamnOverSharp\RenderHookAPI\Hook\DX11\DXOverlayEngine.cs:line 82
at RenderHookAPI.Hook.DX11.DXOverlayEngine.Initialise(SwapChain swapChain) in D:\source\repos\DamnOverSharp\RenderHookAPI\Hook\DX11\DXOverlayEngine.cs:line 44
at RenderHookAPI.Hook.DXHookD3D11.PresentHook(IntPtr swapChainPtr, Int32 syncInterval, PresentFlags flags) in D:\source\repos\DamnOverSharp\RenderHookAPI\Hook\DXHookD3D11.cs:line 556
The code that handles updating the overlay (called every frame):
public void Draw(Bitmap frame, Point topLeft)
{
CaptureProcess.CaptureInterface.DrawOverlayInGame(new RenderHookAPI.Hook.Common.Overlay
{
Elements = new List<RenderHookAPI.Hook.Common.IOverlayElement>
{
new RenderHookAPI.Hook.Common.ImageElement(frame) { Location = topLeft }
}
});
}
Thanks in advance for anyones help :)! M