c# - Passing struct to unmanaged DLL with PInvoke -


Due to many restrictions related to the project and not specifically the problem, I have a straight one from PInvoke on C # Data related to Bitmap's MAT maker. In #C # I get a bitmap, called frame, and I'm doing this to access pixel data:

  Bitmapdata data = frame. Lockbits (new rectangle (0,0, frame width, frame height), image lock mod.readwrit, frame pixel format); I am creating the structure for my unmanaged DLL as   

data.Scan0 as IntPtr . Obviously, after calling my external function, I call the frame. Unlockbits (data);

Here the code is C # Invoke

  [DllImport ("Image Processing Experiment", Calling Convention = Calling Convention. CDCL) ] Public static extension zero directory (intimate object, referee export bitmap bitmap); Public authority (height of the public bowel); Public full width; Public IntPtr Data; Public int phase; Public INS Channel; C ++ function declaration   
  CVAPI (empty) drone (objectfender * ojjaprint, export bitmap * bitmap) {/ code>  

Cv :: Mat testmat (CV :: size (bitmap-> width, bitmap-> height), CV_MAKETYPE (CV_8, bitmap-> channel), bitmap-> data, bitmap- & Gt; phase); }

C ++ Structure

  #pragma pack (push, 8) typefif structure exportbitmap {int height; Integer width Zero * data; Int step; Int channel; } ExportBitmap; #pragma pack (pop)  

So far my code seems to work until I create that mat if I modify any parameter except data from IntPtr Everything works fine. When using the Matrix Constructor Line, I get an error saying that DLL is not a valid Win32 application (error code 193 kernel 32 load library (from))

About two solutions to me Stuck for weeks and I'm still not sure what's going on, I can only think of how I am getting editable bitmap data, but I'm not sure that the problem with it Or what could happen.


Comments