Search code examples
c#c++typescalldllimport

Use C++ library in C# with Bitmap type?


Let me explain, I' ve found some informations how to make a DLL and call it from C# code, but what I want to do is to replace Bitmap.Save(String path) with custom-made C++ function

I want to optimize my code, because C# bitmap Save() method seems to have a tons of shitload Strings / Stringbuilders etc. which is making my code creepy in profiler data

How to write C++ function to work with Bitmap C# class? To pass the bitmap parameter...

Should I have rather write full C++ Dll for bitmap optimization rather than hardtrying to mix both languages?


Solution

  • You can get the bitmap GDI+ handle using Bitmap.GetHbitmap()