I am programming some graphical filters in my main program which is based upon C#.
However C# is not fast for getpixel / putpixel.
I’ve seen workarounds for it, using unsafe code in C#
Unsafe code gives me a bit an unsafe feeling too, as i understand the benefit of safe code and memory cleanup.
So now i am wondering….
Might it be better to write this unsafe code in a separated dll based on C++ ?.
However I never made mixed language programs, so i am wondered.
- How would one pass a bitmap from C# to a function in a C++
i can set the reference to the dll, but i dont think that will be enough - How would one pass some returned values and the bitmap back again to the c# main program
Also what if i used another compiler to write the c++11 .dll would that be a problem?
The main program is written in visual studio 2010 expres
If you use C++ then you also can use C# with unsafe code. Both is unsafe and in C# you still don’t need to care about memory cleanup. The only thing you have to care about is accessing invalid pointers which will cause a
AccessViolationException.I’m using unsafe code in my image libraries too. If you are not going cross-plattform you can also use C++/CLI.