Open MarcellVokk opened 1 year ago
Update:
I also came across this exception:
Debug: DXHookD3D11: PresentHook: Exeception: System.Runtime.Serialization.SerializationException: System.Runtime.Serialization.SerializationException: Type 'System.Drawing.Imaging.BitmapData' in Assembly 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable.
Server stack trace:
at System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context)
at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo()
at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder)
at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder)
at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)
at System.Runtime.Remoting.Channels.BinaryServerFormatterSink.SerializeResponse(IServerResponseChannelSinkStack sinkStack, IMessage msg, ITransportHeaders& headers, Stream& stream)
at System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)
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.Bitmap.LockBits(Rectangle rect, ImageLockMode flags, PixelFormat format)
at RenderHookAPI.Hook.DX11.DXImage.Initialise(Bitmap bitmap) in D:\source\repos\DamnOverSharp\RenderHookAPI\Hook\DX11\DXImage.cs:line 58
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
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:
The code that handles updating the overlay (called every frame):
Thanks in advance for anyones help :)! M