2015-04-10 01:51:37 -0600 | received badge | ● Teacher (source) |
2015-04-09 23:01:56 -0600 | received badge | ● Necromancer (source) |
2015-04-09 09:34:13 -0600 | answered a question | Convert DLL IntPtr to byte[] to bitmap I have tested two ways that solve C# (Bitmap) and native C++ (cv::Mat) communication problem. All communication is based by C++ Dll which is used in C# by DllImport-ing (PInvoke). For image information storing I use two similar structures. C++ structure consists char* member for image data and C# structure consists InPtr for same data. C# structure is defined as [StructLayout(LayoutKind.Sequential)]. This "ImgBridge" is main condition for successful communication. There are two functions for C# that convert C# (Bitmap) to C++ (cv::Mat) and vice versa via mentioned "ImgBridge".: _ Both these function use CopyImgData function.: At the beginning I had written that I have tested two ways. The second one inspired by GitHub/shimat/opencvsharp project https://github.com/shimat/opencvsharp... If you would like to try this one you will need to extract CopyMemory function https://github.com/shimat/opencvsharp... and implement it in your C# code. After this process you have to swap original CopyImgData function by for ImgBridge2Bitmap and by this (more) |
2015-04-09 08:12:05 -0600 | received badge | ● Editor (source) |
2015-04-08 02:50:09 -0600 | answered a question | Convert DLL IntPtr to byte[] to bitmap Hello to everyone, have anybody solved this problem yet ? I am just trying to send my own structure (ImgBridge) with image data from native c++ to c# via DllImport-ing (PInvoke). On C++ side image data are stored in uchar* and on C# side they are stored in IntPtr (this image data, width, height etc. are members of ImgBridge structure). Communication works fine so that means if i send image from native c++ to C# I can create and display an bitmap or send it back to C++. Despite of this fact I have one problem. If I send rotated image (cv::warpAffine) from C++ to C# I can not reconstruct a valid Bitmap from this data. I hope it is not problem of rotating.. Image looks that it is snap by diagonal CPlusPlus_2_CSharp.jpg and I do not why. Image data are continuous (cv::Mat::isContinuous()) and I have suspicion on my converting function. Could you help me with this problem please? (I do not want to use Emgu, OpenCVSharp or any other) Thank You This is a fragment of my code (C#) which convert communication structure to Bitmap.: |